"...git@developer.sourcefind.cn:renzhc/diffusers_dcu.git" did not exist on "8e8b046d2476309c2ff8158703b6f7a23b68fd77"
Unverified Commit adea4e60 authored by Adrià Arrufat's avatar Adrià Arrufat Committed by GitHub
Browse files

Allow setting custom cuda compute capabilities (#2431)

* add more cuda capabilities

* Allow setting custom cuda capabilities

* improve default behavior

* rename to compute capabilities
parent 45069796
...@@ -172,6 +172,8 @@ if (NOT TARGET dlib) ...@@ -172,6 +172,8 @@ if (NOT TARGET dlib)
"Disable this if you don't want to use a LAPACK library" ) "Disable this if you don't want to use a LAPACK library" )
set (DLIB_USE_CUDA_STR set (DLIB_USE_CUDA_STR
"Disable this if you don't want to use NVIDIA CUDA" ) "Disable this if you don't want to use NVIDIA CUDA" )
set (DLIB_USE_CUDA_COMPUTE_CAPABILITIES_STR
"Set this to a comma-separated list of CUDA compute capabilities" )
set (DLIB_USE_MKL_SEQUENTIAL_STR set (DLIB_USE_MKL_SEQUENTIAL_STR
"Enable this if you have MKL installed and want to use the sequential version instead of the multi-core version." ) "Enable this if you have MKL installed and want to use the sequential version instead of the multi-core version." )
set (DLIB_USE_MKL_WITH_TBB_STR set (DLIB_USE_MKL_WITH_TBB_STR
...@@ -246,6 +248,7 @@ if (NOT TARGET dlib) ...@@ -246,6 +248,7 @@ if (NOT TARGET dlib)
option(DLIB_USE_BLAS ${DLIB_USE_BLAS_STR} ON) option(DLIB_USE_BLAS ${DLIB_USE_BLAS_STR} ON)
option(DLIB_USE_LAPACK ${DLIB_USE_LAPACK_STR} ON) option(DLIB_USE_LAPACK ${DLIB_USE_LAPACK_STR} ON)
option(DLIB_USE_CUDA ${DLIB_USE_CUDA_STR} ON) option(DLIB_USE_CUDA ${DLIB_USE_CUDA_STR} ON)
set(DLIB_USE_CUDA_COMPUTE_CAPABILITIES 50 CACHE STRING ${DLIB_USE_CUDA_COMPUTE_CAPABILITIES_STR})
option(DLIB_PNG_SUPPORT ${DLIB_PNG_SUPPORT_STR} ON) option(DLIB_PNG_SUPPORT ${DLIB_PNG_SUPPORT_STR} ON)
option(DLIB_GIF_SUPPORT ${DLIB_GIF_SUPPORT_STR} ON) option(DLIB_GIF_SUPPORT ${DLIB_GIF_SUPPORT_STR} ON)
#option(DLIB_USE_FFTW ${DLIB_USE_FFTW_STR} ON) #option(DLIB_USE_FFTW ${DLIB_USE_FFTW_STR} ON)
...@@ -642,10 +645,13 @@ if (NOT TARGET dlib) ...@@ -642,10 +645,13 @@ if (NOT TARGET dlib)
endif() endif()
set(CUDA_HOST_COMPILATION_CPP ON) set(CUDA_HOST_COMPILATION_CPP ON)
string(REPLACE "," ";" DLIB_CUDA_COMPUTE_CAPABILITIES ${DLIB_USE_CUDA_COMPUTE_CAPABILITIES})
foreach(CAP ${DLIB_CUDA_COMPUTE_CAPABILITIES})
list(APPEND CUDA_NVCC_FLAGS "-gencode arch=compute_${CAP},code=[sm_${CAP},compute_${CAP}]")
endforeach()
# Note that we add __STRICT_ANSI__ to avoid freaking out nvcc with gcc specific # Note that we add __STRICT_ANSI__ to avoid freaking out nvcc with gcc specific
# magic in the standard C++ header files (since nvcc uses gcc headers on # magic in the standard C++ header files (since nvcc uses gcc headers on linux).
# linux). list(APPEND CUDA_NVCC_FLAGS "-D__STRICT_ANSI__;-D_MWAITXINTRIN_H_INCLUDED;-D_FORCE_INLINES;${FLAGS_FOR_NVCC}")
list(APPEND CUDA_NVCC_FLAGS "-arch=sm_50;-D__STRICT_ANSI__;-D_MWAITXINTRIN_H_INCLUDED;-D_FORCE_INLINES;${FLAGS_FOR_NVCC}")
list(APPEND CUDA_NVCC_FLAGS ${active_preprocessor_switches}) list(APPEND CUDA_NVCC_FLAGS ${active_preprocessor_switches})
if (NOT DLIB_IN_PROJECT_BUILD) if (NOT DLIB_IN_PROJECT_BUILD)
LIST(APPEND CUDA_NVCC_FLAGS -DDLIB__CMAKE_GENERATED_A_CONFIG_H_FILE) LIST(APPEND CUDA_NVCC_FLAGS -DDLIB__CMAKE_GENERATED_A_CONFIG_H_FILE)
...@@ -773,7 +779,7 @@ if (NOT TARGET dlib) ...@@ -773,7 +779,7 @@ if (NOT TARGET dlib)
endif() endif()
include_directories(${cudnn_include}) include_directories(${cudnn_include})
message(STATUS "Enabling CUDA support for dlib. DLIB WILL USE CUDA") message(STATUS "Enabling CUDA support for dlib. DLIB WILL USE CUDA, compute capabilities: ${DLIB_CUDA_COMPUTE_CAPABILITIES}")
else() else()
set(DLIB_USE_CUDA OFF CACHE STRING ${DLIB_USE_BLAS_STR} FORCE ) set(DLIB_USE_CUDA OFF CACHE STRING ${DLIB_USE_BLAS_STR} FORCE )
toggle_preprocessor_switch(DLIB_USE_CUDA) toggle_preprocessor_switch(DLIB_USE_CUDA)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment