Skip to content

Commit

Permalink
[cmake+cuda] improve friendliness of architecture selection
Browse files Browse the repository at this point in the history
  • Loading branch information
cenit committed May 20, 2019
1 parent 5e242df commit 578d1c0
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,20 +38,22 @@ set(ENABLE_CUDA "FALSE" CACHE BOOL "Enable CUDA support")
set(ENABLE_CUDNN "FALSE" CACHE BOOL "Enable CUDNN")
set(ENABLE_CUDNN_HALF "FALSE" CACHE BOOL "Enable CUDNN Half precision")

if(${CMAKE_VERSION} VERSION_LESS "3.8.0")
if(${CMAKE_VERSION} VERSION_LESS "3.9.0")
set(ENABLE_CUDA "FALSE" CACHE BOOL "Enable CUDA support" FORCE)
message(WARNING "To build with CUDA support you need CMake 3.8.0+")
message(WARNING "To build with CUDA support you need CMake 3.9.0+")
else()
include(CheckLanguage)
check_language(CUDA)
if(CMAKE_CUDA_COMPILER)
set(CUDA_ARCHITECTURES "Auto" CACHE STRING "\"Auto\" detects local machine GPU compute arch at runtime, \"Common\" and \"All\" cover common and entire subsets of architectures, \"Names\" is a list of architectures to enable by name, \"Numbers\" is a list of compute capabilities (version number) to enable")
set_property(CACHE CUDA_ARCHITECTURES PROPERTY STRINGS "Auto" "Common" "All" "Kepler Maxwell Kepler+Tegra Maxwell+Tegra Pascal" "3.0 7.5")
enable_language(CUDA)
find_package(CUDA REQUIRED)
if(CUDA_VERSION VERSION_LESS "9.0")
message(STATUS "Unsupported CUDA version, please upgrade to CUDA 9+. Disabling CUDA support")
else()
set(ENABLE_CUDA "TRUE" CACHE BOOL "Enable CUDA support" FORCE)
cuda_select_nvcc_arch_flags(CUDA_ARCH_FLAGS "Auto")
cuda_select_nvcc_arch_flags(CUDA_ARCH_FLAGS ${CUDA_ARCHITECTURES})
message(STATUS "Building with CUDA flags: " "${CUDA_ARCH_FLAGS}")
if ("arch=compute_75,code=sm_75" IN_LIST CUDA_ARCH_FLAGS)
set(ENABLE_CUDNN_HALF "TRUE" CACHE BOOL "Enable CUDNN Half precision" FORCE)
Expand Down

0 comments on commit 578d1c0

Please sign in to comment.