Skip to content

Commit 5e5cbce

Browse files
xuhdevfacebook-github-bot
authored andcommitted
remove tools/setup_helpers/cudnn.py (pytorch#25876)
Summary: FindCUDNN.cmake and cuda.cmake have done the detection. This commit deletes `tools/setup_helpers/cudnn.py` as it is no longer needed. Previously in pytorch#25482, one test failed because TensorRT detects cuDNN differently, and there may be situations we can find cuDNN but TensorRT cannot. This is fixed by passing our detection result down to TensorRT. Pull Request resolved: pytorch#25876 Differential Revision: D17346270 Pulled By: ezyang fbshipit-source-id: c1e7ad4a1cb20f964fe07a72906f2f002425d894
1 parent 9f3351d commit 5e5cbce

File tree

5 files changed

+12
-104
lines changed

5 files changed

+12
-104
lines changed

cmake/Dependencies.cmake

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1170,10 +1170,16 @@ if (CAFFE2_CMAKE_BUILDING_WITH_MAIN_REPO AND NOT INTERN_DISABLE_ONNX)
11701170
endif()
11711171

11721172
# --[ TensorRT integration with onnx-trt
1173+
function (add_onnx_tensorrt_subdir)
1174+
# We pass the paths we found to onnx tensorrt.
1175+
set(CUDNN_INCLUDE_DIR "${CUDNN_INCLUDE_PATH}")
1176+
set(CUDNN_LIBRARY "${CUDNN_LIBRARY_PATH}")
1177+
add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/../third_party/onnx-tensorrt EXCLUDE_FROM_ALL)
1178+
endfunction()
11731179
if (CAFFE2_CMAKE_BUILDING_WITH_MAIN_REPO)
11741180
if (USE_TENSORRT)
11751181
set(CMAKE_CUDA_COMPILER ${CUDA_NVCC_EXECUTABLE})
1176-
add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/../third_party/onnx-tensorrt EXCLUDE_FROM_ALL)
1182+
add_onnx_tensorrt_subdir()
11771183
include_directories("${CMAKE_CURRENT_LIST_DIR}/../third_party/onnx-tensorrt")
11781184
caffe2_interface_library(nvonnxparser_static onnx_trt_library)
11791185
list(APPEND Caffe2_DEPENDENCY_WHOLE_LINK_LIBS onnx_trt_library)

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,6 @@
185185
check_env_flag, build_type)
186186
from tools.setup_helpers.cmake import CMake
187187
from tools.setup_helpers.cuda import CUDA_HOME, CUDA_VERSION
188-
from tools.setup_helpers.cudnn import CUDNN_LIBRARY, CUDNN_INCLUDE_DIR
189188

190189
try:
191190
FileNotFoundError
@@ -377,7 +376,8 @@ def run(self):
377376
else:
378377
report('-- NumPy not found')
379378
if cmake_cache_vars['USE_CUDNN']:
380-
report('-- Detected cuDNN at ' + CUDNN_LIBRARY + ', ' + CUDNN_INCLUDE_DIR)
379+
report('-- Detected cuDNN at ' +
380+
cmake_cache_vars['CUDNN_LIBRARY'] + ', ' + cmake_cache_vars['CUDNN_INCLUDE_DIR'])
381381
else:
382382
report('-- Not using cuDNN')
383383
if cmake_cache_vars['USE_CUDA']:

tools/build_pytorch_libs.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
from .setup_helpers.env import IS_64BIT, IS_WINDOWS, check_negative_env_flag
77
from .setup_helpers.cmake import USE_NINJA
88
from .setup_helpers.cuda import USE_CUDA, CUDA_HOME
9-
from .setup_helpers.cudnn import CUDNN_INCLUDE_DIR, CUDNN_LIBRARY, USE_CUDNN
109

1110

1211
def _overlay_windows_vcvars(env):
@@ -34,9 +33,6 @@ def _create_build_env():
3433
# you should NEVER add something to this list. It is bad practice to
3534
# have cmake read the environment
3635
my_env = os.environ.copy()
37-
if USE_CUDNN:
38-
my_env['CUDNN_LIBRARY'] = CUDNN_LIBRARY
39-
my_env['CUDNN_INCLUDE_DIR'] = CUDNN_INCLUDE_DIR
4036
if USE_CUDA:
4137
my_env['CUDA_BIN_PATH'] = CUDA_HOME
4238

tools/setup_helpers/cmake.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,7 @@ def generate(self, version, cmake_python_library, build_python, build_test, my_e
215215
# adding a new build option to this block: Consider making these two names identical and adding this option
216216
# in the block below.
217217
'_GLIBCXX_USE_CXX11_ABI': 'GLIBCXX_USE_CXX11_ABI',
218+
'CUDNN_LIB_DIR': 'CUDNN_LIBRARY',
218219
'USE_CUDA_STATIC_LINK': 'CAFFE2_STATIC_LINK_CUDA',
219220
'USE_GLOO_IBVERBS': 'USE_IBVERBS' # Backward compatibility. Will be removed in the future.
220221
}
@@ -226,6 +227,8 @@ def generate(self, version, cmake_python_library, build_python, build_test, my_e
226227
('BLAS',
227228
'BUILDING_WITH_TORCH_LIBS',
228229
'CUDA_NVCC_EXECUTABLE',
230+
'CUDNN_LIBRARY',
231+
'CUDNN_INCLUDE_DIR',
229232
'EXPERIMENTAL_SINGLE_THREAD_POOL',
230233
'INSTALL_TEST',
231234
'MKL_THREADING',

tools/setup_helpers/cudnn.py

Lines changed: 0 additions & 97 deletions
This file was deleted.

0 commit comments

Comments
 (0)