Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/intern
diff options
context:
space:
mode:
authorPatrick Mours <pmours@nvidia.com>2020-10-13 13:33:34 +0300
committerBrecht Van Lommel <brecht@blender.org>2021-02-08 17:50:03 +0300
commitc661515090b189061c4388a335573ac3d5745925 (patch)
tree5f81489cb4906b5d3fa0252c37c897cb3bc36383 /intern
parent8d02177ab079eec518685d60f5e0d9e146de97cb (diff)
Cycles: Add CUDA 11 build support
With this patch the build system checks whether the "CUDA10_NVCC_EXECUTABLE" CMake variable is set and if so will use that to build sm_30 kernels. Similarily for sm_8x kernels it checks "CUDA11_NVCC_EXECUTABLE". All other kernels are built using the default CUDA toolkit. This makes it possible to use either the CUDA 10 or CUDA 11 toolkit by default and only selectively use the other for the kernels where its a hard requirement. Reviewed By: brecht Differential Revision: https://developer.blender.org/D9179
Diffstat (limited to 'intern')
-rw-r--r--intern/cycles/CMakeLists.txt2
-rw-r--r--intern/cycles/kernel/CMakeLists.txt43
2 files changed, 36 insertions, 9 deletions
diff --git a/intern/cycles/CMakeLists.txt b/intern/cycles/CMakeLists.txt
index 121c8bdad6e..762d37996cf 100644
--- a/intern/cycles/CMakeLists.txt
+++ b/intern/cycles/CMakeLists.txt
@@ -313,7 +313,7 @@ if(WITH_CYCLES_CUDA_BINARIES AND (NOT WITH_CYCLES_CUBIN_COMPILER))
set(MAX_MSVC 1910)
elseif(${CUDA_VERSION} EQUAL "9.1")
set(MAX_MSVC 1911)
- elseif(${CUDA_VERSION} LESS "11.0")
+ elseif(${CUDA_VERSION} VERSION_GREATER_EQUAL 10.0)
set(MAX_MSVC 1999)
endif()
if(NOT MSVC_VERSION LESS ${MAX_MSVC} OR CMAKE_C_COMPILER_ID MATCHES "Clang")
diff --git a/intern/cycles/kernel/CMakeLists.txt b/intern/cycles/kernel/CMakeLists.txt
index 5e408c55328..d2fbff29776 100644
--- a/intern/cycles/kernel/CMakeLists.txt
+++ b/intern/cycles/kernel/CMakeLists.txt
@@ -375,11 +375,11 @@ if(WITH_CYCLES_CUDA_BINARIES)
set(CUDA_VERSION "${CUDA_VERSION_MAJOR}${CUDA_VERSION_MINOR}")
# warn for other versions
- if((CUDA_VERSION MATCHES "101") OR (CUDA_VERSION MATCHES "102"))
+ if((CUDA_VERSION MATCHES "101") OR (CUDA_VERSION MATCHES "102") OR (CUDA_VERSION MATCHES "111"))
else()
message(WARNING
"CUDA version ${CUDA_VERSION_MAJOR}.${CUDA_VERSION_MINOR} detected, "
- "build may succeed but only CUDA 10.1 and 10.2 are officially supported")
+ "build may succeed but only CUDA 10.1, 10.2 and 11.1 are officially supported")
endif()
# build for each arch
@@ -445,10 +445,10 @@ if(WITH_CYCLES_CUDA_BINARIES)
# cycles_cubin_cc since the env variable is read before main()
if(APPLE)
set(CUBIN_CC_ENV ${CMAKE_COMMAND}
- -E env DYLD_LIBRARY_PATH="${CUDA_TOOLKIT_ROOT_DIR}/lib")
+ -E env DYLD_LIBRARY_PATH="${cuda_toolkit_root_dir}/lib")
elseif(UNIX)
set(CUBIN_CC_ENV ${CMAKE_COMMAND}
- -E env LD_LIBRARY_PATH="${CUDA_TOOLKIT_ROOT_DIR}/lib64")
+ -E env LD_LIBRARY_PATH="${cuda_toolkit_root_dir}/lib64")
endif()
add_custom_command(
@@ -459,12 +459,12 @@ if(WITH_CYCLES_CUDA_BINARIES)
-i ${CMAKE_CURRENT_SOURCE_DIR}${cuda_kernel_src}
${cuda_flags}
-v
- -cuda-toolkit-dir "${CUDA_TOOLKIT_ROOT_DIR}"
+ -cuda-toolkit-dir "${cuda_toolkit_root_dir}"
DEPENDS ${kernel_sources} cycles_cubin_cc)
else()
add_custom_command(
OUTPUT ${cuda_file}
- COMMAND ${CUDA_NVCC_EXECUTABLE}
+ COMMAND ${cuda_nvcc_executable}
-arch=${arch}
${CUDA_NVCC_FLAGS}
--${format}
@@ -481,11 +481,35 @@ if(WITH_CYCLES_CUDA_BINARIES)
set(prev_arch "none")
foreach(arch ${CYCLES_CUDA_BINARIES_ARCH})
- if(${arch} MATCHES "sm_2.")
+ if(${arch} MATCHES ".*_2.")
message(STATUS "CUDA binaries for ${arch} are no longer supported, skipped.")
- elseif(${arch} MATCHES "sm_7." AND ${CUDA_VERSION} LESS 100)
+ elseif(${arch} MATCHES ".*_30")
+ if(DEFINED CUDA10_NVCC_EXECUTABLE)
+ set(cuda_nvcc_executable ${CUDA10_NVCC_EXECUTABLE})
+ set(cuda_toolkit_root_dir ${CUDA10_TOOLKIT_ROOT_DIR})
+ elseif(${CUDA_VERSION} LESS 110) # Support for sm_30 was removed in CUDA 11
+ set(cuda_nvcc_executable ${CUDA_NVCC_EXECUTABLE})
+ set(cuda_toolkit_root_dir ${CUDA_TOOLKIT_ROOT_DIR})
+ else()
+ message(STATUS "CUDA binaries for ${arch} require CUDA 10 or earlier, skipped.")
+ endif()
+ elseif(${arch} MATCHES ".*_7." AND ${CUDA_VERSION} LESS 100)
message(STATUS "CUDA binaries for ${arch} require CUDA 10.0+, skipped.")
+ elseif(${arch} MATCHES ".*_8.")
+ if(DEFINED CUDA11_NVCC_EXECUTABLE)
+ set(cuda_nvcc_executable ${CUDA11_NVCC_EXECUTABLE})
+ set(cuda_toolkit_root_dir ${CUDA11_TOOLKIT_ROOT_DIR})
+ elseif(${CUDA_VERSION} GREATER_EQUAL 111) # Support for sm_86 was introduced in CUDA 11
+ set(cuda_nvcc_executable ${CUDA_NVCC_EXECUTABLE})
+ set(cuda_toolkit_root_dir ${CUDA_TOOLKIT_ROOT_DIR})
+ else()
+ message(STATUS "CUDA binaries for ${arch} require CUDA 11.1+, skipped.")
+ endif()
else()
+ set(cuda_nvcc_executable ${CUDA_NVCC_EXECUTABLE})
+ set(cuda_toolkit_root_dir ${CUDA_TOOLKIT_ROOT_DIR})
+ endif()
+ if(DEFINED cuda_nvcc_executable AND DEFINED cuda_toolkit_root_dir)
# Compile regular kernel
CYCLES_CUDA_KERNEL_ADD(${arch} ${prev_arch} filter "" "${cuda_filter_sources}" FALSE)
CYCLES_CUDA_KERNEL_ADD(${arch} ${prev_arch} kernel "" "${cuda_sources}" FALSE)
@@ -498,6 +522,9 @@ if(WITH_CYCLES_CUDA_BINARIES)
if(WITH_CYCLES_CUDA_BUILD_SERIAL)
set(prev_arch ${arch})
endif()
+
+ unset(cuda_nvcc_executable)
+ unset(cuda_toolkit_root_dir)
endif()
endforeach()