MCPcopy Create free account
hub / github.com/unslothai/unsloth / _amd_smi_allowed

Function _amd_smi_allowed

studio/install_python_stack.py:318–344  ·  view source on GitHub ↗

Whether it is safe to spawn amd-smi here. On Windows w/o a working HIP runtime, amd-smi elevates a child and pops a UAC/DiskPart prompt RunAsInvoker can't suppress. Only call it on Windows with a HIP SDK (hipinfo present) or UNSLOTH_ENABLE_AMD_SMI=1; Linux/macOS always.

()

Source from the content-addressed store, hash-verified

316
317
318def _amd_smi_allowed() -> bool:
319 """Whether it is safe to spawn amd-smi here.
320
321 On Windows w/o a working HIP runtime, amd-smi elevates a child and pops a
322 UAC/DiskPart prompt RunAsInvoker can't suppress. Only call it on Windows with
323 a HIP SDK (hipinfo present) or UNSLOTH_ENABLE_AMD_SMI=1; Linux/macOS always.
324 """
325 if platform.system() != "Windows":
326 return True
327 flag = os.environ.get("UNSLOTH_ENABLE_AMD_SMI", "").strip().lower()
328 if flag in ("1", "true", "yes", "on"):
329 return True
330 if flag in ("0", "false", "no", "off"):
331 return False
332 # A real HIP SDK lets amd-smi run un-elevated; hipinfo-on-PATH is the proxy.
333 # Ignore the venv hipInfo.exe (AMD wheel via bnb fix): not a HIP SDK, doesn't
334 # stop amd-smi's DiskPart UAC.
335 if _external_hipinfo_on_path():
336 return True
337 for _var in ("HIP_PATH", "HIP_PATH_57", "ROCM_PATH"):
338 _root = os.environ.get(_var)
339 if not _root:
340 continue
341 _candidate = os.path.join(_root, "bin", "hipinfo.exe")
342 if os.path.isfile(_candidate) and not _path_inside_venv(_candidate):
343 return True
344 return False
345
346
347def _detect_rocm_version() -> tuple[int, int] | None:

Callers 5

_detect_rocm_versionFunction · 0.70
_detect_windows_gfx_archFunction · 0.70
_has_rocm_gpuFunction · 0.70
_detect_amd_gfx_codesFunction · 0.70
install_python_stackFunction · 0.70

Calls 4

_path_inside_venvFunction · 0.70
getMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…