mirror of
https://github.com/vladmandic/automatic
synced 2026-09-19 09:14:35 +02:00
prevent segfault when no hip device found
This commit is contained in:
+5
-4
@@ -484,7 +484,8 @@ def install_rocm_zluda(torch_command):
|
||||
if gpu in ['gfx1030', 'gfx1031', 'gfx1032', 'gfx1034']: # experimental navi 2x support
|
||||
hip_visible_devices.append((idx, gpu, 'navi2x'))
|
||||
break
|
||||
if len(hip_visible_devices) > 0:
|
||||
hip_found_device = len(hip_visible_devices) > 0
|
||||
if hip_found_device:
|
||||
idx, gpu, arch = hip_visible_devices[0]
|
||||
log.debug(f'ROCm agent used by default: idx={idx} gpu={gpu} arch={arch}')
|
||||
os.environ.setdefault('HIP_VISIBLE_DEVICES', str(idx))
|
||||
@@ -557,17 +558,17 @@ def install_rocm_zluda(torch_command):
|
||||
|
||||
if bool(int(os.environ.get("TORCH_BLAS_PREFER_HIPBLASLT", "1"))):
|
||||
supported_archs = []
|
||||
hipblaslt_available = True
|
||||
hipblaslt_available = hip_found_device
|
||||
libpath = os.environ.get("HIPBLASLT_TENSILE_LIBPATH", "/opt/rocm/lib/hipblaslt/library")
|
||||
for file in os.listdir(libpath):
|
||||
if not file.startswith('extop_'):
|
||||
continue
|
||||
supported_archs.append(file[6:-3])
|
||||
for gpu in amd_gpus:
|
||||
for gpu in hip_visible_devices:
|
||||
if gpu not in supported_archs:
|
||||
hipblaslt_available = False
|
||||
break
|
||||
log.info(f'hipBLASLt supported_archs={supported_archs}, available={hipblaslt_available}')
|
||||
log.debug(f'hipBLASLt supported_archs={supported_archs}, available={hipblaslt_available}')
|
||||
if hipblaslt_available:
|
||||
import ctypes
|
||||
# Preload hipBLASLt.
|
||||
|
||||
+14
-15
@@ -7,20 +7,6 @@ import urllib.request
|
||||
from typing import Tuple
|
||||
|
||||
|
||||
class HIPSDKVersion:
|
||||
major: int
|
||||
minor: int
|
||||
|
||||
def __init__(self, version: str):
|
||||
self.major, self.minor = [int(v) for v in version.strip().split(".")]
|
||||
|
||||
def __gt__(self, other):
|
||||
return self.major * 10 + other.minor > other.major * 10 + other.minor
|
||||
|
||||
def __str__(self):
|
||||
return f"{self.major}.{self.minor}"
|
||||
|
||||
|
||||
class HIPSDK:
|
||||
is_installed = False
|
||||
|
||||
@@ -36,11 +22,24 @@ class HIPSDK:
|
||||
rocm_path = rf'{program_files}\AMD\ROCm'
|
||||
default_version = None
|
||||
if os.path.exists(rocm_path):
|
||||
class Version:
|
||||
major: int
|
||||
minor: int
|
||||
|
||||
def __init__(self, version: str):
|
||||
self.major, self.minor = [int(v) for v in version.strip().split(".")]
|
||||
|
||||
def __gt__(self, other):
|
||||
return self.major * 10 + other.minor > other.major * 10 + other.minor
|
||||
|
||||
def __str__(self):
|
||||
return f"{self.major}.{self.minor}"
|
||||
|
||||
versions = os.listdir(rocm_path)
|
||||
for s in versions:
|
||||
version = None
|
||||
try:
|
||||
version = HIPSDKVersion(s)
|
||||
version = Version(s)
|
||||
except Exception:
|
||||
continue
|
||||
if default_version is None:
|
||||
|
||||
Reference in New Issue
Block a user