fix: detect AMD SDK ROCm torch via __version__ when torch.version.hip is unset
AMD's repo.radeon.com wheels (e.g. 2.9.0+rocmsdk20251116) do not set torch.version.hip, leaving it None. All three probes that relied solely on torch.version.hip now also check for 'rocm' in torch.__version__.lower(): - hardware.py detect_hardware(): IS_ROCM was never set, causing the studio to report 'Hardware detected: CPU' even after AMD wheels were installed and HIP DLLs were on PATH. - install_python_stack.py _ensure_rocm_torch(): skip-if-already-installed probe would always reinstall on subsequent runs. - install_python_stack.py Windows AMD warning: suppression check always failed, so the 'must be installed manually' note kept appearing after a successful AMD wheel install.
This commit is contained in:
parent
67d8b7481a
commit
f036ee0022
2 changed files with 25 additions and 8 deletions
|
|
@ -299,13 +299,18 @@ def _ensure_rocm_torch() -> None:
|
|||
[
|
||||
sys.executable,
|
||||
"-c",
|
||||
"import torch; print(getattr(torch.version,'hip','') or '')",
|
||||
(
|
||||
"import torch; "
|
||||
"hip=getattr(torch.version,'hip','') or ''; "
|
||||
"ver=torch.__version__; "
|
||||
"print('yes' if hip or 'rocm' in ver.lower() else '')"
|
||||
),
|
||||
],
|
||||
stdout = subprocess.PIPE,
|
||||
stderr = subprocess.DEVNULL,
|
||||
timeout = 30,
|
||||
)
|
||||
if probe.returncode == 0 and probe.stdout.decode().strip():
|
||||
if probe.returncode == 0 and probe.stdout.decode().strip() == "yes":
|
||||
return # already ROCm torch
|
||||
except (OSError, subprocess.TimeoutExpired):
|
||||
pass
|
||||
|
|
@ -1175,20 +1180,28 @@ def install_python_stack() -> int:
|
|||
_win_amd_gpu = True
|
||||
break
|
||||
if _win_amd_gpu:
|
||||
# Only warn if torch doesn't already have ROCm (HIP) support
|
||||
# Only warn if torch doesn't already have ROCm (HIP) support.
|
||||
# AMD SDK wheels (e.g. 2.9.0+rocmsdk20251116) don't set
|
||||
# torch.version.hip, so also check for "rocm" in __version__.
|
||||
try:
|
||||
_hip_ver = subprocess.run(
|
||||
_rocm_probe = subprocess.run(
|
||||
[
|
||||
sys.executable,
|
||||
"-c",
|
||||
"import torch; print(getattr(torch.version,'hip','') or '')",
|
||||
(
|
||||
"import torch; "
|
||||
"hip=getattr(torch.version,'hip','') or ''; "
|
||||
"ver=torch.__version__; "
|
||||
"print('yes' if hip or 'rocm' in ver.lower() else '')"
|
||||
),
|
||||
],
|
||||
stdout = subprocess.PIPE,
|
||||
stderr = subprocess.DEVNULL,
|
||||
timeout = 20,
|
||||
)
|
||||
_has_rocm_torch = (
|
||||
_hip_ver.returncode == 0 and _hip_ver.stdout.decode().strip() != ""
|
||||
_rocm_probe.returncode == 0
|
||||
and _rocm_probe.stdout.decode().strip() == "yes"
|
||||
)
|
||||
except Exception:
|
||||
_has_rocm_torch = False
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue