Merge pull request #4743 from resonantsky/dev

ROCm default system path corrections
This commit is contained in:
Vladimir Mandic
2026-04-09 09:06:15 +02:00
committed by GitHub
3 changed files with 55 additions and 15 deletions
+52 -1
View File
@@ -115,8 +115,59 @@ def _get_root() -> str:
return str(script_path)
_libs_pkg_cache: Optional[str] = None
def _get_libs_pkg() -> str:
"""Return the _rocm_sdk_libraries_<gfx> folder name present in site-packages, or ''.
Scans site-packages for a directory matching '_rocm_sdk_libraries_*'.
When multiple are found (unusual), prefers the one matching the detected GPU
via modules.rocm; falls back to the first candidate.
Result is cached for the process lifetime.
"""
global _libs_pkg_cache # pylint: disable=global-statement
if _libs_pkg_cache is not None:
return _libs_pkg_cache
import sysconfig # pylint: disable=import-outside-toplevel
site_pkgs = sysconfig.get_path('purelib')
if not site_pkgs or not os.path.isdir(site_pkgs):
_libs_pkg_cache = ""
return ""
try:
candidates = [e for e in os.listdir(site_pkgs) if e.startswith("_rocm_sdk_libraries_")]
except OSError:
_libs_pkg_cache = ""
return ""
if not candidates:
_libs_pkg_cache = ""
return ""
if len(candidates) == 1:
_libs_pkg_cache = candidates[0]
return _libs_pkg_cache
# Multiple libraries packages — pick the one matching the active GPU
try:
from modules import rocm as _rocm # pylint: disable=import-outside-toplevel
import torch # pylint: disable=import-outside-toplevel
for i in range(torch.cuda.device_count()):
agent = _rocm.Agent(i)
therock = agent.therock
if therock:
suffix = therock.split("/")[-1].replace("-", "_")
folder = "_rocm_sdk_libraries_" + suffix
if folder in candidates:
_libs_pkg_cache = folder
return _libs_pkg_cache
except Exception:
pass
_libs_pkg_cache = candidates[0]
return _libs_pkg_cache
def _expand_venv(value: str) -> str:
return value.replace("{VIRTUAL_ENV}", _get_venv()).replace("{ROOT}", _get_root())
return (value
.replace("{VIRTUAL_ENV}", _get_venv())
.replace("{ROOT}", _get_root())
.replace("{LIBS_PKG}", _get_libs_pkg()))
def _collapse_venv(value: str) -> str:
+3 -3
View File
@@ -16,14 +16,14 @@ def _sitepackages_subpath(*parts: str) -> str:
GENERAL_VARS: Dict[str, Dict[str, Any]] = {
"MIOPEN_SYSTEM_DB_PATH": {
"default": _sitepackages_subpath("_rocm_sdk_devel", "bin") + os.sep,
"desc": "MIOpen system DB path",
"default": _sitepackages_subpath("{LIBS_PKG}", "bin") + os.sep,
"desc": "MIOpen system path",
"widget": "textbox",
"options": None,
"restart_required": True,
},
"ROCBLAS_TENSILE_LIBPATH": {
"default": _sitepackages_subpath("_rocm_sdk_devel", "bin", "rocblas", "library"),
"default": _sitepackages_subpath("{LIBS_PKG}", "bin", "rocblas", "library"),
"desc": "rocBLAS Tensile library path",
"widget": "textbox",
"options": None,
-11
View File
@@ -47,22 +47,11 @@ class ROCmScript(scripts_manager.Script):
section("ROCm / HIP")
for k, v in d.get("rocm", {}).items():
row(k, v)
section("System DB")
sdb = d.get("system_db", {})
row("path", sdb.get("path", ""))
for sub in ("solver_db", "find_db", "kernel_db"):
for fname, sz in sdb.get(sub, {}).items():
row(sub.replace("_", " "), f"{fname} &nbsp; {sz}")
section("User DB (~/.miopen/db)")
udb = d.get("user_db", {})
row("path", udb.get("path", ""))
for fname, finfo in udb.get("files", {}).items():
row(fname, finfo)
section("User cache (~/.miopen/cache)")
ucache = d.get("user_cache", {})
row("path", ucache.get("path", ""))
for fname, sz in ucache.get("files", {}).items():
row(fname, sz)
return f"<table style='width:100%;border-collapse:collapse'>{''.join(rows)}</table>"
def _build_style(unavailable, hipblaslt_disabled=False):