Skip to content

Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.

Unsloth Studio Installer: improve GPU print details (NVIDIA, Intel, AMD) (#8762)

Leo Borcherding32c01c8ad0bc
diff --git a/install.ps1 b/install.ps1
index 8dd06b2e111..9a4a880bf2f 100644
--- a/install.ps1
+++ b/install.ps1
@@ -5386,9 +5386,17 @@ exit 0
}
# ── A driverless nvidia-smi exits 0 listing no GPU, so require a "GPU <n>:" row. ──
+ # 124 is what Invoke-NvidiaSmiBounded reports when it had to kill the probe. Recorded
+ # so the banner below can skip a second query: detection already waited out the full
+ # bound on this binary, and asking a hung nvidia-smi again only doubles the stall.
+ $script:NvidiaSmiWedged = $false
+
function Test-NvidiaSmiHasGpu {
param([Parameter(Mandatory = $true)][string]$Exe)
$out = Invoke-NvidiaSmiBounded $Exe @('-L')
+ # Assigned, not OR-ed: the fallback loop tries several paths, and what matters is
+ # whether the binary it settled on answered, not whether an earlier one hung.
+ $script:NvidiaSmiWedged = ($LASTEXITCODE -eq 124)
return ($LASTEXITCODE -eq 0 -and $out -match '(?m)^GPU\s+\d+:')
}
@@ -5534,6 +5542,9 @@ exit 0
# ── Detect GPU (robust: PATH + hardcoded fallback paths, mirrors setup.ps1) ──
$HasNvidiaSmi = $false
$NvidiaSmiExe = $null
+ $NvidiaGpuName = $null
+ $NvidiaSmArch = $null
+ $NvidiaDriverVersion = $null
try {
$nvSmiCmd = Get-Command nvidia-smi -ErrorAction SilentlyContinue
if ($nvSmiCmd -and (Test-NvidiaSmiHasGpu $nvSmiCmd.Source)) {
@@ -5557,10 +5568,126 @@ exit 0
$HasNvidiaSmi = $true
Write-StudioLine " NVIDIA GPU found through the driver library; nvidia-smi is unavailable" -ForegroundColor Gray
}
+ # nvidia-smi was already resolved above and never asked which card it found, so the
+ # banner said "NVIDIA GPU detected" on every NVIDIA host alike. compute_cap is the
+ # counterpart of the gfx arch shown for AMD, and the driver version the counterpart of
+ # the HIP SDK line; one query returns all three. Honour the same visible-device index
+ # the AMD probes do.
+ #
+ # A mask of "" or -1 hides every device, so it selects nothing to name. It is also not
+ # a UUID, and letting it reach the prefix match below would spend a second probe that
+ # can never match and then name row 0 anyway. $HasNvidiaSmi still drives wheel
+ # selection here, as it does on main, so only the naming is skipped: the banner keeps
+ # the vendor-only wording rather than claiming a card CUDA does not expose.
+ $nvMaskHidesAll = $false
+ if ($null -ne $env:CUDA_VISIBLE_DEVICES) {
+ $nvMask = ($env:CUDA_VISIBLE_DEVICES -replace '\s', '')
+ $nvMaskHidesAll = ($nvMask -eq '' -or $nvMask -eq '-1')
+ }
+ if ($HasNvidiaSmi -and $NvidiaSmiExe -and -not $script:NvidiaSmiWedged -and -not $nvMaskHidesAll) {
+ try {
+ # Through the bounded runner, like every other nvidia-smi call here: a
+ # wedged driver blocks nvidia-smi indefinitely, and a bare `&` call has
+ # nothing to time it out. -StdoutOnly because driver warnings on stderr
+ # would corrupt this machine-readable CSV.
+ $nvOut = Invoke-NvidiaSmiBounded $NvidiaSmiExe @('--query-gpu=name,compute_cap,driver_version', '--format=csv,noheader') -StdoutOnly
+ $nvRows = @($nvOut -split '\r?\n' | ForEach-Object { $_.Trim() } | Where-Object { $_ })
+ if ($nvRows.Count -gt 0) {
+ # nvidia-smi ignores CUDA_VISIBLE_DEVICES, so the mask is resolved against
+ # its physical rows here. A non-numeric token is a GPU UUID, or a MIG id
+ # (MIG-<GPU-UUID>/<gi>/<ci>) embedding one; NVIDIA allows the UUID to be
+ # abbreviated to any unique leading portion, so it is matched on prefix.
+ $nvIdx = 0
+ $nvTok = if ($env:CUDA_VISIBLE_DEVICES) { ($env:CUDA_VISIBLE_DEVICES -split ',')[0].Trim() } else { '' }
+ # True while nothing has IDENTIFIED a device: a plain ordinal.
+ $nvByOrdinal = $true
+ # Set when an identity mask was given but did not resolve, which means CUDA
+ # selected NO device. Row 0 is not a fallback for that.
+ $nvUnresolved = $false
+ if ($nvTok -match '^\d+$') {
+ $nvIdx = [int]$nvTok
+ } elseif ($nvTok -like 'MIG-*' -and $nvTok -notlike 'MIG-GPU-*') {
+ # R470 and later give each MIG instance its OWN opaque UUID, which
+ # carries nothing of the parent, so --query-gpu=uuid can never match
+ # it. `nvidia-smi -L` nests the instances under their GPU.
+ $nvListOut = Invoke-NvidiaSmiBounded $NvidiaSmiExe @('-L') -StdoutOnly
+ $cur = 0
+ $nvByOrdinal = $false
+ $nvFound = $false
+ foreach ($ln in ($nvListOut -split '\r?\n')) {
+ if ($ln -match '^GPU\s+(\d+):') { $cur = [int]$Matches[1] }
+ if ($ln -match [regex]::Escape($nvTok)) { $nvIdx = $cur; $nvFound = $true; break }
+ }
+ if (-not $nvFound) { $nvUnresolved = $true }
+ } elseif ($nvTok) {
+ # Pre-R470 MIG names embed the parent UUID: MIG-<GPU-UUID>/<gi>/<ci>.
+ if ($nvTok -like 'MIG-GPU-*') { $nvTok = ($nvTok.Substring(4) -split '/')[0] }
+ $nvUuidOut = Invoke-NvidiaSmiBounded $NvidiaSmiExe @('--query-gpu=uuid', '--format=csv,noheader') -StdoutOnly
+ $nvUuids = @($nvUuidOut -split '\r?\n' | ForEach-Object { $_.Trim() } | Where-Object { $_ })
+ $nvByOrdinal = $false
+ $nvFound = $false
+ # NVIDIA accepts an abbreviation only when it is a UNIQUE leading portion, so
+ # a prefix matching two cards selects NO device. Collect, do not stop at the
+ # first hit, or the banner names one of them.
+ $nvMatches = @()
+ for ($i = 0; $i -lt $nvUuids.Count; $i++) {
+ if ($nvUuids[$i].StartsWith($nvTok, [System.StringComparison]::OrdinalIgnoreCase)) { $nvMatches += $i }
+ }
+ if ($nvMatches.Count -eq 1) { $nvIdx = $nvMatches[0]; $nvFound = $true }
+ if (-not $nvFound) { $nvUnresolved = $true }
+ }
+ $nvRow = if ($nvIdx -lt $nvRows.Count) { $nvRows[$nvIdx] } else { $nvRows[0] }
+ # A numeric entry is a CUDA ordinal, and CUDA's default
+ # CUDA_DEVICE_ORDER=FASTEST_FIRST puts the fastest card at 0 and leaves the
+ # rest unspecified, while nvidia-smi always lists in PCI order. So an ordinal
+ # identifies an nvidia-smi 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. Compared on name and compute_cap, not the driver, which is host-wide.
+ # CUDA stops enumerating at the first invalid index, so an ordinal past the last
+ # row exposes NO device. The row pick below clamps to 0 so the driver still
+ # reads, but row 0 is not the selected card -- nothing is.
+ if ($nvByOrdinal -and $nvIdx -ge $nvRows.Count) { $nvUnresolved = $true }
+ $nvAmbiguous = $nvUnresolved
+ if ($nvByOrdinal -and -not $nvAmbiguous) {
+ $nvOrder = (("$env:CUDA_DEVICE_ORDER") -replace '\s', '').ToUpperInvariant()
+ $nvModels = @($nvRows | ForEach-Object { $_ -replace ',[^,]*$', '' } |
+ Sort-Object -Unique).Count
+ $nvAmbiguous = ($nvOrder -ne 'PCI_BUS_ID' -and $nvModels -gt 1)
+ }
+ # Split from the right: nvidia-smi does not quote, so a comma in a device
+ # name would otherwise shift every field.
+ $nvParts = $nvRow -split ','
+ if ($nvParts.Count -ge 3) {
+ $NvidiaDriverVersion = $nvParts[-1].Trim()
+ $nvComputeCap = $nvParts[-2].Trim()
+ $NvidiaGpuName = ($nvParts[0..($nvParts.Count - 3)] -join ',').Trim()
+ if ($nvComputeCap -match '^(\d+)\.(\d+)$') {
+ $NvidiaSmArch = "sm_" + (([int]$Matches[1] * 10) + [int]$Matches[2])
+ }
+ } else {
+ # Short row: field 1 only. Taking the whole row would print the
+ # compute capability as part of the name ("RTX 4090, 8.9").
+ $NvidiaGpuName = $nvParts[0].Trim()
+ }
+ # An nvidia-smi too old for a field answers with a placeholder rather
+ # than failing (the 470 branch has no compute_cap at all).
+ $nvPlaceholders = @('[N/A]', '[Not Supported]', '[Unknown Error]')
+ if ($nvPlaceholders -contains $NvidiaGpuName) { $NvidiaGpuName = $null }
+ if ($nvPlaceholders -contains $NvidiaDriverVersion) { $NvidiaDriverVersion = $null }
+ # Keep the driver, drop the identity: the banner falls back to the vendor-only
+ # wording rather than claiming a card that may not be the one CUDA will use.
+ if ($nvAmbiguous) { $NvidiaGpuName = $null; $NvidiaSmArch = $null }
+ }
+ } catch {}
+ }
# ── AMD ROCm detection (Windows) — mirrors setup.ps1 ──
$HasROCm = $false
$HipSdkInstalled = $false # HIP SDK binary found (independent of device accessibility)
$ROCmGpuLabel = $null
+ # Marketing name on its own ("AMD Radeon RX 9060 XT"), never decorated. Kept apart from
+ # $ROCmGpuLabel because that one doubles as the input to the name -> arch tables below;
+ # this one only ever reaches the banner.
+ $ROCmGpuName = $null
$ROCmVersion = $null
$ROCmGfxArch = $null
# Declared with its neighbours, not inside the block below: the arms that read
@@ -5638,10 +5765,23 @@ exit 0
# Once the arch is printed, keep the ROCm wheel path.
$HasROCm = $true
$_hipAllArches = @([regex]::Matches($hipOut, "(?im)^\s*gcnArchName\s*:\s*(\S+)") | ForEach-Object { ($_.Groups[1].Value -split ':')[0].Trim().ToLower() })
- $_hipVisIdx = if ($env:HIP_VISIBLE_DEVICES -match '^\d') { [int]($env:HIP_VISIBLE_DEVICES -split ',')[0] } elseif ($env:ROCR_VISIBLE_DEVICES -match '^\d') { [int]($env:ROCR_VISIBLE_DEVICES -split ',')[0] } else { 0 }
+ # hipinfo prints "Name:" per device alongside gcnArchName. Anchored so
+ # gcnArchName cannot match. Only trusted when the two lists line up, so a
+ # format change can mislabel nothing -- the arch (which picks the wheel)
+ # never reads this.
+ $_hipAllNames = @([regex]::Matches($hipOut, "(?im)^\s*Name\s*:\s*(.+?)\s*$") | ForEach-Object { $_.Groups[1].Value.Trim() })
if ($_hipAllArches.Count -gt 0) {
- $ROCmGfxArch = if ($_hipVisIdx -lt $_hipAllArches.Count) { $_hipAllArches[$_hipVisIdx] } else { $_hipAllArches[0] }
+ # Entry 0, NOT the visible-device token, and the same choice
+ # studio/setup.ps1 already makes: hipinfo is itself a HIP
+ # application, so HIP/ROCR_VISIBLE_DEVICES has already filtered
+ # its output and renumbered the survivors from 0. Indexing that
+ # by the physical token applies the mask twice and lands on the
+ # wrong card, which the banner now shows by name.
+ $ROCmGfxArch = $_hipAllArches[0]
$ROCmGpuLabel = "AMD ROCm ($ROCmGfxArch)"
+ if ($_hipAllNames.Count -eq $_hipAllArches.Count) {
+ $ROCmGpuName = $_hipAllNames[0]
+ }
} else {
$ROCmGpuLabel = "AMD ROCm"
}
@@ -5673,19 +5813,31 @@ exit 0
$_smiVisIdx = if ($env:HIP_VISIBLE_DEVICES -match '^\d') { [int]($env:HIP_VISIBLE_DEVICES -split ',')[0] } elseif ($env:ROCR_VISIBLE_DEVICES -match '^\d') { [int]($env:ROCR_VISIBLE_DEVICES -split ',')[0] } else { 0 }
# Attempt 1: newer amd-smi versions embed the gfx arch in list output.
$_smiGfxTokens = @([regex]::Matches($smiOut, "(?i)\b(gfx\d+[a-z]?)\b") | ForEach-Object { $_.Groups[1].Value.ToLower() })
+ # Market names, when this amd-smi prints them, indexed like the gfx
+ # tokens above. Banner only; the arch that selects the wheel is never
+ # taken from here.
+ $_smiNames = @([regex]::Matches($smiOut, "(?im)Market.?Name\s*[:\|]\s*([^\r\n]+)") | ForEach-Object { $_.Groups[1].Value.Trim() })
if ($_smiGfxTokens.Count -gt 0) {
$ROCmGfxArch = if ($_smiVisIdx -lt $_smiGfxTokens.Count) { $_smiGfxTokens[$_smiVisIdx] } else { $_smiGfxTokens[0] }
$ROCmGpuLabel = "AMD ROCm ($ROCmGfxArch)"
+ if ($_smiNames.Count -eq $_smiGfxTokens.Count) {
+ $ROCmGpuName = if ($_smiVisIdx -lt $_smiNames.Count) { $_smiNames[$_smiVisIdx] } else { $_smiNames[0] }
+ }
} else {
# Attempt 2: 'static --asic' exposes the GFX target on ROCm 6+.
$smiAsicOut = ""
try { $smiAsicOut = Invoke-AmdSmiNoElevate $amdSmiExe.Source @('static','--asic') } catch {}
$_asicGfxTokens = @([regex]::Matches($smiAsicOut, "(?i)\b(gfx\d+[a-z]?)\b") | ForEach-Object { $_.Groups[1].Value.ToLower() })
+ $_asicNames = @([regex]::Matches($smiAsicOut, "(?im)Market.?Name\s*[:\|]\s*([^\r\n]+)") | ForEach-Object { $_.Groups[1].Value.Trim() })
if ($_asicGfxTokens.Count -gt 0) {
$ROCmGfxArch = if ($_smiVisIdx -lt $_asicGfxTokens.Count) { $_asicGfxTokens[$_smiVisIdx] } else { $_asicGfxTokens[0] }
$ROCmGpuLabel = "AMD ROCm ($ROCmGfxArch)"
- } elseif ($smiAsicOut -match "(?im)Market.?Name\s*[:\|]\s*([^\r\n]+)") {
- $ROCmGpuLabel = "AMD ROCm ($($Matches[1].Trim()))"
+ if ($_asicNames.Count -eq $_asicGfxTokens.Count) {
+ $ROCmGpuName = if ($_smiVisIdx -lt $_asicNames.Count) { $_asicNames[$_smiVisIdx] } else { $_asicNames[0] }
+ }
+ } elseif ($_asicNames.Count -gt 0) {
+ $ROCmGpuName = if ($_smiVisIdx -lt $_asicNames.Count) { $_asicNames[$_smiVisIdx] } else { $_asicNames[0] }
+ $ROCmGpuLabel = "AMD ROCm ($ROCmGpuName)"
} else {
$ROCmGpuLabel = "AMD ROCm"
}
@@ -5715,7 +5867,7 @@ exit 0
$healthyAdapters = @($amdAdapters | Where-Object {
($null -eq $_.ConfigManagerErrorCode) -or ($_.ConfigManagerErrorCode -eq 0) })
$wmiGpu = @(if ($healthyAdapters.Count -gt 0) { $healthyAdapters } else { $amdAdapters })[0]
- if ($wmiGpu) { $ROCmGpuLabel = $wmiGpu.Name }
+ if ($wmiGpu) { $ROCmGpuLabel = $wmiGpu.Name; $ROCmGpuName = $wmiGpu.Name }
} catch {}
}
# Peer names for the REPORT ONLY, kept apart from the scan above: that one feeds the
@@ -6083,19 +6235,38 @@ exit 0
}
}
+ # One banner string for the AMD arms below. The arch alone ("AMD ROCm (gfx1200)") named a
+ # target nobody shopping for a GPU recognises, while every probe above already had the
+ # marketing name in hand and threw it away; the backend then prints it at startup, so the
+ # installer was the only place it went missing.
+ $ROCmGpuDisplay =
+ if ($ROCmGpuName -and $ROCmGfxArch) { "$ROCmGpuName ($ROCmGfxArch)" }
+ elseif ($ROCmGpuName) { $ROCmGpuName }
+ elseif ($ROCmGfxArch) { "AMD ROCm ($ROCmGfxArch)" }
+ else { $ROCmGpuLabel }
+
+ # Same shape for every vendor: the device on the step line, its compute target in
+ # parentheses, the runtime below. Intel has no counterpart to gfx1200 / sm_89 that any
+ # probe here already resolves, so it gets the name alone rather than an invented one.
+ $NvidiaGpuDisplay =
+ if ($NvidiaGpuName -and $NvidiaSmArch) { "$NvidiaGpuName ($NvidiaSmArch)" }
+ elseif ($NvidiaGpuName) { $NvidiaGpuName }
+ else { "NVIDIA GPU detected" }
+ $IntelGpuDisplay = if ($IntelGpuLabel) { $IntelGpuLabel } else { "Intel GPU detected" }
+
if ($HasNvidiaSmi) {
- step "gpu" "NVIDIA GPU detected"
+ step "gpu" $NvidiaGpuDisplay
+ if ($NvidiaDriverVersion) { substep "Driver: $NvidiaDriverVersion" }
} elseif ($script:IsIntelXpu) {
# Ranks above every AMD branch: only true when AMD gets no GPU wheel ($AmdHasGpuWheels
# gates the scan above), so those branches would all end on CPU.
- step "gpu" "Intel GPU detected" "Green"
- substep "$IntelGpuLabel"
+ step "gpu" $IntelGpuDisplay "Green"
# The reroute below prints the index: only it knows the mirror URL and any pin.
} elseif ($HasROCm -and -not $ROCmUnsupportedGfxArch) {
# Guarded like the HIP SDK arm below: amd-smi can report a GPU with no gfx token
# and only a market name, setting $HasROCm without an arch. Calling that card
# "AMD ROCm" contradicts the wheel note this run also prints.
- step "gpu" $ROCmGpuLabel
+ step "gpu" $ROCmGpuDisplay
$hipSdkPath = if ($env:HIP_PATH) { $env:HIP_PATH } elseif ($env:ROCM_PATH) { $env:ROCM_PATH } else { "on system PATH" }
substep "HIP SDK: $hipSdkPath"
if ($ROCmVersionFull) { substep "hipconfig: $ROCmVersionFull" }
@@ -6112,7 +6283,9 @@ exit 0
substep " Ensure the ROCm compute driver is installed alongside the display driver:" "Yellow"
substep " https://rocm.docs.amd.com/en/latest/deploy/windows/index.html" "Yellow"
} elseif ($ROCmGfxArch) {
- step "gpu" "AMD ROCm ($ROCmGfxArch)" "Cyan"
+ # Known arch: Unsloth setup installs AMD's bundled-runtime ROCm PyTorch wheels
+ # (repo.amd.com), which ship their own runtime -- HIP SDK optional.
+ step "gpu" $ROCmGpuDisplay "Cyan"
substep "Detected: $ROCmGpuLabel" "Cyan"
substep "GPU PyTorch uses AMD's bundled-runtime ROCm wheels -- HIP SDK not required (optional)." "Cyan"
} elseif ($ROCmUnsupportedGfxArch) {
diff --git a/install.sh b/install.sh
index 28bc7be533a..b80f8f0ec00 100755
--- a/install.sh
+++ b/install.sh
@@ -2678,6 +2678,7 @@ PY
# ── NVIDIA usable-GPU helper ──
# nvidia-smi -L primary, /proc/driver/nvidia/gpus/ fallback, driver library last; a hidden GPU is NOT usable.
_has_usable_nvidia_gpu() {
+ _nv_smi_wedged=""
if _cvd_hides_nvidia; then
return 1
fi
@@ -2688,7 +2689,15 @@ _has_usable_nvidia_gpu() {
_nvsmi="/usr/bin/nvidia-smi"
fi
if [ -n "$_nvsmi" ]; then
- if _run_bounded "$_nvsmi" -L 2>/dev/null | awk '/^GPU[[:space:]]+[0-9]+:/{found=1} END{exit !found}'; then
+ # Captured rather than piped so `timeout`'s own 124 stays visible. A wedged
+ # driver still detects as a GPU through /proc below, and the banner must not
+ # then pay the 10s bound a second time asking a hung nvidia-smi for a name.
+ _nv_l_rc=0
+ _nv_l_out=$(_run_bounded "$_nvsmi" -L 2>/dev/null) || _nv_l_rc=$?
+ if [ "$_nv_l_rc" = "124" ]; then
+ _nv_smi_wedged=1
+ fi
+ if printf '%s\n' "$_nv_l_out" | awk '/^GPU[[:space:]]+[0-9]+:/{found=1} END{exit !found}'; then
return 0
fi
fi
@@ -2700,6 +2709,130 @@ _has_usable_nvidia_gpu() {
return 1
}
+# Row index of the GPU whose UUID starts with $1, or empty. NVIDIA allows a UUID to
+# be abbreviated to any unique leading portion, hence the prefix match.
+_nv_idx_from_uuid() {
+ # NVIDIA accepts an abbreviation only when it is a UNIQUE leading portion, so a
+ # prefix matching two cards selects NO device. Counting instead of stopping at the
+ # first hit keeps the banner from naming one of them.
+ _run_bounded "$_nvsmi" --query-gpu=uuid --format=csv,noheader 2>/dev/null \
+ | awk -v want="$1" '
+ NF { gsub(/^[[:space:]]+|[[:space:]]+$/,""); if (index($0, want) == 1) { hits++; idx = NR-1 } }
+ END { if (hits == 1) print idx }' || true
+}
+
+# Resolves the banner's NVIDIA fields into _nv_name / _nv_sm / _nv_driver, each empty
+# when it could not be read. compute_cap is the counterpart of the gfx arch shown for
+# AMD and the driver version the counterpart of the hipconfig line, so one query gets
+# all three.
+#
+# Bounded, and fed the executable _has_usable_nvidia_gpu already resolved into $_nvsmi.
+# Both matter: a wedged driver blocks nvidia-smi indefinitely (the reason _run_bounded
+# exists), and detection also succeeds via /usr/bin/nvidia-smi off PATH or via
+# /proc/driver/nvidia/gpus with no nvidia-smi at all -- re-resolving with `command -v`
+# would silently skip the name on exactly those hosts.
+_nv_banner_fields() {
+ _nv_name=""; _nv_sm=""; _nv_driver=""; _nv_row=""; _nv_cc=""; _nv_ambiguous=""
+ [ -n "${_nvsmi:-}" ] || return 0
+ # Detection already waited out the full bound on this binary. Asking again cannot
+ # succeed and would double the stall, so the banner keeps the vendor-only wording.
+ [ -z "${_nv_smi_wedged:-}" ] || return 0
+ # nvidia-smi ignores CUDA_VISIBLE_DEVICES, so its rows are the physical devices and
+ # the mask has to be resolved against them by hand.
+ _nv_idx=0
+ # Set while nothing has IDENTIFIED a device: an ordinal, or a failed identity lookup
+ # that fell back to one. Only an ordinal is order-dependent, so only it needs the
+ # CUDA_DEVICE_ORDER check below.
+ _nv_by_ordinal=1
+ _nv_vis="${CUDA_VISIBLE_DEVICES:-}"
+ # Only the FIRST entry selects the device, and only IT decides the form of the mask.
+ # CUDA truncates enumeration at the first invalid index, so the documented `2,-1`
+ # means "device 2, then stop"; classifying the whole string would see the `-1`, call
+ # it non-numeric, and send a plain ordinal down the UUID path.
+ _nv_tok="${_nv_vis%%,*}"
+ case "$_nv_tok" in
+ '') ;;
+ *[!0-9]*)
+ # A non-numeric mask names a device rather than indexing one.
+ _nv_by_ordinal=""
+ case "$_nv_tok" in
+ MIG-GPU-*)
+ # Pre-R470 MIG name, MIG-<GPU-UUID>/<gi>/<ci>: the parent UUID is
+ # embedded, so it still matches a --query-gpu=uuid row.
+ _nv_tok="${_nv_tok#MIG-}"; _nv_tok="${_nv_tok%%/*}"
+ _nv_idx=$(_nv_idx_from_uuid "$_nv_tok") ;;
+ MIG-*)
+ # R470 and later give each MIG instance its OWN opaque UUID, which
+ # carries nothing of the parent, so --query-gpu=uuid can never match
+ # it. `nvidia-smi -L` nests the instances under their GPU, which is
+ # the documented way to map one back to the card it lives on.
+ _nv_idx=$(_run_bounded "$_nvsmi" -L 2>/dev/null | awk -v want="$_nv_tok" '
+ /^GPU[[:space:]]+[0-9]+:/ { cur = $2 + 0 }
+ index($0, want) > 0 { print cur; exit }' || true) ;;
+ *)
+ _nv_idx=$(_nv_idx_from_uuid "$_nv_tok") ;;
+ esac
+ # An identity mask that does not resolve means CUDA selected NO device: an
+ # abbreviation short enough to match two cards, or a UUID for a card that is
+ # not here. Row 0 is not a fallback for that -- it is a different card.
+ case "$_nv_idx" in ''|*[!0-9]*) _nv_idx=0; _nv_ambiguous=1 ;; esac
+ ;;
+ *) _nv_idx="$_nv_tok" ;;
+ esac
+ # Canonicalise the ordinal before anything compares or subscripts with it.
+ # `[` parses with strtol and ERRORS on a value wider than a long, printing a
+ # shell diagnostic and skipping the range check below, so an absurd ordinal
+ # would have named row 0. Clamped rather than rejected: 9999 is past any real
+ # host, so it stays out of range and declines, which is the right answer.
+ _nv_idx=$(printf '%s' "$_nv_idx" \
+ | awk '{ n = $0 + 0; if (n < 0) n = 0; if (n > 9999) n = 9999; printf "%d", n }')
+ _nv_all=$(_run_bounded "$_nvsmi" --query-gpu=name,compute_cap,driver_version --format=csv,noheader 2>/dev/null || true)
+ _nv_row=$(printf '%s\n' "$_nv_all" \
+ | awk -v idx="$_nv_idx" 'NF { a[n++]=$0 } END { if(idx>=n) idx=0; if(n>0) print a[idx+0] }')
+ [ -n "$_nv_row" ] || return 0
+ # A numeric entry is a CUDA ordinal, and CUDA's default CUDA_DEVICE_ORDER=FASTEST_FIRST
+ # puts the fastest card at 0 and leaves the rest "unspecified", while nvidia-smi always
+ # lists in PCI order. So an ordinal identifies an nvidia-smi 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 naming one is a guess, and the AMD path above already
+ # refuses that rather than name a card the mask did not select. Compared on name and
+ # compute_cap, not the driver, which is host-wide and identical on every row.
+ # CUDA stops enumerating at the first invalid index, so an ordinal past the last
+ # row exposes NO device at all. The awk above clamps to row 0 so the driver still
+ # reads, but row 0 is not the selected card -- nothing is.
+ _nv_rowcount=$(printf '%s\n' "$_nv_all" | awk 'NF { n++ } END { print n+0 }')
+ if [ -n "$_nv_by_ordinal" ] && [ "$_nv_idx" -ge "$_nv_rowcount" ]; then
+ _nv_ambiguous=1
+ fi
+ if [ -n "$_nv_by_ordinal" ]; then
+ _nv_order=$(printf '%s' "${CUDA_DEVICE_ORDER:-}" | tr '[:lower:]' '[:upper:]' | tr -d '[:space:]')
+ _nv_models=$(printf '%s\n' "$_nv_all" \
+ | awk -F, 'NF { k=$0; sub(/,[^,]*$/,"",k); if (!(k in s)) { s[k]; n++ } } END { print n+0 }')
+ if [ "$_nv_order" != "PCI_BUS_ID" ] && [ "$_nv_models" -gt 1 ]; then
+ _nv_ambiguous=1
+ fi
+ fi
+ # Split from the right: nvidia-smi does not quote, so a comma in a device name
+ # would otherwise shift every field.
+ _nv_driver=$(printf '%s' "$_nv_row" | awk -F, 'NF>=3 { gsub(/^[[:space:]]+|[[:space:]]+$/,"",$NF); print $NF }')
+ _nv_cc=$(printf '%s' "$_nv_row" | awk -F, 'NF>=3 { gsub(/^[[:space:]]+|[[:space:]]+$/,"",$(NF-1)); print $(NF-1) }')
+ _nv_name=$(printf '%s' "$_nv_row" | awk -F, 'NF>=3 { out=$1; for(i=2;i<=NF-2;i++) out=out","$i; gsub(/^[[:space:]]+|[[:space:]]+$/,"",out); print out }')
+ # Short row: keep field 1 only. Taking the whole row would print the compute
+ # capability as part of the device name ("RTX 4090, 8.9").
+ [ -n "$_nv_name" ] || _nv_name=$(printf '%s' "$_nv_row" | awk -F, '{ gsub(/^[[:space:]]+|[[:space:]]+$/,"",$1); print $1 }')
+ # An nvidia-smi too old for a field answers with a placeholder rather than failing
+ # (the 470 branch has no compute_cap at all). "[N/A]" is not a name.
+ case "$_nv_name" in '[N/A]'|'[Not Supported]'|'[Unknown Error]') _nv_name="" ;; esac
+ case "$_nv_driver" in '[N/A]'|'[Not Supported]'|'[Unknown Error]') _nv_driver="" ;; esac
+ # Keep the driver, drop the identity: the banner falls back to "NVIDIA GPU detected"
+ # rather than claiming a card that may not be the one CUDA will use.
+ if [ -n "$_nv_ambiguous" ]; then _nv_name=""; _nv_cc=""; fi
+ case "$_nv_cc" in
+ [0-9]*.[0-9]*) _nv_sm="sm_$(printf '%s' "$_nv_cc" | awk -F. '{ print ($1*10)+$2 }')" ;;
+ esac
+ return 0
+}
+
# Strix Halo ROCm-on-WSL needs Ubuntu 24.04: re-run in one, else CPU. Never create a distro.
_maybe_reroute_strixhalo_to_2404() {
[ "${OS:-}" = "wsl" ] || return 0
@@ -5337,7 +5470,17 @@ tauri_diag_marker "$_TAURI_GPU_BRANCH" "$_TAURI_TORCH_INDEX_FAMILY"
# ── GPU detection summary (mirrors install.ps1 step "gpu" block) ──
if _has_usable_nvidia_gpu; then
- step "gpu" "NVIDIA GPU detected"
+ _nv_banner_fields
+ if [ -n "$_nv_name" ] && [ -n "$_nv_sm" ]; then
+ step "gpu" "$_nv_name ($_nv_sm)"
+ elif [ -n "$_nv_name" ]; then
+ step "gpu" "$_nv_name"
+ else
+ step "gpu" "NVIDIA GPU detected"
+ fi
+ # An `if`, not `[ ... ] && substep ...`: the AND-list form leaves a non-zero status
+ # behind on the common path where there is no driver string to print.
+ if [ -n "$_nv_driver" ]; then substep "Driver: $_nv_driver"; fi
elif case "$TORCH_INDEX_URL" in */rocm*|*/gfx*) true ;; *) false ;; esac; then
# Probe gfx arch for the display label, honouring HIP_VISIBLE_DEVICES
_ensure_rocm_probe_env
@@ -5382,14 +5525,14 @@ elif case "$TORCH_INDEX_URL" in */rocm*|*/gfx*) true ;; *) false ;; esac; then
if [ -n "$_gpu_disp_records" ]; then
# Records already preserve device ordinals, including duplicate arches.
_gpu_disp_record=$(printf '%s\n' "$_gpu_disp_records" | awk -v idx="$_gpu_vis_idx" \
- 'NF { a[n++]=$0 } END { if(idx>=n) idx=0; if(n>0) print a[idx] }')
+ 'NF { a[n++]=$0 } END { if(idx>=n) idx=0; if(n>0) print a[idx+0] }')
_gpu_disp_gfx=${_gpu_disp_record%%|*}
_gpu_disp_mkt=${_gpu_disp_record#*|}
fi
# Only pre-TARGET_GRAPHICS_VERSION amd-smi lands here: names but no arch in the record.
if [ -z "$_gpu_disp_gfx" ]; then
_gpu_disp_gfx=$(printf '%s\n' "$_gpu_disp_gfx_all" | awk -v idx="$_gpu_vis_idx" \
- 'NF && !seen[$0]++ { a[n++]=$0 } END { if(idx>=n) idx=0; if(n>0) print a[idx] }')
+ 'NF && !seen[$0]++ { a[n++]=$0 } END { if(idx>=n) idx=0; if(n>0) print a[idx+0] }')
fi
# UNSLOTH_ROCM_GFX_ARCH env override (mirrors install.ps1)
if [ -n "${UNSLOTH_ROCM_GFX_ARCH:-}" ]; then
@@ -5426,7 +5569,14 @@ elif case "$TORCH_INDEX_URL" in */rocm*|*/gfx*) true ;; *) false ;; esac; then
_gpu_rocm_ver=$(amd-smi version 2>/dev/null | awk -F'ROCm version: ' \
'NF>1{gsub(/[[:space:]]/,"", $2); print $2; exit}' || true)
fi
- if [ -n "$_gpu_disp_gfx" ]; then
+ # $_gpu_disp_mkt is the marketing name of the SAME record the arch came from, so it
+ # is safe to put on the step line: _rocminfo_gpu_records pairs it per GPU agent and
+ # _amd_smi_hip_order puts the amd-smi records in the order the mask indexes.
+ if [ -n "$_gpu_disp_mkt" ] && [ -n "$_gpu_disp_gfx" ]; then
+ step "gpu" "$_gpu_disp_mkt ($_gpu_disp_gfx)"
+ elif [ -n "$_gpu_disp_mkt" ]; then
+ step "gpu" "$_gpu_disp_mkt"
+ elif [ -n "$_gpu_disp_gfx" ]; then
step "gpu" "AMD ROCm ($_gpu_disp_gfx)"
else
step "gpu" "AMD ROCm"
@@ -5439,7 +5589,6 @@ elif case "$TORCH_INDEX_URL" in */rocm*|*/gfx*) true ;; *) false ;; esac; then
substep "ROCm: runtime detected (no SDK tree at $_rocm_root)"
fi
[ -n "$_gpu_rocm_ver" ] && substep "hipconfig: $_gpu_rocm_ver"
- [ -n "$_gpu_disp_mkt" ] && [ -n "$_gpu_disp_gfx" ] && substep "GPU: $_gpu_disp_mkt"
elif [ "$OS" = "macos" ] && [ "$_ARCH" = "arm64" ]; then
# Apple Silicon: PyTorch gets Metal (MPS) acceleration over unified memory, so not CPU-only.
step "gpu" "Apple Silicon (Metal, unified memory)"
diff --git a/studio/setup.ps1 b/studio/setup.ps1
index 9a7f8a9ae40..bf20c747486 100644
--- a/studio/setup.ps1
+++ b/studio/setup.ps1
@@ -2544,9 +2544,17 @@ function Invoke-NvidiaSmiBounded {
}
# A driverless nvidia-smi exits 0 listing no GPU, so require a "GPU <n>:" row.
+# 124 is what Invoke-NvidiaSmiBounded reports when it had to kill the probe. Recorded so
+# the banner below can skip a second query: detection already waited out the full bound on
+# this binary, and asking a hung nvidia-smi again only doubles the stall.
+$script:NvidiaSmiWedged = $false
+
function Test-NvidiaSmiHasGpu {
param([Parameter(Mandatory = $true)][string]$Exe)
$out = Invoke-NvidiaSmiBounded $Exe @('-L')
+ # Assigned, not OR-ed: the fallback loop tries several paths, and what matters is
+ # whether the binary it settled on answered, not whether an earlier one hung.
+ $script:NvidiaSmiWedged = ($LASTEXITCODE -eq 124)
return ($LASTEXITCODE -eq 0 -and $out -match '(?m)^GPU\s+\d+:')
}
@@ -2584,6 +2592,120 @@ if (-not $HasNvidiaSmi -and (Get-NvidiaLibraryInventory)) {
$script:NvidiaSmiRejected = $true
Write-StudioLine " NVIDIA GPU found through the driver library; nvidia-smi is unavailable" -ForegroundColor Gray
}
+# nvidia-smi was already resolved above and never asked which card it found, so the banner
+# said "NVIDIA GPU detected" on every NVIDIA host alike. compute_cap is the counterpart of the
+# gfx arch shown for AMD, the driver version the counterpart of the HIP SDK line, and one
+# query returns all three. Honour the same visible-device index the AMD probes do.
+#
+# A mask of "" or -1 hides every device, so it selects nothing to name. It is also not a
+# UUID, and letting it reach the prefix match below would spend a second probe that can
+# never match and then name row 0 anyway. $HasNvidiaSmi still drives wheel selection here,
+# as it does on main, so only the naming is skipped: the banner keeps the vendor-only
+# wording rather than claiming a card CUDA does not expose.
+$NvidiaGpuName = $null
+$NvidiaSmArch = $null
+$NvidiaDriverVersion = $null
+$nvMaskHidesAll = $false
+if ($null -ne $env:CUDA_VISIBLE_DEVICES) {
+ $nvMask = ($env:CUDA_VISIBLE_DEVICES -replace '\s', '')
+ $nvMaskHidesAll = ($nvMask -eq '' -or $nvMask -eq '-1')
+}
+if ($HasNvidiaSmi -and $NvidiaSmiExe -and -not $script:NvidiaSmiWedged -and -not $nvMaskHidesAll) {
+ try {
+ # Through the bounded runner, like every other nvidia-smi call here: a wedged
+ # driver blocks nvidia-smi indefinitely, and a bare `&` call has nothing to
+ # time it out. -StdoutOnly because driver warnings on stderr would corrupt
+ # this machine-readable CSV.
+ $nvOut = Invoke-NvidiaSmiBounded $NvidiaSmiExe @('--query-gpu=name,compute_cap,driver_version', '--format=csv,noheader') -StdoutOnly
+ $nvRows = @($nvOut -split '\r?\n' | ForEach-Object { $_.Trim() } | Where-Object { $_ })
+ if ($nvRows.Count -gt 0) {
+ # nvidia-smi ignores CUDA_VISIBLE_DEVICES, so the mask is resolved against its
+ # physical rows here. A non-numeric token is a GPU UUID, or a MIG id
+ # (MIG-<GPU-UUID>/<gi>/<ci>) embedding one; NVIDIA allows the UUID to be
+ # abbreviated to any unique leading portion, so it is matched on prefix.
+ $nvIdx = 0
+ $nvTok = if ($env:CUDA_VISIBLE_DEVICES) { ($env:CUDA_VISIBLE_DEVICES -split ',')[0].Trim() } else { '' }
+ # True while nothing has IDENTIFIED a device: a plain ordinal.
+ $nvByOrdinal = $true
+ # Set when an identity mask was given but did not resolve, which means CUDA
+ # selected NO device. Row 0 is not a fallback for that.
+ $nvUnresolved = $false
+ if ($nvTok -match '^\d+$') {
+ $nvIdx = [int]$nvTok
+ } elseif ($nvTok -like 'MIG-*' -and $nvTok -notlike 'MIG-GPU-*') {
+ # R470 and later give each MIG instance its OWN opaque UUID, which
+ # carries nothing of the parent, so --query-gpu=uuid can never match it.
+ # `nvidia-smi -L` nests the instances under their GPU.
+ $nvListOut = Invoke-NvidiaSmiBounded $NvidiaSmiExe @('-L') -StdoutOnly
+ $cur = 0
+ $nvByOrdinal = $false
+ $nvFound = $false
+ foreach ($ln in ($nvListOut -split '\r?\n')) {
+ if ($ln -match '^GPU\s+(\d+):') { $cur = [int]$Matches[1] }
+ if ($ln -match [regex]::Escape($nvTok)) { $nvIdx = $cur; $nvFound = $true; break }
+ }
+ if (-not $nvFound) { $nvUnresolved = $true }
+ } elseif ($nvTok) {
+ # Pre-R470 MIG names embed the parent UUID: MIG-<GPU-UUID>/<gi>/<ci>.
+ if ($nvTok -like 'MIG-GPU-*') { $nvTok = ($nvTok.Substring(4) -split '/')[0] }
+ $nvUuidOut = Invoke-NvidiaSmiBounded $NvidiaSmiExe @('--query-gpu=uuid', '--format=csv,noheader') -StdoutOnly
+ $nvUuids = @($nvUuidOut -split '\r?\n' | ForEach-Object { $_.Trim() } | Where-Object { $_ })
+ $nvByOrdinal = $false
+ $nvFound = $false
+ # NVIDIA accepts an abbreviation only when it is a UNIQUE leading portion, so
+ # a prefix matching two cards selects NO device. Collect, do not stop at the
+ # first hit, or the banner names one of them.
+ $nvMatches = @()
+ for ($i = 0; $i -lt $nvUuids.Count; $i++) {
+ if ($nvUuids[$i].StartsWith($nvTok, [System.StringComparison]::OrdinalIgnoreCase)) { $nvMatches += $i }
+ }
+ if ($nvMatches.Count -eq 1) { $nvIdx = $nvMatches[0]; $nvFound = $true }
+ if (-not $nvFound) { $nvUnresolved = $true }
+ }
+ $nvRow = if ($nvIdx -lt $nvRows.Count) { $nvRows[$nvIdx] } else { $nvRows[0] }
+ # A numeric entry is a CUDA ordinal, and CUDA's default
+ # CUDA_DEVICE_ORDER=FASTEST_FIRST puts the fastest card at 0 and leaves the
+ # rest unspecified, while nvidia-smi always lists in PCI order. So an ordinal
+ # identifies an nvidia-smi 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. Compared on name and compute_cap, not the driver, which is host-wide.
+ # CUDA stops enumerating at the first invalid index, so an ordinal past the last
+ # row exposes NO device. The row pick below clamps to 0 so the driver still
+ # reads, but row 0 is not the selected card -- nothing is.
+ if ($nvByOrdinal -and $nvIdx -ge $nvRows.Count) { $nvUnresolved = $true }
+ $nvAmbiguous = $nvUnresolved
+ if ($nvByOrdinal -and -not $nvAmbiguous) {
+ $nvOrder = (("$env:CUDA_DEVICE_ORDER") -replace '\s', '').ToUpperInvariant()
+ $nvModels = @($nvRows | ForEach-Object { $_ -replace ',[^,]*$', '' } |
+ Sort-Object -Unique).Count
+ $nvAmbiguous = ($nvOrder -ne 'PCI_BUS_ID' -and $nvModels -gt 1)
+ }
+ # Split from the right: nvidia-smi does not quote, so a comma in a device name
+ # would otherwise shift every field.
+ $nvParts = $nvRow -split ','
+ if ($nvParts.Count -ge 3) {
+ $NvidiaDriverVersion = $nvParts[-1].Trim()
+ $nvComputeCap = $nvParts[-2].Trim()
+ $NvidiaGpuName = ($nvParts[0..($nvParts.Count - 3)] -join ',').Trim()
+ if ($nvComputeCap -match '^(\d+)\.(\d+)$') {
+ $NvidiaSmArch = "sm_" + (([int]$Matches[1] * 10) + [int]$Matches[2])
+ }
+ } else {
+ # Short row: field 1 only. Taking the whole row would print the
+ # compute capability as part of the name ("RTX 4090, 8.9").
+ $NvidiaGpuName = $nvParts[0].Trim()
+ }
+ # An nvidia-smi too old for a field answers with a placeholder rather
+ # than failing (the 470 branch has no compute_cap at all).
+ $nvPlaceholders = @('[N/A]', '[Not Supported]', '[Unknown Error]')
+ if ($nvPlaceholders -contains $NvidiaGpuName) { $NvidiaGpuName = $null }
+ if ($nvPlaceholders -contains $NvidiaDriverVersion) { $NvidiaDriverVersion = $null }
+ # Keep the driver, drop the identity: the banner falls back to the vendor-only
+ # wording rather than claiming a card that may not be the one CUDA will use.
+ if ($nvAmbiguous) { $NvidiaGpuName = $null; $NvidiaSmArch = $null }
+ }
+ } catch {}
+}
# amd-smi auto-elevates to read GPU memory, popping a DiskPart UAC prompt; RunAsInvoker stops it.
function Invoke-AmdSmiNoElevate {
param(
@@ -2628,6 +2750,10 @@ function Invoke-AmdSmiNoElevate {
$HasROCm = $false
$HipSdkInstalled = $false # HIP SDK binary found (independent of device accessibility)
$ROCmGpuLabel = $null
+# Marketing name on its own ("AMD Radeon RX 9060 XT"), never decorated. Kept apart from
+# $ROCmGpuLabel because that one doubles as the input to the name -> arch tables below;
+# this one only ever reaches the banner.
+$ROCmGpuName = $null
$script:ROCmGpuLabels = @() # every AMD adapter name WMI reported (shadowing-aware inference)
$script:ROCmGfxArch = $null
# Beside ROCmGfxArch, NOT inside the `-not $HasNvidiaSmi` block below: the ROCm summary
@@ -2813,6 +2939,11 @@ if (-not $HasNvidiaSmi) {
# hipinfo can crash after printing gcnArchName (#6043); keep the ROCm path.
$HasROCm = $true
$_hipAllArches = @([regex]::Matches($hipOut, "(?im)^\s*gcnArchName\s*:\s*(\S+)") | ForEach-Object { ($_.Groups[1].Value -split ':')[0].Trim().ToLower() })
+ # hipinfo prints "Name:" per device alongside gcnArchName. Anchored so
+ # gcnArchName cannot match. Only trusted when the two lists line up, and read
+ # at the index the arch pick landed on, so the banner names the card the
+ # wheels were chosen for.
+ $_hipAllNames = @([regex]::Matches($hipOut, "(?im)^\s*Name\s*:\s*(.+?)\s*$") | ForEach-Object { $_.Groups[1].Value.Trim() })
if ($_hipAllArches.Count -gt 0) {
# hipinfo is itself a HIP application, so under a mask it already
# enumerated only the visible devices, renumbered from 0; indexing it
@@ -2821,6 +2952,10 @@ if (-not $HasNvidiaSmi) {
$script:ROCmGfxArch = $_hipAllArches[0]
$script:ROCmGfxArch = Resolve-ShadowingGfxPick $script:ROCmGfxArch $_hipAllArches
$ROCmGpuLabel = "AMD ROCm ($script:ROCmGfxArch)"
+ if ($_hipAllNames.Count -eq $_hipAllArches.Count) {
+ $_hipPickIdx = [array]::IndexOf($_hipAllArches, $script:ROCmGfxArch)
+ if ($_hipPickIdx -ge 0) { $ROCmGpuName = $_hipAllNames[$_hipPickIdx] }
+ }
} else {
$ROCmGpuLabel = "AMD ROCm"
}
@@ -2852,9 +2987,23 @@ if (-not $HasNvidiaSmi) {
# amd-smi lists every GPU regardless of the masks, so resolve the
# index here, via the shared helper so a comma list or a padded
# value cannot select a different GPU than elsewhere.
- $script:ROCmGfxArch = $allGfxArches[(Resolve-VisibleGpuIndex $allGfxArches.Count)]
- $script:ROCmGfxArch = Resolve-ShadowingGfxPick $script:ROCmGfxArch $allGfxArches
+ $_smiPickIdx = Resolve-VisibleGpuIndex $allGfxArches.Count
+ $script:ROCmGfxArch = $allGfxArches[$_smiPickIdx]
+ $_smiShadowPick = Resolve-ShadowingGfxPick $script:ROCmGfxArch $allGfxArches
+ if ($_smiShadowPick -ne $script:ROCmGfxArch) {
+ $script:ROCmGfxArch = $_smiShadowPick
+ $_smiPickIdx = [array]::IndexOf($allGfxArches, $_smiShadowPick)
+ }
$ROCmGpuLabel = "AMD ROCm ($script:ROCmGfxArch)"
+ # Banner only, read at the index the arch pick landed on. The index
+ # is carried forward rather than recovered from the arch VALUE:
+ # the list is deliberately not deduplicated, so IndexOf on two
+ # same-arch cards always returns 0 and names the first one even
+ # when the mask selected the second (RX 7900 XTX vs PRO W7900).
+ $_smiNames = @([regex]::Matches($smiOut, "(?im)Market.?Name\s*[:\|]\s*([^\r\n]+)") | ForEach-Object { $_.Groups[1].Value.Trim() })
+ if ($_smiNames.Count -eq $allGfxArches.Count -and $_smiPickIdx -ge 0) {
+ $ROCmGpuName = $_smiNames[$_smiPickIdx]
+ }
} else {
# Attempt 2: 'static --asic' exposes the GFX target on ROCm 6+.
$smiAsicOut = ""
@@ -2865,11 +3014,23 @@ if (-not $HasNvidiaSmi) {
$asicGfxArches = @([regex]::Matches($smiAsicOut, '(?i)\b(gfx\d+[a-z]?)\b') |
ForEach-Object { $_.Groups[1].Value.ToLower() })
if ($asicGfxArches.Count -gt 0) {
- $script:ROCmGfxArch = $asicGfxArches[(Resolve-VisibleGpuIndex $asicGfxArches.Count)]
- $script:ROCmGfxArch = Resolve-ShadowingGfxPick $script:ROCmGfxArch $asicGfxArches
+ $_asicPickIdx = Resolve-VisibleGpuIndex $asicGfxArches.Count
+ $script:ROCmGfxArch = $asicGfxArches[$_asicPickIdx]
+ $_asicShadowPick = Resolve-ShadowingGfxPick $script:ROCmGfxArch $asicGfxArches
+ if ($_asicShadowPick -ne $script:ROCmGfxArch) {
+ $script:ROCmGfxArch = $_asicShadowPick
+ $_asicPickIdx = [array]::IndexOf($asicGfxArches, $_asicShadowPick)
+ }
$ROCmGpuLabel = "AMD ROCm ($script:ROCmGfxArch)"
+ # Index carried forward, not recovered from the arch value --
+ # see the sibling branch above.
+ $_asicNames = @([regex]::Matches($smiAsicOut, "(?im)Market.?Name\s*[:\|]\s*([^\r\n]+)") | ForEach-Object { $_.Groups[1].Value.Trim() })
+ if ($_asicNames.Count -eq $asicGfxArches.Count -and $_asicPickIdx -ge 0) {
+ $ROCmGpuName = $_asicNames[$_asicPickIdx]
+ }
} elseif ($smiAsicOut -match "(?im)Market.?Name\s*[:\|]\s*([^\r\n]+)") {
- $ROCmGpuLabel = "AMD ROCm ($($Matches[1].Trim()))"
+ $ROCmGpuName = $Matches[1].Trim()
+ $ROCmGpuLabel = "AMD ROCm ($ROCmGpuName)"
} else {
$ROCmGpuLabel = "AMD ROCm"
}
@@ -2904,6 +3065,7 @@ if (-not $HasNvidiaSmi) {
if ($wmiGpus.Count -gt 0) {
$script:ROCmGpuLabels = @($wmiGpus | ForEach-Object { $_.Name })
$ROCmGpuLabel = $script:ROCmGpuLabels[0]
+ $ROCmGpuName = $script:ROCmGpuLabels[0]
}
} catch {}
}
@@ -2986,17 +3148,33 @@ if (-not $HasNvidiaSmi) {
# drops out below, and indexing the shortened list would name the wrong card.
$nameIdx = Resolve-VisibleGpuIndex $gpuNames.Count
$nameArches = @()
- foreach ($gpuName in $gpuNames) {
- $inferred = Get-GfxArchFromGpuName -Name $gpuName -Table $nameArchTable
- if ($inferred) { $nameArches += $inferred }
+ # Which ADAPTER each inferred arch came from. Unmappable names drop out, so
+ # $nameArches is shorter than $gpuNames and its positions stop lining up; the
+ # borrow below has to be able to say which card it borrowed from.
+ $nameArchSrc = @()
+ for ($_gi = 0; $_gi -lt $gpuNames.Count; $_gi++) {
+ $inferred = Get-GfxArchFromGpuName -Name $gpuNames[$_gi] -Table $nameArchTable
+ if ($inferred) { $nameArches += $inferred; $nameArchSrc += $_gi }
}
$pickedName = Get-GfxArchFromGpuName -Name $gpuNames[$nameIdx] -Table $nameArchTable
# Borrow another adapter's arch only when unpinned: an unmappable leading
# adapter is exactly the #7776 iGPU and the named discrete card should decide,
# but under a mask substituting installs wheels for a GPU they masked away.
+ # Which adapter actually supplied the arch: the borrowed one, or the selected
+ # one when its own name mapped. -1 only when nothing mapped. Both cases need
+ # it, because either can leave $nameArches shorter than $gpuNames and so skip
+ # the repick block below.
+ $_archSrcIdx = -1
if (-not $pickedName -and -not (Test-VisibleDevicesPinned) -and $nameArches.Count -gt 0) {
$pickedName = $nameArches[0]
+ $_archSrcIdx = $nameArchSrc[0]
}
+ # Guarded on $_archSrcIdx so a borrow above is not overwritten. Spelled with
+ # -and rather than a bare truthiness test on $pickedName alone, because that
+ # exact spelling is the end anchor TestSetupPs1ShadowingParity slices this
+ # block on; a second copy closes its window early and hides the pinned-mask
+ # guard from it.
+ if ($pickedName -and $_archSrcIdx -lt 0) { $_archSrcIdx = $nameIdx }
if ($pickedName) {
# Repick only when every adapter mapped: an unknown name may BE the
# discrete card, so skipping the iGPU could pick the wrong one.
@@ -3004,6 +3182,33 @@ if (-not $HasNvidiaSmi) {
Resolve-ShadowingGfxPick -Picked $pickedName -AllArches $nameArches
} else { $pickedName }
$ROCmGpuLabel = "AMD ROCm ($script:ROCmGfxArch)"
+ # Move the banner name onto the adapter this arch actually came from.
+ # $ROCmGpuName was set to adapter 0 by the WMI scan above, but all three
+ # mechanisms here -- the visible-device mask, the $nameArches[0] borrow
+ # and the shadowing repick -- can land the arch on a different adapter.
+ # Left alone, an iGPU+dGPU host reads "AMD Radeon 890M (gfx1201)":
+ # the integrated name against the discrete arch.
+ if ($nameArches.Count -eq $gpuNames.Count) {
+ # Keep $nameIdx when the arch at that index is the one that was
+ # picked: two adapters can map to the same arch (RX 7900 XTX and
+ # PRO W7900 are both gfx1100), and IndexOf on a non-unique value
+ # returns 0, naming the first card even under a mask selecting the
+ # second. IndexOf is only the fallback for a shadowing repick.
+ $_nameArchIdx = if ($nameIdx -lt $nameArches.Count -and $nameArches[$nameIdx] -eq $script:ROCmGfxArch) {
+ $nameIdx
+ } else {
+ [array]::IndexOf($nameArches, $script:ROCmGfxArch)
+ }
+ if ($_nameArchIdx -ge 0) { $ROCmGpuName = $gpuNames[$_nameArchIdx] }
+ } elseif ($_archSrcIdx -ge 0) {
+ # Not every adapter mapped, so the block above cannot run, but the arch
+ # came from a KNOWN adapter and $ROCmGpuName is still adapter 0. Covers
+ # both shapes: an unmappable iGPU ahead of an RX 9070 with no mask, and
+ # the same pair with HIP_VISIBLE_DEVICES=1 selecting the RX 9070
+ # directly. Either otherwise reads "AMD Radeon Graphics (gfx1201)":
+ # the integrated name against the discrete arch.
+ $ROCmGpuName = $gpuNames[$_archSrcIdx]
+ }
substep "gfx arch inferred from GPU name: $script:ROCmGfxArch" "Cyan"
substep "Tip: set UNSLOTH_ROCM_GFX_ARCH=$script:ROCmGfxArch to skip inference next time" "Cyan"
} else {
@@ -3094,6 +3299,14 @@ if (-not $HasNvidiaSmi) {
} catch {}
}
}
+ # Last resort: the SDK root itself is versioned (...\AMD\ROCm\7.1). Reporting
+ # "ROCm (version unknown)" while the very next line prints that path made the summary
+ # look broken on a perfectly good install; both probes above can miss when hipconfig
+ # is absent from a runtime-only layout and amd-smi is not on PATH.
+ if (-not $script:ROCmVersion) {
+ $hipVersionedRoot = if ($env:HIP_PATH) { $env:HIP_PATH } elseif ($env:ROCM_PATH) { $env:ROCM_PATH } else { $null }
+ if ($hipVersionedRoot -match '[\\/](\d+\.\d+(?:\.\d+)?)[\\/]?$') { $script:ROCmVersion = $Matches[1] }
+ }
}
}
@@ -3170,20 +3383,38 @@ if (-not $HasNvidiaSmi -and -not $AmdHasGpuWheels) {
}
}
+# One banner string for the AMD arms below. The arch alone ("AMD ROCm (gfx1200)") named a
+# target nobody shopping for a GPU recognises, while every probe above already had the
+# marketing name in hand and threw it away.
+$ROCmGpuDisplay =
+ if ($ROCmGpuName -and $script:ROCmGfxArch) { "$ROCmGpuName ($script:ROCmGfxArch)" }
+ elseif ($ROCmGpuName) { $ROCmGpuName }
+ elseif ($script:ROCmGfxArch) { "AMD ROCm ($script:ROCmGfxArch)" }
+ else { $ROCmGpuLabel }
+
+# Same shape for every vendor: the device on the step line, its compute target in
+# parentheses, the runtime below. Intel has no counterpart to gfx1200 / sm_89 that any probe
+# here already resolves, so it gets the name alone rather than an invented one.
+$NvidiaGpuDisplay =
+ if ($NvidiaGpuName -and $NvidiaSmArch) { "$NvidiaGpuName ($NvidiaSmArch)" }
+ elseif ($NvidiaGpuName) { $NvidiaGpuName }
+ else { "NVIDIA GPU detected" }
+$IntelGpuDisplay = if ($IntelGpuLabel) { $IntelGpuLabel } else { "Intel GPU detected" }
+
if ($HasNvidiaSmi) {
- step "gpu" "NVIDIA GPU detected"
+ step "gpu" $NvidiaGpuDisplay
+ if ($NvidiaDriverVersion) { substep "Driver: $NvidiaDriverVersion" }
} elseif ($script:IsIntelXpu) {
# Ranks above every AMD branch: only true when AMD gets no GPU wheel ($AmdHasGpuWheels gates
# the scan above), so those branches would all end on CPU torch.
Write-StudioLine ""
- step "gpu" "Intel GPU detected" "Green"
- substep "$IntelGpuLabel"
+ step "gpu" $IntelGpuDisplay "Green"
substep "PyTorch XPU (SYCL) wheels provide training and GPU inference on this GPU." "Cyan"
Write-StudioLine ""
} elseif ($HasROCm -and -not $script:ROCmUnsupportedGfxArch) {
# Guarded like the HIP SDK arm below: amd-smi can report a GPU with no gfx token
# and only a market name, which sets $HasROCm without an arch.
- step "gpu" $ROCmGpuLabel
+ step "gpu" $ROCmGpuDisplay
$hipSdkPath = if ($env:HIP_PATH) { $env:HIP_PATH } elseif ($env:ROCM_PATH) { $env:ROCM_PATH } else { "on system PATH" }
substep "HIP SDK: $hipSdkPath"
if ($script:ROCmVersionFull) { substep "hipconfig: $script:ROCmVersionFull" }
@@ -3203,7 +3434,7 @@ if ($HasNvidiaSmi) {
# Known arch: PyTorch comes from AMD's bundled-runtime ROCm wheels (repo.amd.com),
# which ship their own runtime -- HIP SDK optional (only adds the system toolchain).
Write-StudioLine ""
- step "gpu" "AMD ROCm ($script:ROCmGfxArch)" "Cyan"
+ step "gpu" $ROCmGpuDisplay "Cyan"
substep "Detected: $ROCmGpuLabel" "Cyan"
substep "GPU PyTorch uses AMD's bundled-runtime ROCm wheels -- HIP SDK not required (optional)." "Cyan"
Write-StudioLine ""
diff --git a/studio/setup.sh b/studio/setup.sh
index 8bfb1a0abfd..243023efdb0 100755
--- a/studio/setup.sh
+++ b/studio/setup.sh
@@ -652,6 +652,9 @@ _setup_cvd_hides_nvidia() {
# and a mixed host steered to its AMD card keeps the ROCm route.
# Present, mask or no mask. The usable probe is this plus the CUDA_VISIBLE_DEVICES check.
_setup_has_physical_nvidia_gpu() {
+ # Reset here rather than in the usable wrapper: this is where the bounded -L call
+ # lives, and both entry points reach the probe through it.
+ _setup_nv_smi_wedged=""
_setup_nvsmi=""
if command -v nvidia-smi >/dev/null 2>&1; then
_setup_nvsmi="nvidia-smi"
@@ -659,7 +662,15 @@ _setup_has_physical_nvidia_gpu() {
_setup_nvsmi="/usr/bin/nvidia-smi"
fi
if [ -n "$_setup_nvsmi" ]; then
- if _setup_run_smi "$_setup_nvsmi" -L 2>/dev/null \
+ # Captured rather than piped so `timeout`'s own 124 stays visible. A wedged
+ # driver still detects as a GPU through /proc below, and the banner must not
+ # then pay the 10s bound a second time asking a hung nvidia-smi for a name.
+ _setup_nv_l_rc=0
+ _setup_nv_l_out=$(_setup_run_smi "$_setup_nvsmi" -L 2>/dev/null) || _setup_nv_l_rc=$?
+ if [ "$_setup_nv_l_rc" = "124" ]; then
+ _setup_nv_smi_wedged=1
+ fi
+ if printf '%s\n' "$_setup_nv_l_out" \
| awk '/^GPU[[:space:]]+[0-9]+:/{found=1} END{exit !found}'; then
return 0
fi
@@ -676,6 +687,121 @@ _setup_has_physical_nvidia_gpu() {
return 1
}
+# Row index of the GPU whose UUID starts with $1, or empty. NVIDIA allows a UUID to
+# be abbreviated to any unique leading portion, hence the prefix match.
+_setup_nv_idx_from_uuid() {
+ # NVIDIA accepts an abbreviation only when it is a UNIQUE leading portion, so a
+ # prefix matching two cards selects NO device. Counting instead of stopping at the
+ # first hit keeps the banner from naming one of them.
+ _setup_run_smi "$_setup_nvsmi" --query-gpu=uuid --format=csv,noheader 2>/dev/null \
+ | awk -v want="$1" '
+ NF { gsub(/^[[:space:]]+|[[:space:]]+$/,""); if (index($0, want) == 1) { hits++; idx = NR-1 } }
+ END { if (hits == 1) print idx }' || true
+}
+
+# Resolves the banner's NVIDIA fields into _setup_nv_name / _setup_nv_sm /
+# _setup_nv_driver, each empty when it could not be read. Mirrors install.sh's
+# _nv_banner_fields. Bounded, and fed the executable _setup_has_usable_nvidia_gpu
+# already resolved into $_setup_nvsmi: a wedged driver blocks nvidia-smi indefinitely,
+# and detection also succeeds via /usr/bin/nvidia-smi off PATH or via
+# /proc/driver/nvidia/gpus with no nvidia-smi at all.
+_setup_nv_banner_fields() {
+ _setup_nv_name=""; _setup_nv_sm=""; _setup_nv_driver=""
+ _setup_nv_row=""; _setup_nv_cc=""; _setup_nv_ambiguous=""
+ [ -n "${_setup_nvsmi:-}" ] || return 0
+ # Detection already waited out the full bound on this binary. Asking again cannot
+ # succeed and would double the stall, so the banner keeps the vendor-only wording.
+ [ -z "${_setup_nv_smi_wedged:-}" ] || return 0
+ # nvidia-smi ignores CUDA_VISIBLE_DEVICES, so its rows are the physical devices and
+ # the mask has to be resolved against them by hand.
+ _setup_nv_idx=0
+ # Set while nothing has IDENTIFIED a device: an ordinal, or a failed identity lookup
+ # that fell back to one. Only an ordinal is order-dependent.
+ _setup_nv_by_ordinal=1
+ _setup_nv_vis="${CUDA_VISIBLE_DEVICES:-}"
+ # Only the FIRST entry selects the device, and only IT decides the form of the mask.
+ # CUDA truncates enumeration at the first invalid index, so the documented `2,-1`
+ # means "device 2, then stop"; classifying the whole string would see the `-1`, call
+ # it non-numeric, and send a plain ordinal down the UUID path.
+ _setup_nv_tok="${_setup_nv_vis%%,*}"
+ case "$_setup_nv_tok" in
+ '') ;;
+ *[!0-9]*)
+ _setup_nv_by_ordinal=""
+ case "$_setup_nv_tok" in
+ MIG-GPU-*)
+ # Pre-R470 MIG name, MIG-<GPU-UUID>/<gi>/<ci>: the parent UUID is
+ # embedded, so it still matches a --query-gpu=uuid row.
+ _setup_nv_tok="${_setup_nv_tok#MIG-}"; _setup_nv_tok="${_setup_nv_tok%%/*}"
+ _setup_nv_idx=$(_setup_nv_idx_from_uuid "$_setup_nv_tok") ;;
+ MIG-*)
+ # R470 and later give each MIG instance its OWN opaque UUID, which
+ # carries nothing of the parent, so --query-gpu=uuid can never match
+ # it. `nvidia-smi -L` nests the instances under their GPU.
+ _setup_nv_idx=$(_setup_run_smi "$_setup_nvsmi" -L 2>/dev/null | awk -v want="$_setup_nv_tok" '
+ /^GPU[[:space:]]+[0-9]+:/ { cur = $2 + 0 }
+ index($0, want) > 0 { print cur; exit }' || true) ;;
+ *)
+ _setup_nv_idx=$(_setup_nv_idx_from_uuid "$_setup_nv_tok") ;;
+ esac
+ # An identity mask that does not resolve means CUDA selected NO device: an
+ # abbreviation short enough to match two cards, or a UUID for a card that is
+ # not here. Row 0 is not a fallback for that -- it is a different card.
+ case "$_setup_nv_idx" in ''|*[!0-9]*) _setup_nv_idx=0; _setup_nv_ambiguous=1 ;; esac
+ ;;
+ *) _setup_nv_idx="$_setup_nv_tok" ;;
+ esac
+ # Canonicalise the ordinal before anything compares or subscripts with it.
+ # `[` parses with strtol and ERRORS on a value wider than a long, printing a
+ # shell diagnostic and skipping the range check below, so an absurd ordinal
+ # would have named row 0. Clamped rather than rejected: 9999 is past any real
+ # host, so it stays out of range and declines, which is the right answer.
+ _setup_nv_idx=$(printf '%s' "$_setup_nv_idx" \
+ | awk '{ n = $0 + 0; if (n < 0) n = 0; if (n > 9999) n = 9999; printf "%d", n }')
+ _setup_nv_all=$(_setup_run_smi "$_setup_nvsmi" --query-gpu=name,compute_cap,driver_version --format=csv,noheader 2>/dev/null || true)
+ _setup_nv_row=$(printf '%s\n' "$_setup_nv_all" \
+ | awk -v idx="$_setup_nv_idx" 'NF { a[n++]=$0 } END { if(idx>=n) idx=0; if(n>0) print a[idx+0] }')
+ [ -n "$_setup_nv_row" ] || return 0
+ # A numeric entry is a CUDA ordinal, and CUDA's default CUDA_DEVICE_ORDER=FASTEST_FIRST
+ # puts the fastest card at 0 and leaves the rest "unspecified", while nvidia-smi always
+ # lists in PCI order. So an ordinal identifies an nvidia-smi 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. Compared on name and compute_cap, not the driver, which is
+ # host-wide and identical on every row.
+ # CUDA stops enumerating at the first invalid index, so an ordinal past the last
+ # row exposes NO device at all. The awk above clamps to row 0 so the driver still
+ # reads, but row 0 is not the selected card -- nothing is.
+ _setup_nv_rowcount=$(printf '%s\n' "$_setup_nv_all" | awk 'NF { n++ } END { print n+0 }')
+ if [ -n "$_setup_nv_by_ordinal" ] && [ "$_setup_nv_idx" -ge "$_setup_nv_rowcount" ]; then
+ _setup_nv_ambiguous=1
+ fi
+ if [ -n "$_setup_nv_by_ordinal" ]; then
+ _setup_nv_order=$(printf '%s' "${CUDA_DEVICE_ORDER:-}" | tr '[:lower:]' '[:upper:]' | tr -d '[:space:]')
+ _setup_nv_models=$(printf '%s\n' "$_setup_nv_all" \
+ | awk -F, 'NF { k=$0; sub(/,[^,]*$/,"",k); if (!(k in s)) { s[k]; n++ } } END { print n+0 }')
+ if [ "$_setup_nv_order" != "PCI_BUS_ID" ] && [ "$_setup_nv_models" -gt 1 ]; then
+ _setup_nv_ambiguous=1
+ fi
+ fi
+ # Split from the right: nvidia-smi does not quote, so a comma in a device name
+ # would otherwise shift every field.
+ _setup_nv_driver=$(printf '%s' "$_setup_nv_row" | awk -F, 'NF>=3 { gsub(/^[[:space:]]+|[[:space:]]+$/,"",$NF); print $NF }')
+ _setup_nv_cc=$(printf '%s' "$_setup_nv_row" | awk -F, 'NF>=3 { gsub(/^[[:space:]]+|[[:space:]]+$/,"",$(NF-1)); print $(NF-1) }')
+ _setup_nv_name=$(printf '%s' "$_setup_nv_row" | awk -F, 'NF>=3 { out=$1; for(i=2;i<=NF-2;i++) out=out","$i; gsub(/^[[:space:]]+|[[:space:]]+$/,"",out); print out }')
+ # Short row: keep field 1 only, or the compute capability lands in the name.
+ [ -n "$_setup_nv_name" ] || _setup_nv_name=$(printf '%s' "$_setup_nv_row" | awk -F, '{ gsub(/^[[:space:]]+|[[:space:]]+$/,"",$1); print $1 }')
+ # An nvidia-smi too old for a field answers with a placeholder rather than failing.
+ case "$_setup_nv_name" in '[N/A]'|'[Not Supported]'|'[Unknown Error]') _setup_nv_name="" ;; esac
+ case "$_setup_nv_driver" in '[N/A]'|'[Not Supported]'|'[Unknown Error]') _setup_nv_driver="" ;; esac
+ # Keep the driver, drop the identity: the banner falls back to the vendor-only wording
+ # rather than claiming a card that may not be the one CUDA will use.
+ if [ -n "$_setup_nv_ambiguous" ]; then _setup_nv_name=""; _setup_nv_cc=""; fi
+ case "$_setup_nv_cc" in
+ [0-9]*.[0-9]*) _setup_nv_sm="sm_$(printf '%s' "$_setup_nv_cc" | awk -F. '{ print ($1*10)+$2 }')" ;;
+ esac
+ return 0
+}
+
_setup_has_usable_nvidia_gpu() {
if _setup_cvd_hides_nvidia; then
return 1
@@ -2966,7 +3092,17 @@ if [ "$_setup_nvidia_usable" != true ]; then
fi
if [ "$_setup_nvidia_usable" = true ]; then
- step "gpu" "NVIDIA GPU detected"
+ _setup_nv_banner_fields
+ if [ -n "$_setup_nv_name" ] && [ -n "$_setup_nv_sm" ]; then
+ step "gpu" "$_setup_nv_name ($_setup_nv_sm)"
+ elif [ -n "$_setup_nv_name" ]; then
+ step "gpu" "$_setup_nv_name"
+ else
+ step "gpu" "NVIDIA GPU detected"
+ fi
+ # An `if`, not `[ ... ] && substep ...`: the AND-list form leaves a non-zero status
+ # behind on the common path where there is no driver string to print.
+ if [ -n "$_setup_nv_driver" ]; then substep "Driver: $_setup_nv_driver"; fi
elif [ "$_setup_amd_detected" = true ]; then
_setup_vis="${HIP_VISIBLE_DEVICES:-${ROCR_VISIBLE_DEVICES:-}}"
_setup_vis_idx=0
@@ -2977,14 +3113,14 @@ elif [ "$_setup_amd_detected" = true ]; then
if [ -n "$_setup_amd_records" ]; then
# Records already preserve device ordinals, including duplicate arches.
_setup_amd_record=$(printf '%s\n' "$_setup_amd_records" | awk -v idx="$_setup_vis_idx" \
- 'NF { a[n++]=$0 } END { if(idx>=n) idx=0; if(n>0) print a[idx] }')
+ 'NF { a[n++]=$0 } END { if(idx>=n) idx=0; if(n>0) print a[idx+0] }')
_setup_gfx=${_setup_amd_record%%|*}
_setup_mkt=${_setup_amd_record#*|}
fi
# Only pre-TARGET_GRAPHICS_VERSION amd-smi lands here: names but no arch in the record.
if [ -z "$_setup_gfx" ]; then
_setup_gfx=$(printf '%s\n' "$_setup_gfx_all" | awk -v idx="$_setup_vis_idx" \
- 'NF && !seen[$0]++ { a[n++]=$0 } END { if(idx>=n) idx=0; if(n>0) print a[idx] }')
+ 'NF && !seen[$0]++ { a[n++]=$0 } END { if(idx>=n) idx=0; if(n>0) print a[idx+0] }')
fi
# UNSLOTH_ROCM_GFX_ARCH env override (mirrors setup.ps1)
if [ -n "${UNSLOTH_ROCM_GFX_ARCH:-}" ]; then
@@ -3072,7 +3208,11 @@ $_setup_unsup_pci
EOF
return 1
}
- if [ -n "$_setup_gfx" ]; then
+ # $_setup_mkt is the marketing name of the SAME record the arch came from, paired
+ # per GPU agent by _rocminfo_gpu_records and ordered by _amd_smi_hip_order.
+ if [ -n "$_setup_gfx" ] && [ -n "$_setup_mkt" ]; then
+ step "gpu" "$_setup_mkt ($_setup_gfx)"
+ elif [ -n "$_setup_gfx" ]; then
step "gpu" "AMD ROCm ($_setup_gfx)"
elif _setup_unsup_gfx=$(_setup_unsupported_gfx_any "$_setup_mkt"); then
step "gpu" "AMD GPU detected ($_setup_unsup_gfx) -- no ROCm PyTorch wheels Unsloth installs"
@@ -3094,6 +3234,11 @@ EOF
substep "GGUF chat can still use this GPU through Vulkan: export UNSLOTH_LLAMA_CPP_BACKEND=vulkan,"
substep "then re-run the installer. It picks the llama.cpp bundle at install time, so setting"
substep "it afterwards has no effect until you install or update again."
+ elif [ -n "$_setup_mkt" ]; then
+ # Name without an arch, as install.sh does. Deliberately BELOW the unsupported
+ # arm above: a card with no ROCm wheels also reaches here with a name, and
+ # naming it quietly would drop the warning that training will not run.
+ step "gpu" "$_setup_mkt"
else
step "gpu" "AMD ROCm"
fi
@@ -3109,7 +3254,6 @@ EOF
substep "ROCm: runtime detected (no SDK tree at $_setup_rocm_root)"
fi
[ -n "$_setup_rocm_ver" ] && substep "hipconfig: $_setup_rocm_ver"
- [ -n "$_setup_mkt" ] && [ -n "$_setup_gfx" ] && substep "GPU: $_setup_mkt"
elif [ "$_setup_xpu_ready" = true ]; then
# Ranks below NVIDIA and AMD, as in setup.ps1: those hosts get their own wheels.
step "gpu" "Intel GPU detected (XPU runtime)"
diff --git a/tests/studio/install/test_rocm_support.py b/tests/studio/install/test_rocm_support.py
index 44cf0ad7d2b..76f7224a2d8 100644
--- a/tests/studio/install/test_rocm_support.py
+++ b/tests/studio/install/test_rocm_support.py
@@ -6118,7 +6118,12 @@ class TestHipSdkEnvPathResolution:
def _assert_accepts_partial_hipinfo_output(source: str):
hipout_idx = source.find("$hipOut = & $hipinfoExe.Source")
assert hipout_idx != -1
- hipinfo_block = source[hipout_idx : hipout_idx + 1600]
+ # Bound the probe at the `catch` closing its own try, not at a character
+ # count: the block grows whenever the hipinfo parse gains a branch, and a
+ # fixed slice then drops the diagnostic off the end and fails on correct code.
+ end_idx = source.find("} catch {", hipout_idx)
+ assert end_idx != -1
+ hipinfo_block = source[hipout_idx:end_idx]
assert 'if ($hipOut -match "(?i)gcnArchName")' in hipinfo_block
assert "$LASTEXITCODE -eq 0 -and $hipOut -match" not in hipinfo_block
assert "but reported gcnArchName" in hipinfo_block