Repository navigation
Switch from FindCUDA to the FindCUDAToolkit - #2185
Merged
lgritz merged 3 commits intoOct 16, 2026
Merged
Conversation
Replace the deprecated FindCUDA module with CMake's supported FindCUDAToolkit module and imported CUDA runtime targets. Preserve CUDA_TOOLKIT_ROOT_DIR as a fallback input while using canonical CUDAToolkit results internally. Carry the complete toolkit include list through CUDA compilation and account for the CUDA 13 CCCL layout with older supported CMake releases. Keep OSL's CUDA compatibility headers ahead of toolkit headers. Use platform-aware CTest runtime paths so CUDA tests can locate shared libraries and Windows DLLs. CUDA 13 installs cudart and NVRTC DLLs in bin/x64, so prepend that directory when present while retaining bin for older toolkit layouts. Validated generated CTest paths for CUDA 12.4 and 13.3 on Windows. A clean-PATH loader probe using the generated CUDA 13.3 environment loads both cudart and NVRTC. Assisted-by: OpenAI Codex / GPT-6 Signed-off-by: Tim Grant <tgrant@nvidia.com>
Make the standalone CUDA example use FindCUDAToolkit and its imported runtime, NVRTC, and driver targets. Replace cuda_compile_ptx with a local NVCC custom command so the example continues to configure on CMake releases where FindCUDA has been removed. Propagate dependency include directories, account for the CUDA 13 CCCL layout, and choose a toolkit-compatible default GPU architecture while retaining a cache override. Assisted-by: OpenAI Codex / GPT-6 Signed-off-by: Tim Grant <tgrant@nvidia.com>
Older Clang CUDA builds on Windows can resolve __builtin_assume_aligned to an MSVC host-only declaration. Express the alignment promise with __builtin_assume in a device helper instead. The helper preserves the pointer type and evaluates each argument only once. Assisted-by: OpenAI Codex / GPT-6 Signed-off-by: Tim Grant <tgrant@nvidia.com>
lgritz
approved these changes
Oct 16, 2026
lgritz
left a comment
Collaborator
There was a problem hiding this comment.
LGTM
Thanks for this, it would have taken me a long time to work out myself!
Collaborator
|
The Windows CI failures are totally unrelated, I understand them and will address them separately. So I'll merge this now. |
lgritz
merged commit Oct 16, 2026
392c676
into
AcademySoftwareFoundation:main
57 of 63 checks passed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR replaces use of the deprecated
FindCUDAmodule with CMake's newerFindCUDAToolkit.This change is a spiritual successor to Mark's old PR #2073. The overall direction remains the same, but has been reworked on top of the current state of
main.We're including some additional fixes discovered while testing the build on Windows.
FindCUDAToolkit Migration
The build now uses
checked_find_package(CUDAToolkit)and CMake's imported CUDA runtime targets.The migration:
CUDAToolkit_*variables internally, while continuing to acceptCUDA_TOOLKIT_ROOT_DIRas a legacy fallback input.CUDA::cudartorCUDA::cudart_staticrather than manually locating the CUDA runtime and appending Unix-specific system libraries.include/cccl) when necessary for CUDA 13 and older supported CMake versions.CUDAToolkit_FOUND,CUDAToolkit_VERSION, and purpose-specific OSL variables rather than recreating the oldFindCUDAresult variables.VERBATIMcustom commands so paths containing spaces are handled correctly.Windows Device Alignment Fix
Testing on Windows revealed a separate incompatibility in the CUDA renderer support library. When building with older MSVC versions, Clang CUDA builds can resolve
__builtin_assume_alignedto an MSVC host-only declaration, producing an error when it is used in device code.We added a typed
device_assume_alignedhelper. It uses__builtin_assumeto express the alignment guarantee on Windows and retains__builtin_assume_alignedon other platforms. The helper preserves the pointer type and evaluates each argument only once.Standalone CUDA Example
We also migrated the standalone
example-cudaproject toFindCUDAToolkit. The build now reaches CUDA source compilation but encounters a pre-existing use of the now-defuctOSL/device_string.hAPI. Updating the example to OSL's current hash-based device string interface will be handled in a separate PR.The removed
cuda_compile_ptxhelper is replaced with a local NVCC custom command, and the example links directly against theCUDA::cudart,CUDA::nvrtc, andCUDA::cuda_driverimported targets.The example now propagates its complete dependency include paths into PTX compilation and uses
sm_75as its default architecture with CUDA 13, which no longer supports the previous architectures. Older CUDA versions retain ansm_60default, andCUDA_TARGET_ARCHmay still be overridden explicitly.Tests
We did not add any new tests, and we didn't observe any change in the test results relative to the baseline.
Linux configurations were exercised with CUDA 12.8 through 13.3 and LLVM 15.0.7 through 22.1.8, including the following combinations:
Additional configuration and build checks covered:
CUDA_TOOLKIT_ROOT_DIRinput.PATH.Checklist:
and if I used AI coding assistants, I have an
Assisted-by: TOOL / MODELline in the pull request description above.
behavior.
PR, by pushing the changes to my fork and seeing that the automated CI
passed there. (Exceptions: If most tests pass and you can't figure out why
the remaining ones fail, it's ok to submit the PR and ask for help. Or if
any failures seem entirely unrelated to your change; sometimes things break
on the GitHub runners.)
fixed any problems reported by the clang-format CI test.
Assisted-by: OpenAI Codex / GPT-6