@@ -0,0 +1,26 @@ | |||||
/** | |||||
* \file dnn/include/megdnn/common.h | |||||
* MegEngine is Licensed under the Apache License, Version 2.0 (the "License") | |||||
* | |||||
* Copyright (c) 2014-2021 Megvii Inc. All rights reserved. | |||||
* | |||||
* Unless required by applicable law or agreed to in writing, | |||||
* software distributed under the License is distributed on an | |||||
* "AS IS" BASIS, WITHOUT ARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||||
*/ | |||||
#pragma once | |||||
#if MGB_ENABLE_GETENV | |||||
#define MGB_GETENV ::std::getenv | |||||
#else | |||||
#define MGB_GETENV(_name) static_cast<char*>(nullptr) | |||||
#endif | |||||
#ifdef WIN32 | |||||
#define unsetenv(_name) _putenv_s(_name, ""); | |||||
#define setenv(name,value,overwrite) _putenv_s(name,value) | |||||
#endif | |||||
// vim: syntax=cpp.doxygen foldmethod=marker foldmarker=f{{{,f}}} |
@@ -16,6 +16,7 @@ | |||||
#include "src/cuda/handle.h" | #include "src/cuda/handle.h" | ||||
#include "src/cuda/utils.h" | #include "src/cuda/utils.h" | ||||
#include "src/cuda/api_cache.h" | #include "src/cuda/api_cache.h" | ||||
#include "megdnn/common.h" | |||||
#include <cuda.h> | #include <cuda.h> | ||||
#include <cstring> | #include <cstring> | ||||
@@ -59,10 +60,12 @@ HandleImpl::HandleImpl(megcoreComputingHandle_t comp_handle): | |||||
"cuda library version is too low to run cublasLt"); | "cuda library version is too low to run cublasLt"); | ||||
#endif | #endif | ||||
#if CUDNN_VERSION >= 8000 | #if CUDNN_VERSION >= 8000 | ||||
megdnn_log_warn(R"( | |||||
Cudnn8 will jit ptx code with cache. You can set | |||||
CUDA_CACHE_MAXSIZE and CUDA_CACHE_PATH environment var to avoid repeat jit(very slow). | |||||
For example `export CUDA_CACHE_MAXSIZE=2147483647` and `export CUDA_CACHE_PATH=/data/.cuda_cache`)"); | |||||
if (!MGB_GETENV("CUDA_CACHE_PATH")) { | |||||
megdnn_log_warn(R"( | |||||
Cudnn8 will jit ptx code with cache. You can set | |||||
CUDA_CACHE_MAXSIZE and CUDA_CACHE_PATH environment var to avoid repeat jit(very slow). | |||||
For example `export CUDA_CACHE_MAXSIZE=2147483647` and `export CUDA_CACHE_PATH=/data/.cuda_cache`)"); | |||||
} | |||||
#endif | #endif | ||||
cudnn_check(cudnnCreate(&m_cudnn_handle)); | cudnn_check(cudnnCreate(&m_cudnn_handle)); | ||||
cublas_check(cublasCreate(&m_cublas_handle)); | cublas_check(cublasCreate(&m_cublas_handle)); | ||||
@@ -13,6 +13,7 @@ | |||||
#include "megbrain_build_config.h" | #include "megbrain_build_config.h" | ||||
#include "megdnn/basic_types.h" | #include "megdnn/basic_types.h" | ||||
#include "megdnn/common.h" | |||||
#include <memory> | #include <memory> | ||||
#include <string> | #include <string> | ||||
@@ -199,17 +200,6 @@ void __log__(LogLevel level, const char *file, const char *func, int line, | |||||
/* ================ misc ================ */ | /* ================ misc ================ */ | ||||
#if MGB_ENABLE_GETENV | |||||
#define MGB_GETENV ::std::getenv | |||||
#else | |||||
#define MGB_GETENV(_name) static_cast<char*>(nullptr) | |||||
#endif | |||||
#ifdef WIN32 | |||||
#define unsetenv(_name) _putenv_s(_name, ""); | |||||
#define setenv(name,value,overwrite) _putenv_s(name,value) | |||||
#endif | |||||
// use some macro tricks to get lock guard with unique variable name | // use some macro tricks to get lock guard with unique variable name | ||||
#define MGB_TOKENPASTE(x, y) x ## y | #define MGB_TOKENPASTE(x, y) x ## y | ||||
#define MGB_TOKENPASTE2(x, y) MGB_TOKENPASTE(x, y) | #define MGB_TOKENPASTE2(x, y) MGB_TOKENPASTE(x, y) | ||||