leezu commented on a change in pull request #17031: Use CMake standard library
to handle CUDA
URL: https://github.com/apache/incubator-mxnet/pull/17031#discussion_r355876742
##########
File path: CMakeLists.txt
##########
@@ -620,61 +594,17 @@ if(MSVC)
endif()
if(USE_CUDA)
- if(FIRST_CUDA)
- mshadow_select_nvcc_arch_flags(NVCC_FLAGS_ARCH)
- string(REPLACE ";" " " NVCC_FLAGS_ARCH "${NVCC_FLAGS_ARCH}")
- set(CMAKE_CUDA_FLAGS "${NVCC_FLAGS_ARCH}")
- list(APPEND mxnet_LINKER_LIBS cublas cufft cusolver curand)
- if(ENABLE_CUDA_RTC)
- list(APPEND mxnet_LINKER_LIBS nvrtc cuda)
- add_definitions(-DMXNET_ENABLE_CUDA_RTC=1)
- endif()
- list(APPEND SOURCE ${CUDA})
- add_definitions(-DMXNET_USE_CUDA=1)
- link_directories(${CUDA_TOOLKIT_ROOT_DIR}/lib64)
- else()
- list(APPEND CUDA_INCLUDE_DIRS ${INCLUDE_DIRECTORIES})
- # define preprocessor macro so that we will not include the generated
forcelink header
- if(ENABLE_CUDA_RTC)
- add_definitions(-DMXNET_ENABLE_CUDA_RTC=1)
- endif()
- # Create '.cmake' files for cuda compiles given definitions added thus far
- mshadow_cuda_compile(cuda_objs ${CUDA})
- if(MSVC)
- if(ENABLE_CUDA_RTC)
- FIND_LIBRARY(CUDA_nvrtc_LIBRARY nvrtc
"${CUDA_TOOLKIT_ROOT_DIR}/lib/x64" "${CUDA_TOOLKIT_ROOT_DIR}/lib/win32")
- list(APPEND mxnet_LINKER_LIBS ${CUDA_nvrtc_LIBRARY})
- set(CUDA_cuda_LIBRARY "${CUDA_nvrtc_LIBRARY}/../cuda.lib")
- list(APPEND mxnet_LINKER_LIBS ${CUDA_cuda_LIBRARY})
- endif()
- FIND_LIBRARY(CUDA_cufft_LIBRARY nvrtc
"${CUDA_TOOLKIT_ROOT_DIR}/lib/x64" "${CUDA_TOOLKIT_ROOT_DIR}/lib/win32")
- list(APPEND mxnet_LINKER_LIBS "${CUDA_cufft_LIBRARY}/../cufft.lib") #
For fft operator
- FIND_LIBRARY(CUDA_cusolver_LIBRARY nvrtc
"${CUDA_TOOLKIT_ROOT_DIR}/lib/x64" "${CUDA_TOOLKIT_ROOT_DIR}/lib/win32")
- list(APPEND mxnet_LINKER_LIBS
"${CUDA_cusolver_LIBRARY}/../cusolver.lib") # For cusolver
- link_directories(${CUDA_TOOLKIT_ROOT_DIR}/lib/win32)
- link_directories(${CUDA_TOOLKIT_ROOT_DIR}/lib/x64)
- else(MSVC)
- list(APPEND mxnet_LINKER_LIBS cufft cusolver)
- if(ENABLE_CUDA_RTC)
- list(APPEND mxnet_LINKER_LIBS nvrtc cuda)
- endif()
- link_directories("${CUDA_TOOLKIT_ROOT_DIR}/lib64")
- endif()
- list(APPEND SOURCE ${cuda_objs} ${CUDA})
- add_definitions(-DMXNET_USE_CUDA=1)
- if(CUDA_LIBRARY_PATH)
- if(IS_CONTAINER_BUILD)
- # In case of building on a production-like build container which may
not have Cuda installed
- if(NOT CMAKE_SYSTEM_HAS_CUDA)
- # Assuming building in a container that doesn't have CUDA
installed (ie CPU-only build machine)
- # so use the stub cuda driver shared library
- if(EXISTS ${CUDA_LIBRARY_PATH}/stubs/libcuda.so)
- link_directories(${CUDA_LIBRARY_PATH}/stubs)
- endif()
- endif()
- endif()
- endif()
- endif()
+ CUDA_SELECT_NVCC_ARCH_FLAGS(NVCC_FLAGS_ARCH Auto)
Review comment:
See https://gitlab.kitware.com/cmake/cmake/issues/19199
`CUDA_SELECT_NVCC_ARCH_FLAGS` is currently part of a deprecated module, but
the command itself is going to stay around. They'll just move it to another
module.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services