-
Notifications
You must be signed in to change notification settings - Fork 575
feat:support CUDA 13.0+ #5017
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat:support CUDA 13.0+ #5017
Conversation
Note Other AI code review bot(s) detectedCodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review. 📝 WalkthroughWalkthroughAdds CUDA 13.0+ detection to two CMake files: the top-level now gates C++17 upgrade on Changes
Sequence Diagram(s)sequenceDiagram
participant CMake as CMake (invocation)
participant Top as source/CMakeLists.txt
participant GPU as source/lib/src/gpu/CMakeLists.txt
rect rgb(250,250,255)
Note over CMake,Top: Early project configuration
end
CMake->>Top: evaluate USE_CUDA_TOOLKIT?
alt USE_CUDA_TOOLKIT = ON
Top->>Top: read CUDAToolkit_VERSION
alt CUDAToolkit_VERSION >= 13.0
Top->>CMake: set_if_higher(CMAKE_CXX_STANDARD, 17)
Top->>CMake: status("Detected CUDA toolkit vX.Y.Z -> using C++17")
else
Top->>CMake: continue existing CUDA handling
end
else
Top->>CMake: skip CUDA-toolkit-specific path
end
CMake->>GPU: later evaluate GPU CMake
GPU->>GPU: read CMAKE_CUDA_COMPILER_VERSION
alt version >= 13.0
GPU->>CMake: set(CMAKE_CUDA_STANDARD 17)
GPU->>CMake: status("Detected CUDA toolkit vX.Y.Z -> CUDA C++17")
else
GPU->>CMake: existing NVCC/version reporting and 9.0 check
end
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related issues
Possibly related PRs
Suggested reviewers
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds support for CUDA 13.0+ by automatically detecting the CUDA version and setting the C++ standard to 17 when CUDA 13.0 or higher is detected, as required by newer CUDA versions.
Key changes:
- Auto-detection of CUDA version in two CMake files
- Conditional setting of C++17 standard for CUDA 13.0+
- Status messages to inform users of the standard being set
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
File | Description |
---|---|
source/lib/src/gpu/CMakeLists.txt | Adds CUDA version check and sets CMAKE_CUDA_STANDARD to 17 for CUDA 13.0+ |
source/CMakeLists.txt | Adds CUDA version check and sets CMAKE_CXX_STANDARD to 17 for CUDA 13.0+ |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
source/CMakeLists.txt
(1 hunks)source/lib/src/gpu/CMakeLists.txt
(1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
source/CMakeLists.txt
📄 CodeRabbit inference engine (AGENTS.md)
Keep C++ build configuration up to date in CMake when changing C++ components (library, ops, APIs)
Files:
source/CMakeLists.txt
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (29)
- GitHub Check: Test Python (5, 3.9)
- GitHub Check: Test Python (4, 3.9)
- GitHub Check: Test Python (6, 3.9)
- GitHub Check: Test Python (6, 3.12)
- GitHub Check: Test Python (5, 3.12)
- GitHub Check: Test Python (3, 3.12)
- GitHub Check: Test Python (3, 3.9)
- GitHub Check: Test Python (4, 3.12)
- GitHub Check: Test Python (1, 3.12)
- GitHub Check: Test Python (2, 3.12)
- GitHub Check: Test Python (2, 3.9)
- GitHub Check: Test Python (1, 3.9)
- GitHub Check: Build C++ (clang, clang)
- GitHub Check: Build wheels for cp311-win_amd64
- GitHub Check: Build wheels for cp311-manylinux_x86_64
- GitHub Check: Build C++ (cuda120, cuda)
- GitHub Check: Build wheels for cp311-macosx_x86_64
- GitHub Check: Build wheels for cp311-manylinux_x86_64
- GitHub Check: Build C++ (rocm, rocm)
- GitHub Check: Build wheels for cp310-manylinux_aarch64
- GitHub Check: Build wheels for cp311-macosx_arm64
- GitHub Check: Build C++ (cuda, cuda)
- GitHub Check: Build C++ (cpu, cpu)
- GitHub Check: Analyze (python)
- GitHub Check: Analyze (c-cpp)
- GitHub Check: Build C library (2.18, libdeepmd_c.tar.gz)
- GitHub Check: Build C library (2.14, >=2.5.0,<2.15, libdeepmd_c_cu11.tar.gz)
- GitHub Check: Test C++ (true)
- GitHub Check: Test C++ (false)
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## devel #5017 +/- ##
==========================================
- Coverage 84.23% 84.23% -0.01%
==========================================
Files 709 709
Lines 70074 70075 +1
Branches 3619 3619
==========================================
- Hits 59028 59026 -2
- Misses 9880 9881 +1
- Partials 1166 1168 +2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Co-authored-by: Copilot <[email protected]> Signed-off-by: OutisLi <[email protected]>
for more information, see https://pre-commit.ci
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
source/lib/src/gpu/CMakeLists.txt (1)
29-29
: Consider documenting the variable name difference between CMake files.
source/CMakeLists.txt
usesCUDAToolkit_VERSION
while this file usesCMAKE_CUDA_COMPILER_VERSION
to detect CUDA version. Both represent the same CUDA toolkit version but come from different CMake discovery mechanisms:
CUDAToolkit_VERSION
is set byfind_package(CUDAToolkit)
CMAKE_CUDA_COMPILER_VERSION
is set byenable_language(CUDA)
While this is necessary and correct for each context, a brief comment noting this distinction would reduce confusion for future maintainers reviewing version-gating logic across the build system.
Add an inline comment above the version checks in this file, for example:
# Note: CMAKE_CUDA_COMPILER_VERSION is used here (set by enable_language(CUDA) above). # In source/CMakeLists.txt, CUDAToolkit_VERSION is used instead (from find_package). # Both represent the same CUDA version but are set by different CMake operations. if(CMAKE_CUDA_COMPILER_VERSION VERSION_GREATER_EQUAL "13.0") set(CMAKE_CUDA_STANDARD 17)Also applies to: 42-42, 47-53
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
source/CMakeLists.txt
(1 hunks)source/lib/src/gpu/CMakeLists.txt
(2 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
source/CMakeLists.txt
📄 CodeRabbit inference engine (AGENTS.md)
Keep C++ build configuration up to date in CMake when changing C++ components (library, ops, APIs)
Files:
source/CMakeLists.txt
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (29)
- GitHub Check: Build C library (2.14, >=2.5.0,<2.15, libdeepmd_c_cu11.tar.gz)
- GitHub Check: Build C library (2.18, libdeepmd_c.tar.gz)
- GitHub Check: Test Python (5, 3.9)
- GitHub Check: Test Python (6, 3.9)
- GitHub Check: Test Python (6, 3.12)
- GitHub Check: Test Python (5, 3.12)
- GitHub Check: Test Python (4, 3.9)
- GitHub Check: Test Python (3, 3.12)
- GitHub Check: Test Python (1, 3.9)
- GitHub Check: Test Python (3, 3.9)
- GitHub Check: Test Python (2, 3.9)
- GitHub Check: Test Python (4, 3.12)
- GitHub Check: Test Python (2, 3.12)
- GitHub Check: Test Python (1, 3.12)
- GitHub Check: Analyze (python)
- GitHub Check: Analyze (c-cpp)
- GitHub Check: Test C++ (true)
- GitHub Check: Test C++ (false)
- GitHub Check: Build wheels for cp310-manylinux_aarch64
- GitHub Check: Build wheels for cp311-manylinux_x86_64
- GitHub Check: Build wheels for cp311-win_amd64
- GitHub Check: Build wheels for cp311-manylinux_x86_64
- GitHub Check: Build C++ (rocm, rocm)
- GitHub Check: Build wheels for cp311-macosx_arm64
- GitHub Check: Build wheels for cp311-macosx_x86_64
- GitHub Check: Build C++ (cuda120, cuda)
- GitHub Check: Build C++ (cpu, cpu)
- GitHub Check: Build C++ (clang, clang)
- GitHub Check: Build C++ (cuda, cuda)
🔇 Additional comments (2)
source/CMakeLists.txt (1)
249-254
: ✓ Correct placement and logic for CUDA 13.0+ host standard upgrade.The check is correctly positioned after
find_package(CUDAToolkit REQUIRED)
(line 248), soCUDAToolkit_VERSION
is now defined and the version comparison will work as intended. Usingset_if_higher
ensures the standard is only upgraded, never downgraded—appropriate for coexistence with PyTorch's own C++ version requirements (lines 338-341). The status message provides useful build diagnostics.source/lib/src/gpu/CMakeLists.txt (1)
47-53
: ✓ Device-side C++ standard correctly upgraded for CUDA 13.0+.The CUDA device standard is appropriately initialized to 11 (line 13) and upgraded to 17 when
CMAKE_CUDA_COMPILER_VERSION
>= 13.0. Combined with the host-side upgrade insource/CMakeLists.txt
, this ensures both device and host compilation standards align with CUDA 13+ requirements. Status messaging is helpful for debugging version-dependent builds.
auto detect cuda version, if >= 13.0, set c++17
fix issue #5016
Summary by CodeRabbit