Skip to content

Detect CUDA UMD Version from newer nvidia-smi output (fixes #5812) - #5817

Merged
danielhanchen merged 2 commits into
mainfrom
fix/cuda-umd-version-detection-5812
May 27, 2026
Merged

danielhanchen merged 2 commits into
mainfrom
fix/cuda-umd-version-detection-5812

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

Summary

Fixes #5812. Newer NVIDIA drivers (e.g. 610.x on Windows, shipped with the RTX 5090 Laptop) print the driver's max CUDA capability as CUDA UMD Version: X.Y instead of the legacy CUDA Version: X.Y header. Every CUDA-version parser in this repo was only matching the legacy spelling, so on a system with a 13.x driver:

  • install.ps1 reported could not determine CUDA version from nvidia-smi, defaulting to cu126 and installed a cu126 PyTorch wheel on a cu130-capable driver.
  • The same fallback happened on Linux/macOS in install.sh.
  • Studio's setup.ps1 mis-selected the PyTorch CUDA tag and silently left $DriverMaxCuda unset, so the CUDA Toolkit version pin was wrong too.
  • studio/install_llama_prebuilt.py skipped the line entirely and could route GPU hosts to the CPU-only llama.cpp prebuilt.

Reporter's sample nvidia-smi header:

| NVIDIA-SMI 610.47                 KMD Version: 610.47        CUDA UMD Version: 13.3     |

Changes

File Change
install.ps1 Get-TorchIndexUrl regex relaxed to CUDA(?: UMD)? Version:\s+(\d+)\.(\d+).
install.sh Two POSIX BRE -e expressions (UMD first, legacy second). The two patterns are mutually exclusive per line so head -1 selects the right match.
studio/setup.ps1 Same relaxation applied to Get-PytorchCudaTag and the $DriverMaxCuda detector.
studio/install_llama_prebuilt.py Substring scan replaced with re.search(r'CUDA(?: UMD)? Version:\s*(\d+)\.(\d+)', merged).
tests/sh/test_get_torch_index_url.sh New make_mock_smi_umd helper plus three UMD cases: 13.3 -> cu130, 12.8 -> cu128, 11.8 -> cu118.

Regex sanity check on the reporter's exact sample:

>>> re.search(r'CUDA(?: UMD)? Version:\s+(\d+)\.(\d+)',
...     '| NVIDIA-SMI 610.47   KMD Version: 610.47   CUDA UMD Version: 13.3 |').groups()
('13', '3')

The legacy header still matches and continues to route 12.6 -> cu126, 12.8 -> cu128, 13.0 -> cu130, etc.

Test plan

  • bash tests/sh/test_get_torch_index_url.sh -> 30 passed, 0 failed (27 existing + 3 new UMD cases).
  • Manual regex check against the exact CUDA UMD Version: 13.3 line from the issue: routes to cu130.
  • Manual regex check that the legacy CUDA Version: 12.6 line still routes to cu126.
  • On a Windows host with a 13.x driver: run irm https://unsloth.ai/install.ps1 | iex and confirm installing PyTorch (https://download.pytorch.org/whl/cu130)... (cannot run from this environment, requested verification from the reporter).

Closes #5812.

Newer NVIDIA drivers (e.g. 610.x on Windows) print the driver's max
CUDA capability as "CUDA UMD Version: X.Y" instead of the legacy
"CUDA Version: X.Y" header.  The installers and Studio setup scripts
were only matching the legacy spelling, so on a fresh RTX 5090
laptop with a 13.x driver they failed to detect any CUDA version
and fell through to the cu126 wheel default.

Accept both spellings everywhere we parse nvidia-smi output:

- install.ps1: Get-TorchIndexUrl regex now allows " UMD"
- install.sh: two-expression sed (POSIX BRE has no "?"); the two
  patterns are mutually exclusive per line, head -1 picks the match
- studio/setup.ps1: Get-PytorchCudaTag and the $DriverMaxCuda
  detector both relaxed
- studio/install_llama_prebuilt.py: substring scan replaced with a
  regex search using the same pattern
- tests/sh/test_get_torch_index_url.sh: new make_mock_smi_umd helper
  plus three UMD cases (13.3 -> cu130, 12.8 -> cu128, 11.8 -> cu118);
  all 30 tests pass locally
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the installation and setup scripts (install.ps1, install.sh, studio/install_llama_prebuilt.py, and studio/setup.ps1) to support parsing the newer "CUDA UMD Version" header format alongside the legacy "CUDA Version" format from nvidia-smi output. This ensures correct CUDA version detection and PyTorch tag mapping with newer NVIDIA drivers (e.g., 610.x). Additionally, corresponding unit tests have been added to verify this behavior. I have no feedback to provide as there are no review comments and the changes are well-implemented.

@danielhanchen
danielhanchen merged commit a62eb80 into main May 27, 2026
35 checks passed
@danielhanchen
danielhanchen deleted the fix/cuda-umd-version-detection-5812 branch May 27, 2026 17:37
danielhanchen added a commit to oobabooga/unsloth that referenced this pull request May 31, 2026
…ows + Linux) (unslothai#5879)

Make the NVIDIA prebuilt selection version-dynamic and driver-gated on both the
Windows (ggml-org) and Linux (unslothai/llama.cpp) paths, so CUDA version bumps
are handled with no code change while staying safe across driver versions.

- Derive candidate CUDA runtime lines from the driver major; pick the highest
  upstream-published minor the driver can actually run, so a sub-13.3 driver is
  never handed an unguaranteed 13.3 build.
- Pin b9360's cuda-13.1 build (immutable, hash-verified) as a GPU fallback for a
  Blackwell host on a 13.1/13.2 driver that the in-release 13.3 build gates off,
  on both the simple and published install paths. Dormant for every other host
  and self-disabling once upstream ships a driver-runnable build again.
- Seed the published-path ordering from the release's real published minors so a
  future CUDA major is selectable with no code change.

Refs unslothai#5861, unslothai#5817, unslothai#5807, unslothai#5858, unslothai#5854, unslothai#5826, unslothai#5887.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Windows installer does not detect CUDA from newer nvidia-smi output using "CUDA UMD Version", falls back to cu126

1 participant