From 7484aee5d40f1db32533dbca6e720be7a61343fb Mon Sep 17 00:00:00 2001 From: resonantsky Date: Fri, 11 Sep 2026 13:50:44 +0200 Subject: [PATCH] Linux quality fixes --- scripts/rocm/rocm_mgr.py | 19 +++++++++++++++---- scripts/rocm_ext.py | 26 +------------------------- 2 files changed, 16 insertions(+), 29 deletions(-) diff --git a/scripts/rocm/rocm_mgr.py b/scripts/rocm/rocm_mgr.py index 3168ddb78..0a0ec5366 100644 --- a/scripts/rocm/rocm_mgr.py +++ b/scripts/rocm/rocm_mgr.py @@ -344,6 +344,17 @@ def clear_env() -> None: log.info(f'ROCm clear_env: cleared={cleared}') +def _miopen_user_db_path() -> Path: + """Resolve the MIOpen user DB path for the current platform.""" + configured = os.environ.get("MIOPEN_USER_DB_PATH", "") + if configured: + return Path(os.path.expandvars(os.path.expanduser(configured))) + if sys.platform == "win32": + return Path.home() / ".miopen" / "db" + cache_home = os.environ.get("XDG_CACHE_HOME", str(Path.home() / ".cache")) + return Path(cache_home) / "miopen" + + def delete_config() -> None: """Delete the saved config file, clear all vars, and wipe the MIOpen user DB cache.""" import shutil # pylint: disable=import-outside-toplevel @@ -353,8 +364,8 @@ def delete_config() -> None: CONFIG.unlink() log.info(f'ROCm delete_config: deleted {CONFIG}') _cache = None - # Delete the MIOpen user DB (~/.miopen/db) - stale entries can cause solver mismatches - miopen_db = Path(os.path.expanduser('~')) / '.miopen' / 'db' + # Delete the MIOpen user DB - stale entries can cause solver mismatches. + miopen_db = _miopen_user_db_path() if miopen_db.exists(): shutil.rmtree(miopen_db, ignore_errors=True) log.info(f'ROCm delete_config: wiped MIOpen user DB at {miopen_db}') @@ -503,8 +514,8 @@ def info() -> dict: else: sdb["exists"] = False - # --- User DB (~/.miopen/db) --- - user_db_path = Path.home() / ".miopen" / "db" + # --- User DB --- + user_db_path = _miopen_user_db_path() udb = {"path": str(user_db_path), "exists": user_db_path.exists()} if user_db_path.exists(): ufiles = _user_db_summary(user_db_path) diff --git a/scripts/rocm_ext.py b/scripts/rocm_ext.py index 463b186b2..0c4db1892 100644 --- a/scripts/rocm_ext.py +++ b/scripts/rocm_ext.py @@ -47,8 +47,8 @@ class ROCmScript(scripts_manager.Script): section("ROCm / HIP") for k, v in d.get("rocm", {}).items(): row(k, v) - section("User DB (~/.miopen/db)") udb = d.get("user_db", {}) + section("User DB") row("path", udb.get("path", "")) for fname, finfo in udb.get("files", {}).items(): row(fname, finfo) @@ -72,10 +72,6 @@ class ROCmScript(scripts_manager.Script): btn_reset = gr.Button("Defaults", elem_id="rocm_btn_reset", size="sm") btn_clear = gr.Button("Clear Run Vars", elem_id="rocm_btn_clear", size="sm") btn_delete = gr.Button("Delete UserDb", variant="stop", elem_id="rocm_btn_delete", size="sm") - with gr.Row(): - btn_rdna2 = gr.Button("RDNA2 (RX 6000)", elem_id="rocm_btn_rdna2") - btn_rdna3 = gr.Button("RDNA3 (RX 7000)", elem_id="rocm_btn_rdna3") - btn_rdna4 = gr.Button("RDNA4 (RX 9000)", elem_id="rocm_btn_rdna4") _init_gemm = config.get("MIOPEN_GEMM_ENFORCE_BACKEND", "1") _init_arch = config.get(rocm_mgr._ARCH_KEY, "") _init_unavailable = rocm_profiles.UNAVAILABLE.get(_init_arch, set()) if _init_arch else set() @@ -209,30 +205,10 @@ class ROCmScript(scripts_manager.Script): result.append(gr.update(value="")) return result - def profile_fn(arch): - rocm_mgr.apply_profile(arch) - updated = rocm_mgr.load_config() - unavailable = rocm_profiles.UNAVAILABLE.get(arch, set()) - gemm_val = updated.get("MIOPEN_GEMM_ENFORCE_BACKEND", "1") - result = [gr.update(value=_build_style(unavailable, gemm_val == "1"))] - for pname in var_names: - meta = rocm_vars.ROCM_ENV_VARS[pname] - val = updated.get(pname, meta["default"]) - if meta["widget"] == "checkbox": - result.append(gr.update(value=val == "1")) - elif meta["widget"] == "dropdown": - result.append(gr.update(value=rocm_mgr._dropdown_display(val, meta["options"]))) - else: - result.append(gr.update(value=rocm_mgr._expand_venv(val))) - return result - btn_info.click(fn=_info_html, inputs=[], outputs=[info_out], show_progress='hidden') btn_apply.click(fn=apply_fn, inputs=components, outputs=[style_out] + components, show_progress='hidden') btn_reset.click(fn=reset_fn, inputs=[], outputs=[style_out] + components, show_progress='hidden') btn_clear.click(fn=clear_fn, inputs=[], outputs=[style_out] + components, show_progress='hidden') btn_delete.click(fn=delete_fn, inputs=[], outputs=[style_out] + components, show_progress='hidden') - btn_rdna2.click(fn=lambda: profile_fn("RDNA2"), inputs=[], outputs=[style_out] + components, show_progress='hidden') - btn_rdna3.click(fn=lambda: profile_fn("RDNA3"), inputs=[], outputs=[style_out] + components, show_progress='hidden') - btn_rdna4.click(fn=lambda: profile_fn("RDNA4"), inputs=[], outputs=[style_out] + components, show_progress='hidden') return components