From 7d6ac653746a4ce88f992c14ff79b99b92acb978 Mon Sep 17 00:00:00 2001 From: Daniel Han Date: Tue, 31 Mar 2026 09:37:07 +0000 Subject: [PATCH] Harden hipconfig version parsing and torch probe compatibility - Add parts[1].isdigit() check in hipconfig version parsing to handle versions like "6.3-HIP" where the minor component has non-numeric suffix (strip "-" prefix before int() conversion) - Use getattr() in torch probe subprocess to safely handle old or custom torch builds that may lack torch.version.hip/cuda attributes --- studio/install_python_stack.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/studio/install_python_stack.py b/studio/install_python_stack.py index 48d95c9b03..e3b282a667 100644 --- a/studio/install_python_stack.py +++ b/studio/install_python_stack.py @@ -72,8 +72,8 @@ def _detect_rocm_version() -> tuple[int, int] | None: if result.returncode == 0: raw = result.stdout.decode().strip().split("\n")[0] parts = raw.split(".") - if len(parts) >= 2 and parts[0].isdigit(): - return int(parts[0]), int(parts[1]) + if len(parts) >= 2 and parts[0].isdigit() and parts[1].split("-")[0].isdigit(): + return int(parts[0]), int(parts[1].split("-")[0]) except Exception: pass @@ -130,7 +130,7 @@ def _ensure_rocm_torch() -> None: [ sys.executable, "-c", - "import torch; print(torch.version.hip or torch.version.cuda or '')", + "import torch; v=torch.version; print(getattr(v,'hip','') or getattr(v,'cuda','') or '')", ], stdout = subprocess.PIPE, stderr = subprocess.DEVNULL,