From 6a528007a6f025c4a0fae2be4e4a964f219a8d3f Mon Sep 17 00:00:00 2001 From: Thomas Viehmann Date: Sun, 10 Feb 2019 13:57:57 -0800 Subject: [PATCH] find libnvToolsExt instead of using only hardcoded path (#16714) Summary: This changes the libnvToolsExt dependency to go through CMake find_library. I have a machine where cuda libs, and libnvToolsExt in particular, are in the "usual library locations". It would be neat if we could find libnvToolsExt and use the path currently hardcoded as default. Pull Request resolved: https://github.com/pytorch/pytorch/pull/16714 Differential Revision: D14020315 Pulled By: ezyang fbshipit-source-id: 00be27be10b1863ca92fd585f273d50bded850f8 --- cmake/TorchConfig.cmake.in | 3 ++- torch/CMakeLists.txt | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/cmake/TorchConfig.cmake.in b/cmake/TorchConfig.cmake.in index fc643ba..7329e5c 100644 --- a/cmake/TorchConfig.cmake.in +++ b/cmake/TorchConfig.cmake.in @@ -59,10 +59,11 @@ if (@USE_CUDA@) ${CUDA_TOOLKIT_ROOT_DIR}/lib/libnvToolsExt.dylib ${CUDA_LIBRARIES}) else() + find_library(LIBNVTOOLSEXT libnvToolsExt.so PATHS ${CUDA_TOOLKIT_ROOT_DIR}/lib64/) set(TORCH_CUDA_LIBRARIES ${CUDA_CUDA_LIB} ${CUDA_NVRTC_LIB} - ${CUDA_TOOLKIT_ROOT_DIR}/lib64/libnvToolsExt.so + ${LIBNVTOOLSEXT} ${CUDA_LIBRARIES}) endif() list(APPEND TORCH_LIBRARIES ${TORCH_CUDA_LIBRARIES}) diff --git a/torch/CMakeLists.txt b/torch/CMakeLists.txt index 6884aef..7be2a60 100644 --- a/torch/CMakeLists.txt +++ b/torch/CMakeLists.txt @@ -353,8 +353,9 @@ if(USE_CUDA) ${CUDA_LIBRARIES}) set_target_properties(torch PROPERTIES LINK_FLAGS "-undefined dynamic_lookup") else() + find_library(LIBNVTOOLSEXT libnvToolsExt.so PATHS ${CUDA_TOOLKIT_ROOT_DIR}/lib64/) set(TORCH_CUDA_LIBRARIES - ${CUDA_TOOLKIT_ROOT_DIR}/lib64/libnvToolsExt.so + ${LIBNVTOOLSEXT} ${CUDA_LIBRARIES}) endif() @@ -622,7 +623,8 @@ if (BUILD_PYTHON) elseif(APPLE) list(APPEND TORCH_PYTHON_LINK_LIBRARIES ${CUDA_TOOLKIT_ROOT_DIR}/lib/libnvToolsExt.dylib) else() - list(APPEND TORCH_PYTHON_LINK_LIBRARIES ${CUDA_TOOLKIT_ROOT_DIR}/lib64/libnvToolsExt.so) + find_library(LIBNVTOOLSEXT libnvToolsExt.so PATHS ${CUDA_TOOLKIT_ROOT_DIR}/lib64/) + list(APPEND TORCH_PYTHON_LINK_LIBRARIES ${LIBNVTOOLSEXT}) endif() endif() -- 2.7.4