Skip to content

Fall back to the CUDA_PATH toolkit when the preferred CUDA version is not installed#6360

Merged
Fedr merged 2 commits into
masterfrom
cuda-version-fallback
Jul 3, 2026
Merged

Fall back to the CUDA_PATH toolkit when the preferred CUDA version is not installed#6360
Fedr merged 2 commits into
masterfrom
cuda-version-fallback

Conversation

@Fedr

@Fedr Fedr commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

platform.props hard-selects the CUDA version per platform toolset (v142 → 11.4, v143 → 12.0, v145 → 13.2). If a user doesn't have exactly that version, the build fails with MSB4019 on the CUDA $(MRCudaVersion).props import even when a perfectly usable newer toolkit is installed.

This PR adds an evaluation-time fallback: when the selected version's MSBuild integration is absent from the running Visual Studio, MRCudaVersion is re-pointed to the toolkit referenced by the CUDA_PATH environment variable (the NVIDIA installer keeps it at the latest installed version), provided that version's VS integration is present. So a machine with only CUDA 13.3 installed now builds with 13.3 instead of erroring.

Details:

  • The hard mapping stays the preference: when the mapped version is installed (as in CI, which installs it explicitly), nothing changes. This avoids silently switching toolkits on machines that have several CUDA versions installed.
  • The check runs at evaluation time (property functions + Exists()), which is required because the CUDA props import itself happens during evaluation — a target-based detection would run too late.
  • MRCudaGencode (Build MSBuild CUDA for the same GPU architectures as CMake #6359) picks up the fallback version automatically via its version-range conditions, e.g. a 13.x fallback gets the 75/86/89/120 architecture set.
  • If neither the mapped version nor the CUDA_PATH version has its integration installed (or CUDA_PATH is unset), the behavior is exactly as before: MSB4019 naming the missing props file.
  • Also covers the case of a future toolset with no mapping yet (MRCudaVersion empty): the CUDA_PATH version is used if its integration is installed.

Verified locally: with the mapped version present the selection is unchanged (12.0 for v143); with the mapping temporarily pointed at a non-installed 12.9 and CUDA_PATH=v13.2, evaluation selects 13.2 and MRCuda compiles end-to-end with the CUDA 13 architecture set; with CUDA_PATH pointing at a toolkit without VS integration (or unset), the original MSB4019 remains.

🤖 Generated with Claude Code

… not installed

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@Fedr Fedr merged commit 623087e into master Jul 3, 2026
28 checks passed
@Fedr Fedr deleted the cuda-version-fallback branch July 3, 2026 10:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants