From 0facfbc4bcb27cf37477e574c80738a7a3a1a42b Mon Sep 17 00:00:00 2001 From: LeoBorcherding Date: Wed, 6 May 2026 20:45:31 -0500 Subject: [PATCH] fix: remove hardcoded non-standard ROCm paths from DLL directory scan Only use HIP_PATH/ROCM_PATH (set by AMD installer) and the standard C:\Program Files\AMD\ROCm\\bin location. Custom drive paths like F:\ROCm are user-specific and should not be hardcoded. --- studio/backend/main.py | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/studio/backend/main.py b/studio/backend/main.py index 701791f0a7..2b6619ac37 100644 --- a/studio/backend/main.py +++ b/studio/backend/main.py @@ -21,21 +21,25 @@ if sys.platform == "win32": import ctypes as _ctypes def _add_rocm_dll_dirs() -> None: - hip_path = os.environ.get("HIP_PATH") or os.environ.get("ROCM_PATH") candidates = [] - if hip_path: - candidates.append(os.path.join(hip_path, "bin")) - # Also scan common install roots in case HIP_PATH is not set - for _root in (r"C:\Program Files\AMD\ROCm", r"F:\ROCm", r"C:\ROCm"): - try: - if os.path.isdir(_root): - for _ver in sorted(os.listdir(_root), reverse = True): - _bin = os.path.join(_root, _ver, "bin") - if os.path.isdir(_bin): - candidates.append(_bin) - break - except OSError: - pass + # 1. HIP_PATH / ROCM_PATH -- set by the AMD HIP SDK installer + for _var in ("HIP_PATH", "ROCM_PATH"): + _val = os.environ.get(_var) + if _val: + candidates.append(os.path.join(_val, "bin")) + # 2. Standard AMD installer location: C:\Program Files\AMD\ROCm\\bin + # Scan all installed versions, newest first. + _default_root = os.path.join( + os.environ.get("ProgramFiles", r"C:\Program Files"), "AMD", "ROCm" + ) + try: + if os.path.isdir(_default_root): + for _ver in sorted(os.listdir(_default_root), reverse=True): + _bin = os.path.join(_default_root, _ver, "bin") + if os.path.isdir(_bin): + candidates.append(_bin) + except OSError: + pass for _d in candidates: if os.path.isdir(_d): try: