This repository has been archived by the owner on Nov 17, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6.8k
cuda/cuDNN lib version checking. Force cuDNN v7 usage. #15449
Merged
KellenSunderland
merged 5 commits into
apache:master
from
DickJC123:cuda_cudnn_version_checks
Jul 12, 2019
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
7192fc8
Add STATIC_ASSERT_{CUDA,CUDNN}_VERSION_GE macros. Protect rnn.cc aga…
DickJC123 ea410f7
Omit cuda/cudnn lib version checks when no visible gpu devices.
DickJC123 ab5112f
Move STATIC_ASSERT_... to resource.cc.
DickJC123 59cd7e0
Remove function names in cuda/cudnn version check impl.
DickJC123 9ec6097
Remove runtime cuda lib check- major.minor already needed for program…
DickJC123 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
/*! | ||
* Copyright (c) 2019 by Contributors | ||
* \file cuda_utils.cc | ||
* \brief CUDA debugging utilities. | ||
*/ | ||
|
||
#include <mxnet/base.h> | ||
#include "cuda_utils.h" | ||
|
||
#if MXNET_USE_CUDA == 1 | ||
|
||
namespace mxnet { | ||
namespace common { | ||
namespace cuda { | ||
|
||
// The oldest version of cuda used in upstream MXNet CI testing, both for unix and windows. | ||
// Users that have rebuilt MXNet against older versions will we advised with a warning to upgrade | ||
// their systems to match the CI level. Minimally, users should rerun the CI locally. | ||
#if defined(_MSC_VER) | ||
#define MXNET_CI_OLDEST_CUDA_VERSION 9020 | ||
#else | ||
#define MXNET_CI_OLDEST_CUDA_VERSION 10000 | ||
#endif | ||
|
||
// Dynamic init here will emit a warning if runtime and compile-time cuda lib versions mismatch. | ||
// Also if the user has recompiled their source to a version no longer tested by upstream CI. | ||
bool cuda_version_check_performed = []() { | ||
// Don't bother with checks if there are no GPUs visible (e.g. with CUDA_VISIBLE_DEVICES="") | ||
if (dmlc::GetEnv("MXNET_CUDA_VERSION_CHECKING", true) && Context::GetGPUCount() > 0) { | ||
// Not currently performing a runtime check of linked-against vs. compiled-against | ||
// cuda runtime library, as major.minor must match for libmxnet.so to even load, per: | ||
// https://docs.nvidia.com/deploy/cuda-compatibility/#binary-compatibility | ||
if (CUDA_VERSION < MXNET_CI_OLDEST_CUDA_VERSION) | ||
LOG(WARNING) << "Upgrade advisory: this mxnet has been built against cuda library version " | ||
<< CUDA_VERSION << ", which is older than the oldest version tested by CI (" | ||
<< MXNET_CI_OLDEST_CUDA_VERSION << "). " | ||
<< "Set MXNET_CUDA_VERSION_CHECKING=0 to quiet this warning."; | ||
} | ||
return true; | ||
}(); | ||
|
||
} // namespace cuda | ||
} // namespace common | ||
} // namespace mxnet | ||
|
||
#endif // MXNET_USE_CUDA | ||
|
||
#if MXNET_USE_CUDNN == 1 | ||
|
||
namespace mxnet { | ||
namespace common { | ||
namespace cudnn { | ||
|
||
// The oldest version of CUDNN used in upstream MXNet CI testing, both for unix and windows. | ||
// Users that have rebuilt MXNet against older versions will we advised with a warning to upgrade | ||
// their systems to match the CI level. Minimally, users should rerun the CI locally. | ||
#if defined(_MSC_VER) | ||
#define MXNET_CI_OLDEST_CUDNN_VERSION 7600 | ||
#else | ||
#define MXNET_CI_OLDEST_CUDNN_VERSION 7600 | ||
#endif | ||
|
||
// Dynamic init here will emit a warning if runtime and compile-time cudnn lib versions mismatch. | ||
// Also if the user has recompiled their source to a version no longer tested by upstream CI. | ||
bool cudnn_version_check_performed = []() { | ||
// Don't bother with checks if there are no GPUs visible (e.g. with CUDA_VISIBLE_DEVICES="") | ||
if (dmlc::GetEnv("MXNET_CUDNN_VERSION_CHECKING", true) && Context::GetGPUCount() > 0) { | ||
size_t linkedAgainstCudnnVersion = cudnnGetVersion(); | ||
if (linkedAgainstCudnnVersion != CUDNN_VERSION) | ||
LOG(WARNING) << "cuDNN library mismatch: linked-against version " << linkedAgainstCudnnVersion | ||
<< " != compiled-against version " << CUDNN_VERSION << ". " | ||
<< "Set MXNET_CUDNN_VERSION_CHECKING=0 to quiet this warning."; | ||
if (CUDNN_VERSION < MXNET_CI_OLDEST_CUDNN_VERSION) | ||
LOG(WARNING) << "Upgrade advisory: this mxnet has been built against cuDNN library version " | ||
<< CUDNN_VERSION << ", which is older than the oldest version tested by CI (" | ||
<< MXNET_CI_OLDEST_CUDNN_VERSION << "). " | ||
<< "Set MXNET_CUDNN_VERSION_CHECKING=0 to quiet this warning."; | ||
} | ||
return true; | ||
}(); | ||
|
||
} // namespace cudnn | ||
} // namespace common | ||
} // namespace mxnet | ||
|
||
#endif // MXNET_USE_CUDNN |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@DickJC123 we have detected an error when running a GPU compiled MXNet in a CPU machine, when building mxnet is loaded to generate the operator bindings. My colleague will fill a ticket about this. Would be great to have your guidance if the underlying cudaGetDeviceCount can run without driver, as the call is failing. Our thinking is that before we were not calling this cuda function on load time. I think a possible solution is to add a function that checks if GPUs are available if the GPU count can't be called without GPUs which is a bit puzzling.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vrakesh
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
filed a issue on the same, this is breaking our internal build flows, where our buildfarm does not have GPU enabled machines, the GPU builds are also done on CPU machines, with CUDA installed on them, for build purposes.