From 2de2c29d3a7a762ae3739c1a69a764ab75868bf5 Mon Sep 17 00:00:00 2001 From: LeoBorcherding Date: Fri, 8 May 2026 03:50:46 -0500 Subject: [PATCH] fix: hide amd-smi console popups on Windows, guard torch.distributed.is_initialized for ROCm #5301 --- studio/backend/utils/hardware/amd.py | 3 +++ unsloth/models/loader_utils.py | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/studio/backend/utils/hardware/amd.py b/studio/backend/utils/hardware/amd.py index fdb1ab4520..0219407471 100644 --- a/studio/backend/utils/hardware/amd.py +++ b/studio/backend/utils/hardware/amd.py @@ -13,10 +13,12 @@ import math import os import re import subprocess +import sys from typing import Any, Optional from loggers import get_logger from utils.native_path_leases import child_env_without_native_path_secret +from utils.subprocess_compat import windows_hidden_subprocess_kwargs logger = get_logger(__name__) @@ -30,6 +32,7 @@ def _run_amd_smi(*args: str, timeout: int = 5) -> Optional[Any]: text = True, timeout = timeout, env = child_env_without_native_path_secret(), + **windows_hidden_subprocess_kwargs(), ) except (OSError, subprocess.TimeoutExpired) as e: logger.warning("amd-smi query failed: %s", e) diff --git a/unsloth/models/loader_utils.py b/unsloth/models/loader_utils.py index 99da5f799e..99c327c10a 100644 --- a/unsloth/models/loader_utils.py +++ b/unsloth/models/loader_utils.py @@ -68,7 +68,7 @@ def _get_env_int(keys): def _infer_distributed_ranks(): - if torch.distributed.is_available() and torch.distributed.is_initialized(): + if torch.distributed.is_available() and getattr(torch.distributed, "is_initialized", lambda: False)(): try: return torch.distributed.get_rank(), torch.distributed.get_world_size() except Exception: