From 86735ffad18461b5cc47e60afa76c8f04f84cbd1 Mon Sep 17 00:00:00 2001 From: Daniel Han Date: Fri, 3 Apr 2026 12:51:22 +0000 Subject: [PATCH] Fix amd-smi GPU detection for GPU[N] output format Older amd-smi versions output "GPU[0] : Card series: ..." instead of "GPU: 0". The regex now matches both "GPU: " and "GPU[" formats to detect actual GPU data rows. --- studio/install_llama_prebuilt.py | 2 +- studio/install_python_stack.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/studio/install_llama_prebuilt.py b/studio/install_llama_prebuilt.py index 75c6ae8f54..9b76548c23 100755 --- a/studio/install_llama_prebuilt.py +++ b/studio/install_llama_prebuilt.py @@ -2553,7 +2553,7 @@ def detect_host() -> HostInfo: def _amd_smi_has_gpu(stdout: str) -> bool: """Check for 'GPU: ' data rows, not just a table header.""" - return bool(_re.search(r"(?im)^gpu\s*:\s*\d", stdout)) + return bool(_re.search(r"(?im)^gpu\s*[:\[]\s*\d", stdout)) has_rocm = False if is_linux: diff --git a/studio/install_python_stack.py b/studio/install_python_stack.py index 9657c65205..e4c4576fbf 100644 --- a/studio/install_python_stack.py +++ b/studio/install_python_stack.py @@ -112,7 +112,7 @@ def _has_rocm_gpu() -> bool: # rocminfo: look for "Name: gfxNNNN" indicating an actual GPU agent (["rocminfo"], lambda out: "gfx" in out.lower()), # amd-smi list: require "GPU: " data rows, not just a header - (["amd-smi", "list"], lambda out: bool(re.search(r"(?im)^gpu\s*:\s*\d", out))), + (["amd-smi", "list"], lambda out: bool(re.search(r"(?im)^gpu\s*[:\[]\s*\d", out))), ): exe = shutil.which(cmd[0]) if not exe: @@ -756,7 +756,7 @@ def install_python_stack() -> int: import re as _re_win def _win_amd_smi_has_gpu(stdout: str) -> bool: - return bool(_re_win.search(r"(?im)^gpu\s*:\s*\d", stdout)) + return bool(_re_win.search(r"(?im)^gpu\s*[:\[]\s*\d", stdout)) _win_amd_gpu = False for _wcmd, _check_fn in (