From dbbb2fc9e50b26f500c0b2c238d88efd7e625230 Mon Sep 17 00:00:00 2001 From: Hong Xu Date: Fri, 1 Nov 2019 11:16:17 -0700 Subject: [PATCH] Remove the linkage to CUDA libraries when ROCM is used. (#29009) Summary: Currently when ROCM is used, CUDA libraries are still linked. There has been no error because USE_CUDA is set to OFF upon a preliminary check in tools/setup_helper/cuda.py, and no CUDA variable is set. Hence, these lines can pass simply because those variables are always undefined, and thus expanded to empty strings. But this cannot be safely relied on, and is causing https://github.com/pytorch/pytorch/issues/28617 to fail. Pull Request resolved: https://github.com/pytorch/pytorch/pull/29009 Differential Revision: D18273472 Pulled By: ezyang fbshipit-source-id: b8b6580e8a44d874ac678ed9073412d4d2e393ee --- caffe2/CMakeLists.txt | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/caffe2/CMakeLists.txt b/caffe2/CMakeLists.txt index 032902e78d4..10ff6772f0a 100644 --- a/caffe2/CMakeLists.txt +++ b/caffe2/CMakeLists.txt @@ -542,9 +542,7 @@ if (NOT INTERN_BUILD_MOBILE OR NOT BUILD_CAFFE2_MOBILE) # caffe2_nvrtc's stubs to driver APIs are useful for HIP. # See NOTE [ ATen NVRTC Stub and HIP ] add_library(caffe2_nvrtc SHARED ${ATen_NVRTC_STUB_SRCS}) - target_link_libraries(caffe2_nvrtc ${CUDA_NVRTC} ${PYTORCH_HIP_HCC_LIBRARIES} ${ROCM_HIPRTC_LIB}) - target_link_libraries(caffe2_nvrtc ${CUDA_NVRTC} ${CUDA_CUDA_LIB} ${CUDA_NVRTC_LIB}) - target_include_directories(caffe2_nvrtc PRIVATE ${CUDA_INCLUDE_DIRS}) + target_link_libraries(caffe2_nvrtc ${PYTORCH_HIP_HCC_LIBRARIES} ${ROCM_HIPRTC_LIB}) target_compile_definitions(caffe2_nvrtc PRIVATE USE_ROCM __HIP_PLATFORM_HCC__) install(TARGETS caffe2_nvrtc DESTINATION "${TORCH_INSTALL_LIB_DIR}") endif()