Repository navigation
Unsloth Studio Installer: improve GPU print details (NVIDIA, Intel, AMD) - #8762
danielhanchen merged 20 commits into
Conversation
39d05c3 to
3e1a3d7
Compare
The GPU line said a different kind of thing per vendor, and on two of the
three it did not say which card:
gpu NVIDIA GPU detected <- no name, ever
gpu Intel GPU detected <- name on the substep below
Intel Arc A770
gpu AMD ROCm (gfx1200) <- arch, not a name
Every probe already had the answer. nvidia-smi is resolved and run before
this point and was simply never asked; the shell scripts resolve the AMD
marketing name into $_gpu_disp_mkt / $_setup_mkt for their own name -> arch
inference and never print it; and the backend prints the real name at
startup seconds later:
Hardware detected: ROCm (HIP 7.13.99004) -- AMD Radeon RX 9060 XT
One shape for all three now: `step "gpu"` is the device, the runtime detail
drops to a substep.
gpu NVIDIA GeForce RTX 4090
gpu Intel Arc A770
gpu AMD Radeon RX 9060 XT (gfx1200)
HIP SDK: C:\Program Files\AMD\ROCm\7.1
Each vendor honours its own visible-device mask when picking which card to
name (CUDA_VISIBLE_DEVICES, HIP/ROCR_VISIBLE_DEVICES), so a masked run names
the card it is actually going to use.
On the AMD side the name is kept in its own variable rather than folded into
$ROCmGpuLabel: that one doubles as the input to the name -> arch tables, so
changing its shape would move wheel selection. It is read from hipinfo's
per-device "Name:", amd-smi's Market Name, or the WMI adapter name, always
at the index the arch pick landed on and only when the name and arch lists
line up, so a format change can mislabel nothing and the arch that selects
the wheel is never taken from it.
Also stops setup.ps1 reporting a known ROCm version as unknown. It probed
hipconfig then amd-smi and, on a runtime-only layout with neither on PATH,
printed
rocm ROCm (version unknown)
one line after the summary printed C:\Program Files\AMD\ROCm\7.1. The SDK
root is versioned, so that is now the last-resort source.
The first pass unified the device name across vendors but left AMD as the
only one showing what it would actually compile for:
gpu NVIDIA GeForce RTX 4090
gpu AMD Radeon RX 9060 XT (gfx1200)
HIP SDK: C:\Program Files\AMD\ROCm\7.1
compute_cap is the counterpart of the gfx arch, and the driver version the
counterpart of the HIP SDK line. Both come back from the query that already
fetches the name, so this costs no extra call:
gpu NVIDIA GeForce RTX 4090 (sm_89)
Driver: 550.54.15
The installer was already reading compute_cap, but only inside
Get-NvidiaCu126Verdict, which runs on the cu128/cu130 path to decide a
fallback and returns early otherwise, so it was never available where the
banner is printed.
Fields are split from the right because nvidia-smi does not quote its CSV,
so a comma in a device name would otherwise shift every column. A row with
fewer fields than requested falls back to using the whole row as the name
rather than reporting a driver version that is really a compute capability.
Intel keeps the name alone. There is no counterpart to gfx1200 / sm_89 that
any probe here already resolves, and inventing one to make the column look
even is worse than the gap.
…into feat/studio-installer-gpu-name
|
The direction is right, but the same nvidia-smi CSV parse is duplicated in all four scripts and the separate ROCm version-unknown fix in studio/setup.ps1 rides along. Could you split that one out and share the parse rather than copying it, and take a look at Core (HF=latest + TRL=latest) and the hf-stack package scan which are green on main? |
…ounded Simulated the banner against fake nvidia-smi / rocminfo / amd-smi on a 74-case matrix (both shell entry points x NVIDIA / AMD / Intel / CPU-only host shapes), running the merge base and this branch against identical fixtures. Three problems only showed up once the name was actually printed. rocminfo enumerates the CPU as Agent 1, and that agent carries its own "Marketing Name:". Taking the first match in the stream therefore named the processor: an RX 7900 XTX box read "AMD Ryzen 9 7950X 16-Core Processor (gfx1100)". On Strix Halo it is worse, because the CPU agent's name is "AMD RYZEN AI MAX+ 395 w/ Radeon 8060S" -- it contains a Radeon model, so it reads like a GPU name, and $_setup_mkt also feeds the name -> arch table. The parse is now per agent and only an agent whose Device Type is GPU can name the banner. Agents are collected as gfx/name pairs and the banner takes the name belonging to the arch that was picked, so an iGPU + dGPU host no longer prints the integrated name against the discrete arch. The new nvidia-smi query ran unbounded. Every other nvidia-smi call in these files goes through _run_bounded / _setup_run_smi / Invoke-NvidiaSmiBounded precisely because a wedged driver blocks nvidia-smi indefinitely; in the matrix a hung probe took the whole installer down on this branch while the merge base finished normally. It now uses the bounded runner, and the shell side reuses the executable the detection helper already resolved into $_nvsmi rather than re-resolving with `command -v` -- detection also succeeds via /usr/bin/nvidia-smi off PATH and via /proc/driver/nvidia/gpus with no nvidia-smi at all, and those hosts would otherwise silently lose the name. Placeholder rows are no longer treated as device names. An nvidia-smi too old for compute_cap answers "[N/A]" rather than failing, which printed a GPU called "[N/A]"; a short row used the whole row, printing "RTX 4090, 8.9". Short rows now keep field 1 and the placeholders fall back to the old text. Also on the AMD side: amd-smi spells the field MARKET_NAME in caps, so the [Mm]arket.?[Nn]ame class matched no real casing and that probe never yielded a name at all. Matched case-insensitively now, and the rocminfo and amd-smi calls in install.sh are bounded like their setup.sh counterparts. In setup.ps1 the device index is carried forward from Resolve-VisibleGpuIndex instead of being recovered from the arch value. The arch list is deliberately not deduplicated, so [array]::IndexOf always returned the first occurrence: two same-arch cards with different SKUs (RX 7900 XTX + PRO W7900) named the first one even when the mask selected the second. The WMI adapter name is likewise moved onto the adapter the arch pick landed on, which the mask, the nameArches[0] borrow and the shadowing repick can all change. CPU-only and Intel hosts print exactly what they printed before this branch, and all 21 tests in tests/studio/*.ps1 pass.
|
Went through this one properly and simulated it rather than eyeballing it, since the description says it was never run end to end on hardware. I have pushed the fixes straight to the branch (e8c9efd) so you can see them in context. What I didLifted the banner block out of all four entry points at both the merge base and this head, and ran them against fake The direction is right and the NVIDIA line is a clear improvement: 30 of 44 NVIDIA cases now name the device where before every one of them said What the simulation found1. The AMD line named the CPU. Every 2. The new query ran unbounded, and a wedged driver took the installer down. Every other This is the P1 Codex flagged on 3. Placeholder and short rows became device names. An 4. 5. Backwards compatibilityCPU-only and Intel hosts print byte-identical output to the merge base, every case completes with rc=0 and no hang, and all 21 Still openYour two points from earlier stand and I have not done them here, since both are bigger than this diff. The CSV parse is now one function per shell script rather than two copies, but it is still mirrored across Two things I could not answer on this box: it has no AMD or Intel GPU and no Windows, so everything above rests on fake probes plus the real tool output shapes, and the branch is ~1200 commits behind main with a CI run old enough that the logs have expired. It wants a rebase and a fresh run, ideally on real AMD and NVIDIA hardware, before merge. |
Three more cases from the review, each reproduced in the fixture matrix before being changed. nvidia-smi does not honour CUDA_VISIBLE_DEVICES, so the mask has to be resolved against its physical rows by hand, and only a numeric token was. A UUID mask therefore left the index at 0 and named the first card rather than the visible one. UUIDs are the form NVIDIA recommends over indices, may be abbreviated to any unique leading portion, and a MIG id (MIG-<GPU-UUID>/<gi>/<ci>) embeds one, so a non-numeric token is now looked up against --query-gpu=uuid by prefix, with MIG unwrapped to its parent GPU. A token matching nothing still falls back to row 0. The lookup runs only on the non-numeric path, so the ordinary case costs no extra call and the CSV parse keeps its three documented columns. hipinfo is itself a HIP application, so HIP_VISIBLE_DEVICES / ROCR_VISIBLE_DEVICES have already filtered its output and renumbered the survivors from zero. install.ps1 indexed that output by the physical token as well, applying the mask twice and landing on the wrong device; studio/setup.ps1 has always taken entry 0 and says so in a comment. install.ps1 now matches it. This was previously only an arch selection, which is why it went unnoticed; printing the name made it visible. setup.sh could resolve a marketing name but no gfx target and then drop the name, falling through to a bare "AMD ROCm" while install.sh printed the name. The name-only arm is added below the unsupported-GPU arm, not above it: a card with no ROCm wheels also arrives here with a name, and naming it quietly would drop the warning that training will not run. Matrix is now 80 cases, all completing with no hang; tests/studio/*.ps1 all pass.
|
@codex security review |
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. |
Two defects in the NVIDIA banner's device selection. CUDA truncates enumeration at the first invalid index, so the documented "2,-1" means "device 2, then stop". Both shell scripts classified the WHOLE mask, saw the minus sign, called it non-numeric and sent a plain ordinal down the UUID lookup, which matched nothing and named row 0. They now classify the first entry, which is the one that selects the device. The PowerShell copies already did this. A numeric entry is a CUDA ordinal, not an nvidia-smi row. CUDA defaults to CUDA_DEVICE_ORDER=FASTEST_FIRST, which puts the fastest card at 0 and leaves the rest unspecified, while nvidia-smi always lists in PCI order. An ordinal therefore identifies a row only when the order is pinned to PCI_BUS_ID, or when the cards are interchangeable and every row gives the same answer anyway. Otherwise the banner keeps the vendor-only wording and reports the driver alone, which is what the AMD path already does when the mask and the records disagree. A UUID or MIG id identifies the device outright, so it is unaffected.
…its name Two more selection defects. NVIDIA accepts an abbreviated UUID only when it is a unique leading portion, so a prefix matching two cards selects no device at all. The helper returned the first match, and both PowerShell copies stopped at the first hit, so the banner named one of them. They now count matches and resolve only on exactly one. That exposed the same wrong assumption one level up: an identity mask that does not resolve, whether ambiguous or naming a card that is not present, was falling back to row 0. Row 0 is not a fallback for "CUDA selected nothing", it is a different card. Those masks now keep the vendor-only wording. In studio/setup.ps1, an unmappable adapter ahead of a supported one leaves $nameArches shorter than $gpuNames, which skipped the block that moves the banner name onto the adapter the arch came from. A generic integrated Radeon in front of an RX 9070 therefore printed the integrated name against the discrete arch. The source adapter is now recorded while $nameArches is built, so a borrowed arch takes its own card's name with it.
# Conflicts: # studio/setup.sh
|
Rebased onto current The conflictOne file, Resolved by taking Performance112 fixture cases, five runs each, merge base vs head, timing only the installer process and taking the minimum:
AMD adds nothing because The wedged-driver cases, where cost is bounded rather than measured in milliseconds: One thing worth a separate look
I have not touched it here. Memoizing the probe would halve that stall, but the second call also exists to re-check after a PATH gap or driver-init race, which is exactly what a cached answer would hide, so it deserves its own change rather than a quiet one inside this PR. Verification at |
CUDA stops enumerating at the first invalid index, so CUDA_VISIBLE_DEVICES=1 on a one-GPU host exposes no device at all. The row pick clamps an out-of-range index to 0 so the driver version still reads, and the banner then named row 0: a card the process cannot use. An ordinal past the last row now counts as unresolved, the same as an identity mask that matches nothing, so the banner keeps the vendor-only wording. The existing out-of-range fixture did not catch this. It used two different cards under CUDA's default order, so the ordering guard suppressed the name for an unrelated reason and the range bug stayed invisible. The new fixtures pin CUDA_DEVICE_ORDER and use identical cards, which disables that guard and leaves the range check as the only thing that can answer.
The previous fix only moved the banner name when the arch was BORROWED from
another adapter. A visible-device mask selecting a supported adapter that sits
behind an unmappable one resolves the arch directly, so the borrow never fires,
$nameArches is still shorter than $gpuNames, and neither naming branch ran:
HIP_VISIBLE_DEVICES=1 over ["AMD Radeon Graphics", "AMD Radeon RX 9070"]
printed the integrated name against the discrete arch.
One index now records which adapter supplied the arch in either case.
It is spelled `if ($pickedName -and $_archSrcIdx -lt 0)` rather than a bare
truthiness test because `if ($pickedName) {` is the end anchor
TestSetupPs1ShadowingParity slices the borrow block on. A second copy closed
that window early and hid the pinned-mask guard from it, which failed the test
on the first attempt. A new case pins the occurrence count so the anchor cannot
be shadowed again.
|
@codex review |
|
Codex Review: Didn't find any major issues. Can't wait for the next one! 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". |
Self-review turned up two ways a numerically valid ordinal slipped past the checks added over this review. awk subscripts arrays by the STRING form of the key, so a["0000"] is a different cell from a[0]. Rows are stored with a[n++], whose keys are "0", "1", so a CUDA_VISIBLE_DEVICES of "0000" or "01" read an empty cell, the row came back blank and the banner degraded to the vendor wording with no driver line. Six sites across the two scripts, NVIDIA and AMD alike; every one now forces numeric context on the subscript. The bash test builtin parses with strtol and errors on a value wider than a long. An all-digit ordinal that overflows printed a shell diagnostic into the user's terminal and skipped the out-of-range check entirely, so it named row 0, the exact case that check exists to refuse. The ordinal is now clamped to 9999, which is past any real host, so it stays out of range and declines. Eight fixtures pin the non-canonical spellings, with the cards differing and the device order pinned so only the ordinal can decide the outcome.
0cc87e0 to
3d289eb
Compare
|
Self-review pass over the accumulated diff while CI was queued, hunting the defect class that has shown up repeatedly here: a guard that is individually right but that another path walks around. Two found, both fixed in awk subscripts by the string form of the key. Rows are stored with The The ordinal is clamped to 9999 before anything compares or subscripts with it. Clamped rather than rejected, because 9999 is past any real host, so it stays out of range and declines, which is the answer we want anyway. Both were invisible to the existing fixtures because every mask they used was already canonical. The eight new cases use non-canonical but all-digit spellings, with the cards differing and 126 shell fixture cases and 85 PowerShell cases, no failures; |
|
@codex review |
|
Codex Review: Didn't find any major issues. Breezy! 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". |
install.ps1 and studio/setup.ps1 both conflicted at the same place: main grew a Get-NvidiaLibraryInventory promotion that sets $HasNvidiaSmi when the driver lists a GPU nvidia-smi cannot, and this branch added the naming query, both appended after the same nvidia-smi resolution loop and both closed by the same brace. Kept both, promotion first. The naming block is gated on $NvidiaSmiExe, which is assigned only where Test-NvidiaSmiHasGpu answered, so a host promoted through the driver library alone has no exe and keeps the vendor-only wording instead of querying a binary that is absent or was rejected. install.sh and studio/setup.sh merged without conflict and keep main's reflection emit in the WSL shortcut path: no Add-Type, no ExecutionPolicy Bypass.
…MD) (unslothai#8762) * Unsloth Studio Installer: name the actual GPU, whichever vendor it is The GPU line said a different kind of thing per vendor, and on two of the three it did not say which card: gpu NVIDIA GPU detected <- no name, ever gpu Intel GPU detected <- name on the substep below Intel Arc A770 gpu AMD ROCm (gfx1200) <- arch, not a name Every probe already had the answer. nvidia-smi is resolved and run before this point and was simply never asked; the shell scripts resolve the AMD marketing name into $_gpu_disp_mkt / $_setup_mkt for their own name -> arch inference and never print it; and the backend prints the real name at startup seconds later: Hardware detected: ROCm (HIP 7.13.99004) -- AMD Radeon RX 9060 XT One shape for all three now: `step "gpu"` is the device, the runtime detail drops to a substep. gpu NVIDIA GeForce RTX 4090 gpu Intel Arc A770 gpu AMD Radeon RX 9060 XT (gfx1200) HIP SDK: C:\Program Files\AMD\ROCm\7.1 Each vendor honours its own visible-device mask when picking which card to name (CUDA_VISIBLE_DEVICES, HIP/ROCR_VISIBLE_DEVICES), so a masked run names the card it is actually going to use. On the AMD side the name is kept in its own variable rather than folded into $ROCmGpuLabel: that one doubles as the input to the name -> arch tables, so changing its shape would move wheel selection. It is read from hipinfo's per-device "Name:", amd-smi's Market Name, or the WMI adapter name, always at the index the arch pick landed on and only when the name and arch lists line up, so a format change can mislabel nothing and the arch that selects the wheel is never taken from it. Also stops setup.ps1 reporting a known ROCm version as unknown. It probed hipconfig then amd-smi and, on a runtime-only layout with neither on PATH, printed rocm ROCm (version unknown) one line after the summary printed C:\Program Files\AMD\ROCm\7.1. The SDK root is versioned, so that is now the last-resort source. * Give NVIDIA the same compute target and runtime line as AMD The first pass unified the device name across vendors but left AMD as the only one showing what it would actually compile for: gpu NVIDIA GeForce RTX 4090 gpu AMD Radeon RX 9060 XT (gfx1200) HIP SDK: C:\Program Files\AMD\ROCm\7.1 compute_cap is the counterpart of the gfx arch, and the driver version the counterpart of the HIP SDK line. Both come back from the query that already fetches the name, so this costs no extra call: gpu NVIDIA GeForce RTX 4090 (sm_89) Driver: 550.54.15 The installer was already reading compute_cap, but only inside Get-NvidiaCu126Verdict, which runs on the cu128/cu130 path to decide a fallback and returns early otherwise, so it was never available where the banner is printed. Fields are split from the right because nvidia-smi does not quote its CSV, so a comma in a device name would otherwise shift every column. A row with fewer fields than requested falls back to using the whole row as the name rather than reporting a driver version that is really a compute capability. Intel keeps the name alone. There is no counterpart to gfx1200 / sm_89 that any probe here already resolves, and inventing one to make the column look even is worse than the gap. * Installer GPU banner: name the GPU, not the CPU, and keep the probe bounded Simulated the banner against fake nvidia-smi / rocminfo / amd-smi on a 74-case matrix (both shell entry points x NVIDIA / AMD / Intel / CPU-only host shapes), running the merge base and this branch against identical fixtures. Three problems only showed up once the name was actually printed. rocminfo enumerates the CPU as Agent 1, and that agent carries its own "Marketing Name:". Taking the first match in the stream therefore named the processor: an RX 7900 XTX box read "AMD Ryzen 9 7950X 16-Core Processor (gfx1100)". On Strix Halo it is worse, because the CPU agent's name is "AMD RYZEN AI MAX+ 395 w/ Radeon 8060S" -- it contains a Radeon model, so it reads like a GPU name, and $_setup_mkt also feeds the name -> arch table. The parse is now per agent and only an agent whose Device Type is GPU can name the banner. Agents are collected as gfx/name pairs and the banner takes the name belonging to the arch that was picked, so an iGPU + dGPU host no longer prints the integrated name against the discrete arch. The new nvidia-smi query ran unbounded. Every other nvidia-smi call in these files goes through _run_bounded / _setup_run_smi / Invoke-NvidiaSmiBounded precisely because a wedged driver blocks nvidia-smi indefinitely; in the matrix a hung probe took the whole installer down on this branch while the merge base finished normally. It now uses the bounded runner, and the shell side reuses the executable the detection helper already resolved into $_nvsmi rather than re-resolving with `command -v` -- detection also succeeds via /usr/bin/nvidia-smi off PATH and via /proc/driver/nvidia/gpus with no nvidia-smi at all, and those hosts would otherwise silently lose the name. Placeholder rows are no longer treated as device names. An nvidia-smi too old for compute_cap answers "[N/A]" rather than failing, which printed a GPU called "[N/A]"; a short row used the whole row, printing "RTX 4090, 8.9". Short rows now keep field 1 and the placeholders fall back to the old text. Also on the AMD side: amd-smi spells the field MARKET_NAME in caps, so the [Mm]arket.?[Nn]ame class matched no real casing and that probe never yielded a name at all. Matched case-insensitively now, and the rocminfo and amd-smi calls in install.sh are bounded like their setup.sh counterparts. In setup.ps1 the device index is carried forward from Resolve-VisibleGpuIndex instead of being recovered from the arch value. The arch list is deliberately not deduplicated, so [array]::IndexOf always returned the first occurrence: two same-arch cards with different SKUs (RX 7900 XTX + PRO W7900) named the first one even when the mask selected the second. The WMI adapter name is likewise moved onto the adapter the arch pick landed on, which the mask, the nameArches[0] borrow and the shadowing repick can all change. CPU-only and Intel hosts print exactly what they printed before this branch, and all 21 tests in tests/studio/*.ps1 pass. * Resolve UUID and MIG GPU masks, and read hipinfo at logical device zero Three more cases from the review, each reproduced in the fixture matrix before being changed. nvidia-smi does not honour CUDA_VISIBLE_DEVICES, so the mask has to be resolved against its physical rows by hand, and only a numeric token was. A UUID mask therefore left the index at 0 and named the first card rather than the visible one. UUIDs are the form NVIDIA recommends over indices, may be abbreviated to any unique leading portion, and a MIG id (MIG-<GPU-UUID>/<gi>/<ci>) embeds one, so a non-numeric token is now looked up against --query-gpu=uuid by prefix, with MIG unwrapped to its parent GPU. A token matching nothing still falls back to row 0. The lookup runs only on the non-numeric path, so the ordinary case costs no extra call and the CSV parse keeps its three documented columns. hipinfo is itself a HIP application, so HIP_VISIBLE_DEVICES / ROCR_VISIBLE_DEVICES have already filtered its output and renumbered the survivors from zero. install.ps1 indexed that output by the physical token as well, applying the mask twice and landing on the wrong device; studio/setup.ps1 has always taken entry 0 and says so in a comment. install.ps1 now matches it. This was previously only an arch selection, which is why it went unnoticed; printing the name made it visible. setup.sh could resolve a marketing name but no gfx target and then drop the name, falling through to a bare "AMD ROCm" while install.sh printed the name. The name-only arm is added below the unsupported-GPU arm, not above it: a card with no ROCm wheels also arrives here with a name, and naming it quietly would drop the warning that training will not run. Matrix is now 80 cases, all completing with no hang; tests/studio/*.ps1 all pass. * Pick amd-smi's market name by device index, and unbreak the hipinfo probe test Two findings from the last review round, both on the previous commits here. The amd-smi fallback took the first MARKET_NAME in the output while the arch was taken at the masked index, so a multi-AMD host with no rocminfo and HIP_VISIBLE_DEVICES=1 paired GPU 0's name with GPU 1's arch. The rocminfo path was already fixed by pairing name to agent, and the PowerShell paths by carrying the index forward, but the shell amd-smi fallback still read only the first name. It now collects every device's name and selects at the same index the arch came from. In the fixture matrix the masked two-GPU case goes from "Radeon RX 7900 XTX (gfx1100)" to "Radeon PRO W7900 (gfx1100)", and the unmasked case still names the XTX. _assert_accepts_partial_hipinfo_output sliced a fixed 1600 characters from the hipinfo probe and asserted the gcnArchName diagnostic was inside it. The name selection added here pushed that diagnostic past the cut, so test_setup_accepts_hipinfo_gcnarchname_on_nonzero_exit and its install.ps1 twin failed against correct code. The slice is now bounded at the catch that closes the probe's own try, which does not move when the parse gains a branch. tests/studio/install/test_rocm_support.py is 492 passed, 1 skipped; the fixture matrix is 82 cases with no hang; tests/studio/*.ps1 all pass. * Resolve opaque MIG UUIDs, and keep the device index when arches repeat Three findings from the last round, all on the previous commits here. Since R470 each MIG instance carries its OWN opaque UUID, MIG-<UUID>, which contains nothing of the parent GPU; only the pre-R470 name embedded one as MIG-<GPU-UUID>/<gi>/<ci>. The unwrap added earlier assumed the legacy form, so a modern MIG mask matched no --query-gpu=uuid row and the banner fell back to GPU 0. The two forms are now split: the legacy one still resolves through the embedded parent, and the opaque one resolves through the GPU nesting in `nvidia-smi -L`, which is the documented way to map an instance back to its card. Two places still recovered a device index from an arch VALUE, which is not unique. On rocminfo the agent lookup exited on the first agent carrying the selected arch, and in the setup.ps1 WMI fallback IndexOf did the same over $nameArches. Two cards of one arch with different names (RX 7900 XTX and PRO W7900 are both gfx1100) then named the first regardless of the mask. Both now keep the index that was actually selected, falling back to the arch match only where a shadowing repick moved the arch off it, so the name and the arch always describe the same device. Found while testing the above rather than by review: the new agent lookup wrote a[n] with n unset, and an unset awk variable subscripts as "" rather than 0, so a[0] was never assigned and the unmasked two-card case named the second GPU. The counter is initialised explicitly now. The sibling snippets use a[n++], where the increment forces numeric context, and were unaffected. Matrix is 88 cases with no hang, PowerShell 36 cases, test_rocm_support.py 492 passed 1 skipped, tests/studio/*.ps1 all passing. * Do not pay the probe timeout twice when nvidia-smi is wedged Detection already runs nvidia-smi -L under the 10s bound, and a host whose driver is wedged still detects as an NVIDIA GPU through /proc/driver/nvidia. The banner then asked the same hung binary for a name and waited out the bound again, so the installer stalled 20s where main stalled 10. Detection now records the timeout (timeout's 124, and the PowerShell runner's own 124) and the banner skips its query when it is set, falling back to the vendor-only wording main already printed. Measured over the 88-case fixture matrix: the wedged case is back to 10s, every other case adds at most one probe process and 25ms. * Do not name an NVIDIA card that CUDA_VISIBLE_DEVICES hides CUDA_VISIBLE_DEVICES=-1 or "" hides every device. The Windows resolver matched neither the numeric nor the MIG form, so -1 fell through to the UUID branch, spent a probe that can never match, and left the index at 0 -- naming row 0 and printing its compute target while CUDA exposes no GPU at all. The shell installers already treat both spellings as all-hidden in _cvd_hides_nvidia. Only the naming is skipped. HasNvidiaSmi still drives wheel selection, as on main, so the banner falls back to the vendor-only wording main already printed rather than claiming a card that is not there. * Judge the CUDA mask by its first entry, and do not guess a CUDA ordinal Two defects in the NVIDIA banner's device selection. CUDA truncates enumeration at the first invalid index, so the documented "2,-1" means "device 2, then stop". Both shell scripts classified the WHOLE mask, saw the minus sign, called it non-numeric and sent a plain ordinal down the UUID lookup, which matched nothing and named row 0. They now classify the first entry, which is the one that selects the device. The PowerShell copies already did this. A numeric entry is a CUDA ordinal, not an nvidia-smi row. CUDA defaults to CUDA_DEVICE_ORDER=FASTEST_FIRST, which puts the fastest card at 0 and leaves the rest unspecified, while nvidia-smi always lists in PCI order. An ordinal therefore identifies a row only when the order is pinned to PCI_BUS_ID, or when the cards are interchangeable and every row gives the same answer anyway. Otherwise the banner keeps the vendor-only wording and reports the driver alone, which is what the AMD path already does when the mask and the records disagree. A UUID or MIG id identifies the device outright, so it is unaffected. * An unresolved GPU identity is not row 0, and a borrowed arch carries its name Two more selection defects. NVIDIA accepts an abbreviated UUID only when it is a unique leading portion, so a prefix matching two cards selects no device at all. The helper returned the first match, and both PowerShell copies stopped at the first hit, so the banner named one of them. They now count matches and resolve only on exactly one. That exposed the same wrong assumption one level up: an identity mask that does not resolve, whether ambiguous or naming a card that is not present, was falling back to row 0. Row 0 is not a fallback for "CUDA selected nothing", it is a different card. Those masks now keep the vendor-only wording. In studio/setup.ps1, an unmappable adapter ahead of a supported one leaves $nameArches shorter than $gpuNames, which skipped the block that moves the banner name onto the adapter the arch came from. A generic integrated Radeon in front of an RX 9070 therefore printed the integrated name against the discrete arch. The source adapter is now recorded while $nameArches is built, so a borrowed arch takes its own card's name with it. * An out-of-range CUDA ordinal selects nothing, not GPU 0 CUDA stops enumerating at the first invalid index, so CUDA_VISIBLE_DEVICES=1 on a one-GPU host exposes no device at all. The row pick clamps an out-of-range index to 0 so the driver version still reads, and the banner then named row 0: a card the process cannot use. An ordinal past the last row now counts as unresolved, the same as an identity mask that matches nothing, so the banner keeps the vendor-only wording. The existing out-of-range fixture did not catch this. It used two different cards under CUDA's default order, so the ordering guard suppressed the name for an unrelated reason and the range bug stayed invisible. The new fixtures pin CUDA_DEVICE_ORDER and use identical cards, which disables that guard and leaves the range check as the only thing that can answer. * Name the adapter that supplied the arch, selected or borrowed The previous fix only moved the banner name when the arch was BORROWED from another adapter. A visible-device mask selecting a supported adapter that sits behind an unmappable one resolves the arch directly, so the borrow never fires, $nameArches is still shorter than $gpuNames, and neither naming branch ran: HIP_VISIBLE_DEVICES=1 over ["AMD Radeon Graphics", "AMD Radeon RX 9070"] printed the integrated name against the discrete arch. One index now records which adapter supplied the arch in either case. It is spelled `if ($pickedName -and $_archSrcIdx -lt 0)` rather than a bare truthiness test because `if ($pickedName) {` is the end anchor TestSetupPs1ShadowingParity slices the borrow block on. A second copy closed that window early and hid the pinned-mask guard from it, which failed the test on the first attempt. A new case pins the occurrence count so the anchor cannot be shadowed again. * Canonicalise the device ordinal before subscripting or comparing with it Self-review turned up two ways a numerically valid ordinal slipped past the checks added over this review. awk subscripts arrays by the STRING form of the key, so a["0000"] is a different cell from a[0]. Rows are stored with a[n++], whose keys are "0", "1", so a CUDA_VISIBLE_DEVICES of "0000" or "01" read an empty cell, the row came back blank and the banner degraded to the vendor wording with no driver line. Six sites across the two scripts, NVIDIA and AMD alike; every one now forces numeric context on the subscript. The bash test builtin parses with strtol and errors on a value wider than a long. An all-digit ordinal that overflows printed a shell diagnostic into the user's terminal and skipped the out-of-range check entirely, so it named row 0, the exact case that check exists to refuse. The ordinal is now clamped to 9999, which is past any real host, so it stays out of range and declines. Eight fixtures pin the non-canonical spellings, with the cards differing and the device order pinned so only the ordinal can decide the outcome. --------- Co-authored-by: danielhanchen <[email protected]>


Why
The GPU line said a different kind of thing per vendor. Two of the three never named the
card, and only one said what it would actually build for:
Every probe already had the answer:
nvidia-smiis resolved and run before this point and was simply never asked for a name.compute_capwas already being read, inGet-NvidiaCu126Verdict, which runs on thecu128/cu130 path to decide a fallback wheel and returns early otherwise, so it was never
available where the banner prints.
$_gpu_disp_mkt/$_setup_mktfortheir own name -> arch inference and never print it.
Hardware detected: ROCm (HIP 7.13.99004) -- AMD Radeon RX 9060 XTSo this is an organisation problem, not a detection one.
What
One shape for every vendor: the device on the
gpuline, its compute target in parentheses,the runtime below.
compute_capis the counterpart of the gfx arch and the driver version the counterpart of theHIP SDK line; both come back from the same query that fetches the name, so this costs no extra
call. Each vendor honours its own visible-device mask when picking which card to name
(
CUDA_VISIBLE_DEVICES,HIP/ROCR_VISIBLE_DEVICES), so a masked run names the card it isactually going to use.
Intel keeps the name alone. There is no counterpart to
gfx1200/sm_89that any probehere already resolves --
IntelGpuLabelcomes from WMI adapter names, and no Xe arch or LevelZero version is in hand. Inventing one to make the column look even seemed worse than the gap.
On the AMD side the name lives in its own variable rather than folded into
$ROCmGpuLabel:that one doubles as the input to the name -> arch tables, so changing its shape would move
wheel selection. It is read from hipinfo's per-device
Name:, amd-smi's Market Name, or theWMI adapter name, always at the index the arch pick landed on and only when the name and arch
lists line up -- so a format change can mislabel nothing, and the arch that selects the wheel
is never taken from it.
NVIDIA CSV fields are split from the right, because
nvidia-smidoes not quote its output anda comma in a device name would otherwise shift every column. A row with fewer fields than
requested falls back to using the whole row as the name, rather than reporting a compute
capability as a driver version.
Also stops setup.ps1 reporting a known ROCm version as unknown. It probed hipconfig then
amd-smi and, on a runtime-only layout with neither on PATH, printed
one line after the summary printed
C:\Program Files\AMD\ROCm\7.1. The SDK root is versioned,so that is now the last-resort source.
Testing
All four scripts parse (
Parser::ParseFilefor .ps1,bash -nfor .sh). The awk fieldsplitting is covered for a plain row, a comma-in-name row, and a short row, and the
index-picker for a masked device and an out-of-range index.
Not yet run end to end on real hardware. The hipinfo
Name:, amd-smi Market Name andnvidia-smi CSV parses are written against documented output shapes, not observed ones. The
guards mean a mismatch falls back to the old text rather than naming the wrong card, so the
failure mode is "no change" rather than "wrong card" -- but it wants a run on an AMD box and an
NVIDIA box before merge.
Not included
setup.ps1 still re-probes the GPU after install already did, so the block prints twice. It has
to work standalone, so consuming install's result is a contract change rather than a dedup.
Before / after evidence (added by @danielhanchen)
The
gpuline on fifteen host shapes. Every line below is real captured output from theinstallers' own banner block, spliced back together with each file's real functions and
shell options and driven against fake
nvidia-smi/rocminfo/amd-smiprobes; nothingis retyped. BEFORE is the merge base with current main,
66a38c7c2; AFTER is thehead,
3d289eb4e. Both sides are re-run in the same process against the identical fixture,so a row that comes out identical really is identical.
Reading the rows:
sm_target and the driver inplace of "NVIDIA GPU detected". The UUID row shows the mask honoured, naming the second
card rather than row 0, since
nvidia-smiitself ignoresCUDA_VISIBLE_DEVICES.rocminfolistsfirst. Strix Halo is the sharp case: the CPU agent's own marketing name contains "Radeon
8060S", so naming the wrong agent there still looks plausible.
surviving. The arch alone cannot identify the device, so the name and the arch are taken
from the same per-agent record.
review added. They come in pairs, same host, one thing changed, so the rule is visible
rather than asserted. An ordinal past the last card selects nothing, because CUDA stops
enumerating at the first invalid index; in range on that same host it names. An
abbreviated UUID is valid only when unique, so one matching both cards selects nothing. A
numeric entry is a CUDA ordinal, and CUDA's default
FASTEST_FIRSTleaves everythingafter device 0 unspecified while
nvidia-smilists in PCI order, so it identifies a rowonly when the order is pinned to
PCI_BUS_IDor the cards are interchangeable. In each ofthese the banner keeps the vendor-only wording and reports the driver alone.
nvidia-smistill printsthe vendor-only line and, after the timeout fix, still costs one 10s bound rather than two.
The CPU-only host is untouched.
The renderer fails rather than emitting a composite unless the set of identical rows is
exactly those two controls, because two halves that agree is the normal failure mode for
evidence like this.
Backing numbers at
3d289eb4e: 126 shell fixture cases acrossinstall.shandstudio/setup.sh, no failures, no hangs; 85 PowerShell cases;test_rocm_support.py+test_installer_av_shapes.py+test_formatter_fixed_point.py635 passed, 2 skipped;tests/sh/GPU suites and the installertests/studio/*.ps1suites passing.Scope: this composite is the shell side. The Windows banner is the same change in
install.ps1andstudio/setup.ps1, covered by the PowerShell suite and by the Windowsparity and no-compiler lanes in CI rather than by a picture.