Repository navigation
Studio: read the NVIDIA inventory from NVML or the CUDA driver when nvidia-smi cannot answer - #10985
Conversation
…vidia-smi cannot answer, and bound the CUDA version by the kernel module release
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a37ec39685
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if _nvidia_probe is not None and _nvidia_probe.enabled() and sys.platform != "win32": | ||
| bound = _nvidia_probe.cuda_version_for_driver(_nvidia_probe.proc_driver_version()) | ||
| if bound is not None: | ||
| return f"{_PYTORCH_WHL_BASE}/{_torch_family_for_cuda_version(*bound)}" |
There was a problem hiding this comment.
Preserve the pre-Turing cap for the /proc fallback
On a Linux x86_64 host with a Maxwell, Pascal, or Volta GPU, a modern driver, and both nvidia-smi and the library inventory unavailable, this path selects cu128/cu130 solely from /proc. It bypasses _cap_cuda_family_for_pre_turing, even though those PyTorch 2.11 families start at sm_75, so the resulting wheel has no kernels for the GPU. Keep the conservative cu126 default when compute capabilities cannot be read, or otherwise apply the architecture cap before returning.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Right, a driver version alone cannot rule out Maxwell, Pascal or Volta. 7ff997c drops the /proc bound from the torch index (it still feeds detect_host) and keeps cu126 whenever the inventory carries no compute caps; the family is raised only with SMs in hand, through the pre-Turing cap.
| if not has_physical_nvidia: | ||
| has_physical_nvidia = True | ||
| has_usable_nvidia = bool(visible_rows) |
There was a problem hiding this comment.
Keep valid MIG masks usable in the NVML fallback
When NVML is the only successful presence probe and CUDA_VISIBLE_DEVICES contains a valid MIG UUID, the inventory rows contain parent GPU-... UUIDs, so select_visible_gpu_rows returns no rows and this assignment marks the NVIDIA device unusable. This routes an NVML-enabled MIG container without nvidia-smi or /proc/driver/nvidia/gpus to ROCm/CPU even though its CUDA device is visible; recognize MIG UUIDs or retain the existing conservative usable result for mask formats that cannot be matched against physical NVML rows.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Agreed. 7ff997c mirrors the nvidia-smi rows: a mask NVML rows cannot name (a MIG UUID, anything supports_explicit_visible_device_matching rejects) leaves the GPU usable; an explicit index or GPU- UUID that matches nothing stays unusable. Test added.
…bash hook test on Windows for PR #10985
|
@codex review |
|
@codex security review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7ff997c876
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| inventory = _nvidia_library_inventory() | ||
| return bool(inventory is not None and inventory.devices) |
There was a problem hiding this comment.
Apply CUDA visibility to the NVML presence fallback
When nvidia-smi and /proc are unavailable and CUDA_VISIBLE_DEVICES contains an explicit numeric index or GPU-... UUID that matches no NVIDIA device, an NVML inventory is physical and unmasked, so this returns True even though CUDA exposes no NVIDIA GPU. That causes _has_rocm_gpu() to reject a usable AMD device and can route installation or repair to CUDA; filter NVML rows against explicit masks here, while retaining the conservative behavior for MIG or other mask formats that cannot be matched to physical rows.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Agreed. 58794ec filters the NVML rows by an explicit index or GPU- UUID mask in _has_usable_nvidia_gpu (a miss reads as no usable NVIDIA GPU, so ROCm is not blocked); a MIG or other mask NVML rows cannot name stays usable, as the nvidia-smi and /proc probes leave it, and the CUDA driver rows are taken as already masked.
…orch presence check for PR #10985
|
@codex review |
|
Codex Review: Didn't find any major issues. Nice work! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
… path filter for PR #10985
…d on (unslothai#11001) * Run the chat width presets in CI, and two guards main is currently red on Three merges left main failing guards that every open PR then inherits. Lint CI's "Workflow guard suites" step and Repo tests (CPU, studio) are red on main right now, and six open PRs show the failure as their own. 1. unslothai#10958 added tests/studio/playwright_chat_width.py and no workflow that runs it. test_every_playwright_driver_is_invoked_by_ci exists for exactly that and says so. It could not be wired as written: it took CHAT_THREAD_ID and no CI step can produce a thread id, so the presets shipped with a driver that runs nowhere. The driver now seeds its own conversation through /api/chat/threads, the way playwright_thread_scoped_settings.py does, and CHAT_THREAD_ID stays honoured when set. Seeding needs no model: the messages endpoint stores whatever roles it is given, and an assistant-role message renders the .aui-assistant-message-root every assertion here measures. Verified against a real Studio: the seeded thread renders the bubble, and the sweep passes. Its sign-in also handled only the already-rotated case, so it could not have run against a fresh CI boot even with a thread id. Same two-branch shape as its siblings now. While making it run, one assertion that could not fail: the preset ordering is >=, so three presets pinned to the same width satisfy every line of it. The setting could stop working entirely and the driver would pass. At the widest viewport the three are separated by construction (48rem / 72rem / max(72rem, 100% - 6rem) in appearance-custom-store.ts), so that separation is now required. Pinning --custom-chat-max-width in a live browser: the old assertions pass, the new one fails with "at 2560px Wide gives message 744px, no more than Standard's 744px, so the preset is doing nothing". 2. unslothai#10985 added studio/nvidia_probe.py, imported by both install_llama_prebuilt.py and install_python_stack.py, which studio-mac-install-matrix.yml lists as inputs. Editing the probe did not run the matrix that depends on it. Added to both triggers. 3. unslothai#10988 (mine) added tests/studio/test_core_setup_zoo_revision_notice.py, which reads a workflow file but was not in workflow-trigger-lint's guard step, the only job with no paths filter. A PR editing only workflow files never collected it. Added. The 1054 tests in the guard step pass, as does tests/studio (9687 passed; the two failures there are on main already and untouched by this: an mlx import and a PR-scoped guard). * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Tighten the comments this PR adds Comment/docstring text only. comment_tools.py check --strict-ext --allow-docstring-edits: 3/3 OK. The guard step's 1054 tests still pass, and the driver still runs green end to end against a real Studio. --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
…vidia-smi cannot answer (unslothai#10985) * Studio: read the NVIDIA inventory from NVML or the CUDA driver when nvidia-smi cannot answer, and bound the CUDA version by the kernel module release * Shorten the probe comments for PR unslothai#10985 * Keep cu126 without compute caps, keep MIG masks usable, and skip the bash hook test on Windows for PR unslothai#10985 * Apply an explicit CUDA_VISIBLE_DEVICES mask to the NVML rows in the torch presence check for PR unslothai#10985 * Scan nvidia_probe.py for interactive prompts and add it to the parity path filter for PR unslothai#10985 --------- Co-authored-by: danielhanchen <[email protected]>
…d on (unslothai#11001) * Run the chat width presets in CI, and two guards main is currently red on Three merges left main failing guards that every open PR then inherits. Lint CI's "Workflow guard suites" step and Repo tests (CPU, studio) are red on main right now, and six open PRs show the failure as their own. 1. unslothai#10958 added tests/studio/playwright_chat_width.py and no workflow that runs it. test_every_playwright_driver_is_invoked_by_ci exists for exactly that and says so. It could not be wired as written: it took CHAT_THREAD_ID and no CI step can produce a thread id, so the presets shipped with a driver that runs nowhere. The driver now seeds its own conversation through /api/chat/threads, the way playwright_thread_scoped_settings.py does, and CHAT_THREAD_ID stays honoured when set. Seeding needs no model: the messages endpoint stores whatever roles it is given, and an assistant-role message renders the .aui-assistant-message-root every assertion here measures. Verified against a real Studio: the seeded thread renders the bubble, and the sweep passes. Its sign-in also handled only the already-rotated case, so it could not have run against a fresh CI boot even with a thread id. Same two-branch shape as its siblings now. While making it run, one assertion that could not fail: the preset ordering is >=, so three presets pinned to the same width satisfy every line of it. The setting could stop working entirely and the driver would pass. At the widest viewport the three are separated by construction (48rem / 72rem / max(72rem, 100% - 6rem) in appearance-custom-store.ts), so that separation is now required. Pinning --custom-chat-max-width in a live browser: the old assertions pass, the new one fails with "at 2560px Wide gives message 744px, no more than Standard's 744px, so the preset is doing nothing". 2. unslothai#10985 added studio/nvidia_probe.py, imported by both install_llama_prebuilt.py and install_python_stack.py, which studio-mac-install-matrix.yml lists as inputs. Editing the probe did not run the matrix that depends on it. Added to both triggers. 3. unslothai#10988 (mine) added tests/studio/test_core_setup_zoo_revision_notice.py, which reads a workflow file but was not in workflow-trigger-lint's guard step, the only job with no paths filter. A PR editing only workflow files never collected it. Added. The 1054 tests in the guard step pass, as does tests/studio (9687 passed; the two failures there are on main already and untouched by this: an mlx import and a PR-scoped guard). * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Tighten the comments this PR adds Comment/docstring text only. comment_tools.py check --strict-ext --allow-docstring-edits: 3/3 OK. The guard step's 1054 tests still pass, and the driver still runs green end to end against a real Studio. --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
The installers ask nvidia-smi three questions: is there a GPU, which compute capabilities, and which CUDA version the driver carries. When nvidia-smi cannot answer, every one of those became "no": a copy absent from PATH (a container with only the driver libraries mounted, a snap, Windows with the utility off PATH), a stale copy that exits non-zero, or one that hangs, left
driver_cuda_versionunset, and "runnable by this driver=none" then sent a CUDA host to a source build or the CPU bundle. The torch index defaulted to cu126 in the same case, which on Blackwell is a wheel with no kernels, and a CPU torch expectation is what #10906 had to defend against.Ollama, Jan and lemonade never depend on the utility: Ollama loads
libnvidia-ml.soandlibcuda.sodirectly, Jan and lemonade read NVML, and ComfyUI Desktop and LlamaFactory (the two that also install PyTorch) ask torch itself. This adds the same source as the fallback.The change
studio/nvidia_probe.py, a stdlib-only module:libnvidia-ml.so.1/nvml.dll): the library nvidia-smi is a client of, so the inventory is the physical one and the caller appliesCUDA_VISIBLE_DEVICESexactly as it does to nvidia-smi rows. Compute capability, UUID, name, driver version and the packed CUDA driver version (13010 is 13.1).libcuda.so.1/nvcuda.dll):cuInit,cuDriverGetVersion,cuDeviceGetCountand the compute-capability attributes. It honours the mask, so an emptied one reads as no devices./proc/driver/nvidia/versionnames the kernel module and the release bounds the CUDA major (R580 carries CUDA 13, R525 carries 12, R450 carries 11, from NVIDIA's minor-version-compatibility table).Consumers, each after its existing probes and only when they came back empty:
install_llama_prebuilt.detect_host: presence, physical and visible compute caps, driver CUDA version.install_python_stack._has_usable_nvidia_gpuand_detect_cuda_torch_index_url: the torch family, with the pre-Turing cap reading SMs from the library inventory (_cap_cuda_family_for_pre_turingtakes them as an argument). Without SMs the cu126 default stays: a driver version alone cannot rule out Maxwell, Pascal or Volta, which cu128+ drop. The CUDA ladder is one function,_torch_family_for_cuda_version. The/procrelease bound feedsdetect_hostonly.setup.sh _setup_has_physical_nvidia_gpu: runs the module last, bounded by_setup_run_smi.A working nvidia-smi is never second-guessed. Older checkouts import the module under
try, so a newer setup script beside an older tree still runs.UNSLOTH_NVIDIA_LIBRARY_PROBE=0turns every new source off, the/procbound included; the test conftests set it so a test that hides nvidia-smi to fake a CPU host does not find the real GPUs through the libraries.Measured
This host: 8x B200, driver 590.48.01, CUDA 13.1. One variable changed per row,
install_llama_prebuilt.py --resolve-prebuiltat main and at this branch.prebuilt_available: false(source build or CPU); torch index cu126linux-cuda,app-b10909-mix-bea84f7-linux-x64-cuda13-newer.tar.gz; torch index cu130prebuilt_available: false, 62 scuda13-newer, 63 s/proc/driver/nvidia/gpusThe probe answers in 0.1 s. The three 20 s nvidia-smi timeouts still run first; shortening them is a visible behaviour change and is left for its own PR.
Tests
tests/studio/install/test_nvidia_library_probe.py: the module (payload parsing, the CUDA packing, the driver-release table against NVIDIA's documented floors, the/procreader, the child run with its deadline, a hung or broken child, macOS, the CLI exit code, and on a real NVIDIA host the library agreeing withnvidia-smi -L),detect_host(a failing or absent nvidia-smi now reads the inventory; NVML rows are masked like nvidia-smi rows while CUDA driver rows are not; a working nvidia-smi is not probed; the kernel release bounds the driver version; a CPU host stays CPU), the torch index fallbacks, and thesetup.shhook.