zluda better rocm detection

This commit is contained in:
Seunghoon Lee
2024-07-21 00:09:35 +09:00
parent 7eb7dd587d
commit d3a7095683
2 changed files with 25 additions and 21 deletions
+2
View File
@@ -497,6 +497,7 @@ def install_rocm_zluda(torch_command):
os.environ.setdefault('HSA_OVERRIDE_GFX_VERSION', '10.3.0')
else:
log.debug(f'HSA_OVERRIDE_GFX_VERSION auto config is skipped for {gpu}')
try:
command = subprocess.run('hipconfig --version', shell=True, check=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
arr = command.stdout.decode(encoding="utf8", errors="ignore").split('.')
@@ -505,6 +506,7 @@ def install_rocm_zluda(torch_command):
except Exception as e:
log.debug(f'ROCm hipconfig failed: {e}')
rocm_ver = None
if args.use_zluda:
log.warning("ZLUDA support: experimental")
error = None
+23 -21
View File
@@ -14,6 +14,19 @@ class HIPSDK:
path: str
targets: Tuple[str]
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}"
def __init__(self):
if platform.system() != 'Windows':
raise RuntimeError('ZLUDA cannot be automatically installed on Linux. Please select --use-cuda for ZLUDA or --use-rocm for ROCm.')
@@ -22,24 +35,11 @@ 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 = Version(s)
version = HIPSDK.Version(s)
except Exception:
continue
if default_version is None:
@@ -48,14 +48,16 @@ class HIPSDK:
if version > default_version:
default_version = version
self.path = os.environ.get('HIP_PATH', default_version or os.path.join(rocm_path, str(default_version)))
self.path = os.environ.get('HIP_PATH', None)
if self.path is None:
raise RuntimeError('Could not find AMD HIP SDK, please install it from https://www.amd.com/en/developer/resources/rocm-hub/hip-sdk.html')
if os.environ.get("HIP_PATH_61", None) is not None:
self.version = "6.1"
elif os.environ.get("HIP_PATH_57", None) is not None:
self.version = "5.7"
if os.environ.get("HIP_PATH_61", None) is not None:
self.version = "6.1"
elif os.environ.get("HIP_PATH_57", None) is not None:
self.version = "5.7"
elif default_version is None:
raise RuntimeError('Could not find AMD HIP SDK, please install it from https://www.amd.com/en/developer/resources/rocm-hub/hip-sdk.html')
else:
self.version = str(default_version)
else:
self.version = os.path.basename(self.path) or os.path.basename(os.path.dirname(self.path))