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
This commit is contained in:
parent
4286525c53
commit
7d6ac65374
1 changed files with 3 additions and 3 deletions
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue