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.
Python agentaichatgptdeepseekfine-tuninggemmaimage-generationllamallmllmsopenaipythonqwenreinforcement-learningself-hostedstable-diffusiontext-to-speechttsuiunsloth
Studio setup: read the amd-smi index-space line without head -n 1 (#12004)
Daniel Han8918f142d10a
diff --git a/install.sh b/install.shindex c8b7a10ff52..189a45d566c 100755--- a/install.sh+++ b/install.sh@@ -6636,7 +6636,7 @@ case "$_torch_index_leaf" inif [ -n "$_gfx_records" ]; then# HIP_ID from `amd-smi list -e` maps discovery order onto the order HIP numbers, as the GPU summary below does. The first output line reports which space came back._gfx_smi_out=$(amd-smi list -e 2>/dev/null | _amd_smi_hip_order "$_gfx_records" || true)- _gfx_space=$(printf '%s\n' "$_gfx_smi_out" | head -n 1)+ _gfx_space=$(printf '%s\n' "$_gfx_smi_out" | sed -n 1p)_gfx_records=$(printf '%s\n' "$_gfx_smi_out" | tail -n +2)_gfx_all=$(printf '%s\n' "$_gfx_records" | _gfx_arch_slots || true)[ -n "$_gfx_all" ] && _gfx_probe=amd-smi@@ -6897,7 +6897,7 @@ elif _torch_index_url_is_rocm "$TORCH_INDEX_URL"; thenif [ -n "$_gpu_disp_smi_records" ]; then_gpu_disp_smi_out=$(amd-smi list -e 2>/dev/null \| _amd_smi_hip_order "$_gpu_disp_smi_records" || true)- _gpu_disp_smi_space=$(printf '%s\n' "$_gpu_disp_smi_out" | head -n 1)+ _gpu_disp_smi_space=$(printf '%s\n' "$_gpu_disp_smi_out" | sed -n 1p)_gpu_disp_smi_records=$(printf '%s\n' "$_gpu_disp_smi_out" | tail -n +2)# No map, and the adapters are not interchangeable: the mask indexes HIP order while these records are in discovery order, so any ordinal is a guess. Report nothing rather than name one card while the mask selects another. amd-smi 6.1.1 reports no TARGET_GRAPHICS_VERSION at all and the arch is then inferred from the name, so an archless record is compared on its name instead. Interchangeable adapters are unaffected: every ordinal gives the same answer.if [ "$_gpu_disp_smi_space" != hip ] && \diff --git a/studio/setup.sh b/studio/setup.shindex 90a9b3fae8d..45de6e9126b 100755--- a/studio/setup.sh+++ b/studio/setup.sh@@ -3975,7 +3975,8 @@ if [ "$_setup_nvidia_usable" != true ]; thenif [ -n "$_setup_amd_records" ]; then_setup_amd_smi_out=$(_setup_run_smi amd-smi list -e 2>/dev/null \| _setup_amd_smi_hip_order "$_setup_amd_records" || true)- _setup_amd_space=$(printf '%s\n' "$_setup_amd_smi_out" | head -n 1)+ # Expansion, not `| head -n 1`: head exiting early SIGPIPEs printf under pipefail.+ _setup_amd_space=${_setup_amd_smi_out%%$'\n'*}_setup_amd_records=$(printf '%s\n' "$_setup_amd_smi_out" | tail -n +2)# No map, and the adapters are not interchangeable: the mask indexes HIP order# while these records are in discovery order, so any ordinal is a guess. Declinediff --git a/tests/sh/test_setup_gpu_summary_probe_sources.sh b/tests/sh/test_setup_gpu_summary_probe_sources.shindex 0b4ebfeb36f..e097b776b26 100755--- a/tests/sh/test_setup_gpu_summary_probe_sources.sh+++ b/tests/sh/test_setup_gpu_summary_probe_sources.sh@@ -131,7 +131,7 @@ chmod +x "$WORK/roc/rocminfo" "$WORK/smi/amd-smi"# $1 rocminfo fixture ("-" = not installed), $2 amd-smi fixture, $3 visible-device mask.# Prints "gfx|name". The probe log is left in $WORK/probes for the call-count asserts.summary() {- _path="$WORK/base"+ _path="${PREPATH:+$PREPATH:}$WORK/base"[ "$1" != "-" ] && _path="$WORK/roc:$_path"[ "$2" != "-" ] && _path="$WORK/smi:$_path": > "$WORK/probes"@@ -462,6 +462,22 @@ assert_eq "every variable the selection block reads is initialised up front" \assert_eq "amd-smi answers list but not static --asic" \"|" "$(STUB_AMDSMI_MUTE_STATIC=1 summary "$WORK/empty" "$WORK/smi_three")"+echo "=== the index-space line is read without SIGPIPE ==="+mkdir -p "$WORK/head1"+cat > "$WORK/head1/head" <<'STUB'+#!/bin/sh+IFS= read -r _l && printf '%s\n' "$_l"+STUB+chmod +x "$WORK/head1/head"+# Doubling, not sprintf("%200000s"): mawk 1.3.4 caps sprintf at 8192 bytes.+awk '/MARKET_NAME: AMD Radeon RX 7900 XTX/ { s = "X"; while (length(s) < 200000) s = s s; sub(/AMD Radeon RX 7900 XTX/, substr(s, 1, 200000)) } { print }' \+ "$WORK/smi_three" > "$WORK/smi_three_long"+assert_eq "an amd-smi answer larger than a pipe does not abort the block" \+ "gfx1100|200000" \+ "$(PREPATH="$WORK/head1" STUB_AMDSMI_E="$WORK/smi_e_reversed" \+ summary "$WORK/empty" "$WORK/smi_three_long" 1 2>/dev/null \+ | awk -F'|' '{ print $1 "|" length($2) }')"+echo ""echo "Results: $PASS passed, $FAIL failed, $SKIP skipped"[ "$FAIL" -eq 0 ]