Skip to content

Commit a1fa614

Browse files
OutisLiCopilotpre-commit-ci[bot]
authored andcommitted
feat:support CUDA 13.0+ (deepmodeling#5017)
auto detect cuda version, if >= 13.0, set c++17 fix issue deepmodeling#5016 <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Chores** * Build now detects the installed CUDA Toolkit version and adjusts configuration accordingly. * Automatically selects C++17 for host/device compilation when CUDA Toolkit 13.0+ is present. * Emits clearer build status messages showing detected CUDA version and chosen C++ standard. * Maintains existing version checks and does not change runtime behavior or public APIs. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Signed-off-by: OutisLi <137472077+OutisLi@users.noreply.github.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 585af77 commit a1fa614

2 files changed

Lines changed: 17 additions & 2 deletions

File tree

source/CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,12 @@ set(DP_VARIANT "cpu")
246246
if(USE_CUDA_TOOLKIT)
247247
cmake_minimum_required(VERSION 3.25.2)
248248
find_package(CUDAToolkit REQUIRED)
249+
# CUDA 13.0+ requires C++17
250+
if(CUDAToolkit_VERSION VERSION_GREATER_EQUAL "13.0")
251+
set_if_higher(CMAKE_CXX_STANDARD 17)
252+
message(
253+
STATUS "CUDA ${CUDAToolkit_VERSION} detected, setting C++ standard to 17")
254+
endif()
249255
if(NOT DEFINED CMAKE_CUDA_COMPILER)
250256
set(CMAKE_CUDA_COMPILER ${CUDAToolkit_NVCC_EXECUTABLE})
251257
endif()

source/lib/src/gpu/CMakeLists.txt

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ if(USE_CUDA_TOOLKIT)
2626

2727
# cub has been included in CUDA Toolkit 11, we do not need to include it any
2828
# more see https://github.com/NVIDIA/cub
29-
if(${CMAKE_CUDA_COMPILER_VERSION} VERSION_LESS "11")
29+
if(CMAKE_CUDA_COMPILER_VERSION VERSION_LESS "11")
3030
include(FetchContent)
3131
FetchContent_Declare(
3232
cub_download
@@ -39,10 +39,19 @@ if(USE_CUDA_TOOLKIT)
3939
endif()
4040
include_directories(${CUB_SOURCE_ROOT})
4141
endif()
42-
if(${CMAKE_CUDA_COMPILER_VERSION} VERSION_LESS "9")
42+
if(CMAKE_CUDA_COMPILER_VERSION VERSION_LESS "9")
4343
message(FATAL_ERROR "CUDA version must be >= 9.0")
4444
endif()
4545

46+
# CUDA 13.0+ requires C++17
47+
if(CMAKE_CUDA_COMPILER_VERSION VERSION_GREATER_EQUAL "13.0")
48+
set(CMAKE_CUDA_STANDARD 17)
49+
message(
50+
STATUS
51+
"CUDA ${CMAKE_CUDA_COMPILER_VERSION} detected, setting C++ standard to 17"
52+
)
53+
endif()
54+
4655
message(STATUS "NVCC version is " ${CMAKE_CUDA_COMPILER_VERSION})
4756

4857
# arch will be configured by CMAKE_CUDA_ARCHITECTURES

0 commit comments

Comments
 (0)