diff --git a/dnn/include/megdnn/common.h b/dnn/include/megdnn/common.h new file mode 100644 index 0000000000000000000000000000000000000000..93fa158dc6c1d36c1054ced407f4ecf968cf87e3 --- /dev/null +++ b/dnn/include/megdnn/common.h @@ -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(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}}} diff --git a/dnn/src/cuda/handle.cpp b/dnn/src/cuda/handle.cpp index 2c6eb987d2aa56afeb33e1cddce751787b9c8919..3ab550941cc67ebad6ccc89f72a79b18b3f99964 100644 --- a/dnn/src/cuda/handle.cpp +++ b/dnn/src/cuda/handle.cpp @@ -16,6 +16,7 @@ #include "src/cuda/handle.h" #include "src/cuda/utils.h" #include "src/cuda/api_cache.h" +#include "megdnn/common.h" #include #include @@ -59,10 +60,12 @@ HandleImpl::HandleImpl(megcoreComputingHandle_t comp_handle): "cuda library version is too low to run cublasLt"); #endif #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 cudnn_check(cudnnCreate(&m_cudnn_handle)); cublas_check(cublasCreate(&m_cublas_handle)); diff --git a/src/core/include/megbrain/common.h b/src/core/include/megbrain/common.h index e999515e189be124e0acdb97dbe701ea465fd8ac..5283e1b8188f05dd3b535dc245535b35a23d035e 100644 --- a/src/core/include/megbrain/common.h +++ b/src/core/include/megbrain/common.h @@ -13,6 +13,7 @@ #include "megbrain_build_config.h" #include "megdnn/basic_types.h" +#include "megdnn/common.h" #include #include @@ -199,17 +200,6 @@ void __log__(LogLevel level, const char *file, const char *func, int line, /* ================ misc ================ */ -#if MGB_ENABLE_GETENV -#define MGB_GETENV ::std::getenv -#else -#define MGB_GETENV(_name) static_cast(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 #define MGB_TOKENPASTE(x, y) x ## y #define MGB_TOKENPASTE2(x, y) MGB_TOKENPASTE(x, y)