From 40085acbae3720b5ca6857f699f0f025df4a700d Mon Sep 17 00:00:00 2001 From: Megvii Engine Team Date: Thu, 24 Jun 2021 18:55:04 +0800 Subject: [PATCH] fix(mgb): remove unnecessary cudnn8 warning GitOrigin-RevId: 04cf1bfca93273953941a2f5904dc31b5f56cc4e --- dnn/include/megdnn/common.h | 26 ++++++++++++++++++++++++++ dnn/src/cuda/handle.cpp | 11 +++++++---- src/core/include/megbrain/common.h | 12 +----------- 3 files changed, 34 insertions(+), 15 deletions(-) create mode 100644 dnn/include/megdnn/common.h diff --git a/dnn/include/megdnn/common.h b/dnn/include/megdnn/common.h new file mode 100644 index 00000000..93fa158d --- /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 2c6eb987..3ab55094 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 e999515e..5283e1b8 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)