mirror of
https://github.com/vladmandic/automatic
synced 2026-09-18 08:44:33 +02:00
Linux quality fixes
This commit is contained in:
@@ -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)
|
||||
|
||||
+1
-25
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user