From bbac8453d253ba9c5319fd5d776151d1d41392ba Mon Sep 17 00:00:00 2001 From: Felipe Arce Date: Fri, 26 Jun 2026 19:25:58 -0400 Subject: [PATCH 1/6] add intel xpu-smi gpu detection to local discovery --- src/modelinfo/hardware.py | 47 +++++++++++++++++++++++++++++++++++- tests/test_hardware.py | 50 ++++++++++++++++++++++++++++++++++++++- 2 files changed, 95 insertions(+), 2 deletions(-) diff --git a/src/modelinfo/hardware.py b/src/modelinfo/hardware.py index 1170352..2254fff 100644 --- a/src/modelinfo/hardware.py +++ b/src/modelinfo/hardware.py @@ -218,7 +218,52 @@ def detect_local_gpu() -> Tuple[str, float, int]: except Exception: pass - # 3. Apple Silicon + # 3. Intel (xpu-smi) + try: + result = subprocess.run( + ["xpu-smi", "discovery"], + capture_output=True, + text=True, + check=True, + timeout=2.0, + ) + gpu_names: list[str] = [] + total_mib: float = 0.0 + + for line in result.stdout.splitlines(): + lower_line = line.lower() + if "device name:" in lower_line: + idx = lower_line.index("device name:") + name = line[idx + len("device name:"):].split("|")[0].strip() + gpu_names.append(name) + elif "memory physical size:" in lower_line: + idx = lower_line.index("memory physical size:") + size_str = line[idx + len("memory physical size:"):].split("|")[0].strip() + match = re.search(r"([\d\.]+)", size_str) + if match: + val = float(match.group(1)) + unit_match = re.search(r"([a-zA-Z]+)", size_str) + if unit_match: + unit = unit_match.group(1).lower() + if unit in ("gib", "gb"): + val *= 1024.0 + elif unit in ("kib", "kb"): + val /= 1024.0 + elif unit == "b": + val /= (1024.0 * 1024.0) + total_mib += val + + if gpu_names: + gpu_count = len(gpu_names) + first_name = gpu_names[0] + display_name = ( + f"Intel Multi-GPU ({gpu_count}x {first_name})" if gpu_count > 1 else first_name + ) + return display_name, total_mib / 1024.0, gpu_count + except Exception: + pass + + # 4. Apple Silicon try: result = subprocess.run( ["sysctl", "hw.memsize"], diff --git a/tests/test_hardware.py b/tests/test_hardware.py index a2d2a9d..ef53049 100644 --- a/tests/test_hardware.py +++ b/tests/test_hardware.py @@ -108,10 +108,58 @@ def fake_run(command, **kwargs): assert hardware.detect_local_gpu() == ("AMD Multi-GPU (2x)", 32.0, 2) -def test_detect_local_gpu_falls_back_to_apple_unified_memory(monkeypatch): +def test_detect_local_gpu_falls_back_to_xpu_smi(monkeypatch): def fake_run(command, **kwargs): if command[0] in {"nvidia-smi", "rocm-smi"}: raise FileNotFoundError(command[0]) + assert command == ["xpu-smi", "discovery"] + stdout = ( + "+-----------+------------------------------------------------------+\n" + "| Device ID | Device Information |\n" + "+-----------+------------------------------------------------------+\n" + "| 0 | Device Name: Intel(R) Arc(TM) A770 Graphics |\n" + "| | Vendor Name: Intel(R) Corporation |\n" + "| | Memory Physical Size: 16384.00 MiB |\n" + "+-----------+------------------------------------------------------+\n" + ) + return completed(stdout) + + monkeypatch.setattr(hardware.subprocess, "run", fake_run) + + assert hardware.detect_local_gpu() == ("Intel(R) Arc(TM) A770 Graphics", 16.0, 1) + + +def test_detect_local_gpu_sums_multiple_intel_gpus(monkeypatch): + def fake_run(command, **kwargs): + if command[0] in {"nvidia-smi", "rocm-smi"}: + raise FileNotFoundError(command[0]) + assert command == ["xpu-smi", "discovery"] + stdout = ( + "+-----------+------------------------------------------------------+\n" + "| Device ID | Device Information |\n" + "+-----------+------------------------------------------------------+\n" + "| 0 | Device Name: Intel(R) Data Center GPU Flex 170 |\n" + "| | Memory Physical Size: 16384.00 MiB |\n" + "+-----------+------------------------------------------------------+\n" + "| 1 | Device Name: Intel(R) Data Center GPU Flex 170 |\n" + "| | Memory Physical Size: 16384.00 MiB |\n" + "+-----------+------------------------------------------------------+\n" + ) + return completed(stdout) + + monkeypatch.setattr(hardware.subprocess, "run", fake_run) + + assert hardware.detect_local_gpu() == ( + "Intel Multi-GPU (2x Intel(R) Data Center GPU Flex 170)", + 32.0, + 2, + ) + + +def test_detect_local_gpu_falls_back_to_apple_unified_memory(monkeypatch): + def fake_run(command, **kwargs): + if command[0] in {"nvidia-smi", "rocm-smi", "xpu-smi"}: + raise FileNotFoundError(command[0]) assert command == ["sysctl", "hw.memsize"] return completed("hw.memsize: 17179869184\n") From 3017db179932dff6e2304d60021e6c6d70c2dadb Mon Sep 17 00:00:00 2001 From: Felipe Arce Date: Fri, 26 Jun 2026 19:32:03 -0400 Subject: [PATCH 2/6] refactor detect_local_gpu and fix intel parsing fallback guard --- src/modelinfo/hardware.py | 42 +++++++++++++++++++++++++------ tests/test_hardware.py | 53 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 88 insertions(+), 7 deletions(-) diff --git a/src/modelinfo/hardware.py b/src/modelinfo/hardware.py index 2254fff..909dff3 100644 --- a/src/modelinfo/hardware.py +++ b/src/modelinfo/hardware.py @@ -1,6 +1,6 @@ import re import subprocess -from typing import Tuple +from typing import Optional, Tuple KNOWN_GPUS = { # --- NVIDIA Consumer (RTX 50/40/30/20/10 Series & Titans) --- @@ -157,8 +157,7 @@ def normalize_gpu_string(name: str) -> str: return re.sub(r"[\s\-]", "", name) -def detect_local_gpu() -> Tuple[str, float, int]: - # 1. NVIDIA +def _detect_nvidia_gpu() -> Optional[Tuple[str, float, int]]: try: result = subprocess.run( [ @@ -189,8 +188,10 @@ def detect_local_gpu() -> Tuple[str, float, int]: return display_name, total_mb / 1024.0, gpu_count except Exception: pass + return None - # 2. AMD (ROCm) + +def _detect_amd_gpu() -> Optional[Tuple[str, float, int]]: try: result = subprocess.run( ["rocm-smi", "--showmeminfo", "vram"], @@ -217,8 +218,10 @@ def detect_local_gpu() -> Tuple[str, float, int]: return display_name, total_bytes / (1024.0**3), gpu_count except Exception: pass + return None - # 3. Intel (xpu-smi) + +def _detect_intel_gpu() -> Optional[Tuple[str, float, int]]: try: result = subprocess.run( ["xpu-smi", "discovery"], @@ -253,7 +256,7 @@ def detect_local_gpu() -> Tuple[str, float, int]: val /= (1024.0 * 1024.0) total_mib += val - if gpu_names: + if gpu_names and total_mib > 0.0: gpu_count = len(gpu_names) first_name = gpu_names[0] display_name = ( @@ -262,8 +265,10 @@ def detect_local_gpu() -> Tuple[str, float, int]: return display_name, total_mib / 1024.0, gpu_count except Exception: pass + return None - # 4. Apple Silicon + +def _detect_apple_gpu() -> Optional[Tuple[str, float, int]]: try: result = subprocess.run( ["sysctl", "hw.memsize"], @@ -278,6 +283,29 @@ def detect_local_gpu() -> Tuple[str, float, int]: return "Apple Silicon (Unified Memory)", vram_gb, 1 except Exception: pass + return None + + +def detect_local_gpu() -> Tuple[str, float, int]: + # 1. NVIDIA + nvidia_res = _detect_nvidia_gpu() + if nvidia_res is not None: + return nvidia_res + + # 2. AMD (ROCm) + amd_res = _detect_amd_gpu() + if amd_res is not None: + return amd_res + + # 3. Intel (xpu-smi) + intel_res = _detect_intel_gpu() + if intel_res is not None: + return intel_res + + # 4. Apple Silicon + apple_res = _detect_apple_gpu() + if apple_res is not None: + return apple_res return "Unknown", 8.0, 1 diff --git a/tests/test_hardware.py b/tests/test_hardware.py index ef53049..aa6d69c 100644 --- a/tests/test_hardware.py +++ b/tests/test_hardware.py @@ -156,6 +156,59 @@ def fake_run(command, **kwargs): ) +def test_detect_local_gpu_intel_unit_conversions(monkeypatch): + test_cases = [ + ("16.00 GiB", 16.0), + ("16.00 GB", 16.0), + ("16777216.00 KiB", 16.0), + ("17179869184.00 B", 16.0), + ("16384.00 MiB", 16.0), + ("16384.00 MB", 16.0), + ("16384.00", 16.0), # Default MiB unit + ] + for size_str, expected_vram in test_cases: + def fake_run(command, **kwargs): + if command[0] in {"nvidia-smi", "rocm-smi"}: + raise FileNotFoundError(command[0]) + assert command == ["xpu-smi", "discovery"] + stdout = ( + "+-----------+------------------------------------------------------+\n" + "| Device ID | Device Information |\n" + "+-----------+------------------------------------------------------+\n" + "| 0 | Device Name: Intel(R) Arc(TM) A770 Graphics |\n" + f"| | Memory Physical Size: {size_str} |\n" + "+-----------+------------------------------------------------------+\n" + ) + return completed(stdout) + + monkeypatch.setattr(hardware.subprocess, "run", fake_run) + assert hardware.detect_local_gpu() == ("Intel(R) Arc(TM) A770 Graphics", expected_vram, 1) + + +def test_detect_local_gpu_falls_back_on_malformed_xpu_smi(monkeypatch): + def fake_run(command, **kwargs): + if command[0] in {"nvidia-smi", "rocm-smi"}: + raise FileNotFoundError(command[0]) + if command[0] == "xpu-smi": + # Returns device name but no parseable memory size + stdout = ( + "+-----------+------------------------------------------------------+\n" + "| Device ID | Device Information |\n" + "+-----------+------------------------------------------------------+\n" + "| 0 | Device Name: Intel(R) Arc(TM) A770 Graphics |\n" + "| | Vendor Name: Intel(R) Corporation |\n" + "| | Memory Physical Size: N/A |\n" + "+-----------+------------------------------------------------------+\n" + ) + return completed(stdout) + raise FileNotFoundError(command[0]) + + monkeypatch.setattr(hardware.subprocess, "run", fake_run) + + # Since xpu-smi didn't return valid memory, detect_local_gpu should fall back to default/next + assert hardware.detect_local_gpu() == ("Unknown", 8.0, 1) + + def test_detect_local_gpu_falls_back_to_apple_unified_memory(monkeypatch): def fake_run(command, **kwargs): if command[0] in {"nvidia-smi", "rocm-smi", "xpu-smi"}: From 40102dc1b5527207916a874201315a9277741e68 Mon Sep 17 00:00:00 2001 From: Felipe Arce Date: Fri, 26 Jun 2026 19:37:02 -0400 Subject: [PATCH 3/6] fix loop variable binding warning and ensure all devices have memory --- src/modelinfo/hardware.py | 4 +++- tests/test_hardware.py | 29 +++++++++++++++++++++++++++-- 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/src/modelinfo/hardware.py b/src/modelinfo/hardware.py index 909dff3..32e2c8b 100644 --- a/src/modelinfo/hardware.py +++ b/src/modelinfo/hardware.py @@ -232,6 +232,7 @@ def _detect_intel_gpu() -> Optional[Tuple[str, float, int]]: ) gpu_names: list[str] = [] total_mib: float = 0.0 + parsed_memory_entries: int = 0 for line in result.stdout.splitlines(): lower_line = line.lower() @@ -255,8 +256,9 @@ def _detect_intel_gpu() -> Optional[Tuple[str, float, int]]: elif unit == "b": val /= (1024.0 * 1024.0) total_mib += val + parsed_memory_entries += 1 - if gpu_names and total_mib > 0.0: + if gpu_names and parsed_memory_entries == len(gpu_names) and total_mib > 0.0: gpu_count = len(gpu_names) first_name = gpu_names[0] display_name = ( diff --git a/tests/test_hardware.py b/tests/test_hardware.py index aa6d69c..d24f4df 100644 --- a/tests/test_hardware.py +++ b/tests/test_hardware.py @@ -167,7 +167,7 @@ def test_detect_local_gpu_intel_unit_conversions(monkeypatch): ("16384.00", 16.0), # Default MiB unit ] for size_str, expected_vram in test_cases: - def fake_run(command, **kwargs): + def fake_run(command, s=size_str, **kwargs): if command[0] in {"nvidia-smi", "rocm-smi"}: raise FileNotFoundError(command[0]) assert command == ["xpu-smi", "discovery"] @@ -176,7 +176,7 @@ def fake_run(command, **kwargs): "| Device ID | Device Information |\n" "+-----------+------------------------------------------------------+\n" "| 0 | Device Name: Intel(R) Arc(TM) A770 Graphics |\n" - f"| | Memory Physical Size: {size_str} |\n" + f"| | Memory Physical Size: {s} |\n" "+-----------+------------------------------------------------------+\n" ) return completed(stdout) @@ -209,6 +209,31 @@ def fake_run(command, **kwargs): assert hardware.detect_local_gpu() == ("Unknown", 8.0, 1) +def test_detect_local_gpu_falls_back_on_mismatched_intel_count(monkeypatch): + def fake_run(command, **kwargs): + if command[0] in {"nvidia-smi", "rocm-smi"}: + raise FileNotFoundError(command[0]) + if command[0] == "xpu-smi": + # 2 GPUs, but only 1 has memory size + stdout = ( + "+-----------+------------------------------------------------------+\n" + "| Device ID | Device Information |\n" + "+-----------+------------------------------------------------------+\n" + "| 0 | Device Name: Intel(R) Arc(TM) A770 Graphics |\n" + "| | Memory Physical Size: 16384.00 MiB |\n" + "+-----------+------------------------------------------------------+\n" + "| 1 | Device Name: Intel(R) Arc(TM) A770 Graphics |\n" + "+-----------+------------------------------------------------------+\n" + ) + return completed(stdout) + raise FileNotFoundError(command[0]) + + monkeypatch.setattr(hardware.subprocess, "run", fake_run) + + # Since device count (2) != memory entries count (1), it must fall back + assert hardware.detect_local_gpu() == ("Unknown", 8.0, 1) + + def test_detect_local_gpu_falls_back_to_apple_unified_memory(monkeypatch): def fake_run(command, **kwargs): if command[0] in {"nvidia-smi", "rocm-smi", "xpu-smi"}: From 9c67660b85b880853c8e1302d3eca36059822d27 Mon Sep 17 00:00:00 2001 From: Felipe Arce Date: Fri, 26 Jun 2026 19:39:28 -0400 Subject: [PATCH 4/6] clean up regex parsing and annotate test assertions with nosec --- src/modelinfo/hardware.py | 18 ++++++++---------- tests/test_hardware.py | 16 ++++++++-------- 2 files changed, 16 insertions(+), 18 deletions(-) diff --git a/src/modelinfo/hardware.py b/src/modelinfo/hardware.py index 32e2c8b..57cfb2d 100644 --- a/src/modelinfo/hardware.py +++ b/src/modelinfo/hardware.py @@ -243,18 +243,16 @@ def _detect_intel_gpu() -> Optional[Tuple[str, float, int]]: elif "memory physical size:" in lower_line: idx = lower_line.index("memory physical size:") size_str = line[idx + len("memory physical size:"):].split("|")[0].strip() - match = re.search(r"([\d\.]+)", size_str) + match = re.search(r"([\d\.]+)\s*([a-zA-Z]*)", size_str) if match: val = float(match.group(1)) - unit_match = re.search(r"([a-zA-Z]+)", size_str) - if unit_match: - unit = unit_match.group(1).lower() - if unit in ("gib", "gb"): - val *= 1024.0 - elif unit in ("kib", "kb"): - val /= 1024.0 - elif unit == "b": - val /= (1024.0 * 1024.0) + unit = match.group(2).lower() + if unit in ("gib", "gb"): + val *= 1024.0 + elif unit in ("kib", "kb"): + val /= 1024.0 + elif unit == "b": + val /= (1024.0 * 1024.0) total_mib += val parsed_memory_entries += 1 diff --git a/tests/test_hardware.py b/tests/test_hardware.py index d24f4df..60d84c4 100644 --- a/tests/test_hardware.py +++ b/tests/test_hardware.py @@ -112,7 +112,7 @@ def test_detect_local_gpu_falls_back_to_xpu_smi(monkeypatch): def fake_run(command, **kwargs): if command[0] in {"nvidia-smi", "rocm-smi"}: raise FileNotFoundError(command[0]) - assert command == ["xpu-smi", "discovery"] + assert command == ["xpu-smi", "discovery"] # nosec stdout = ( "+-----------+------------------------------------------------------+\n" "| Device ID | Device Information |\n" @@ -126,14 +126,14 @@ def fake_run(command, **kwargs): monkeypatch.setattr(hardware.subprocess, "run", fake_run) - assert hardware.detect_local_gpu() == ("Intel(R) Arc(TM) A770 Graphics", 16.0, 1) + assert hardware.detect_local_gpu() == ("Intel(R) Arc(TM) A770 Graphics", 16.0, 1) # nosec def test_detect_local_gpu_sums_multiple_intel_gpus(monkeypatch): def fake_run(command, **kwargs): if command[0] in {"nvidia-smi", "rocm-smi"}: raise FileNotFoundError(command[0]) - assert command == ["xpu-smi", "discovery"] + assert command == ["xpu-smi", "discovery"] # nosec stdout = ( "+-----------+------------------------------------------------------+\n" "| Device ID | Device Information |\n" @@ -149,7 +149,7 @@ def fake_run(command, **kwargs): monkeypatch.setattr(hardware.subprocess, "run", fake_run) - assert hardware.detect_local_gpu() == ( + assert hardware.detect_local_gpu() == ( # nosec "Intel Multi-GPU (2x Intel(R) Data Center GPU Flex 170)", 32.0, 2, @@ -170,7 +170,7 @@ def test_detect_local_gpu_intel_unit_conversions(monkeypatch): def fake_run(command, s=size_str, **kwargs): if command[0] in {"nvidia-smi", "rocm-smi"}: raise FileNotFoundError(command[0]) - assert command == ["xpu-smi", "discovery"] + assert command == ["xpu-smi", "discovery"] # nosec stdout = ( "+-----------+------------------------------------------------------+\n" "| Device ID | Device Information |\n" @@ -182,7 +182,7 @@ def fake_run(command, s=size_str, **kwargs): return completed(stdout) monkeypatch.setattr(hardware.subprocess, "run", fake_run) - assert hardware.detect_local_gpu() == ("Intel(R) Arc(TM) A770 Graphics", expected_vram, 1) + assert hardware.detect_local_gpu() == ("Intel(R) Arc(TM) A770 Graphics", expected_vram, 1) # nosec def test_detect_local_gpu_falls_back_on_malformed_xpu_smi(monkeypatch): @@ -206,7 +206,7 @@ def fake_run(command, **kwargs): monkeypatch.setattr(hardware.subprocess, "run", fake_run) # Since xpu-smi didn't return valid memory, detect_local_gpu should fall back to default/next - assert hardware.detect_local_gpu() == ("Unknown", 8.0, 1) + assert hardware.detect_local_gpu() == ("Unknown", 8.0, 1) # nosec def test_detect_local_gpu_falls_back_on_mismatched_intel_count(monkeypatch): @@ -231,7 +231,7 @@ def fake_run(command, **kwargs): monkeypatch.setattr(hardware.subprocess, "run", fake_run) # Since device count (2) != memory entries count (1), it must fall back - assert hardware.detect_local_gpu() == ("Unknown", 8.0, 1) + assert hardware.detect_local_gpu() == ("Unknown", 8.0, 1) # nosec def test_detect_local_gpu_falls_back_to_apple_unified_memory(monkeypatch): From 485a5d1d2d85cd2062da753896d7a921748b803e Mon Sep 17 00:00:00 2001 From: Felipe Arce Date: Fri, 26 Jun 2026 19:42:43 -0400 Subject: [PATCH 5/6] reduce _detect_intel_gpu cyclomatic complexity --- src/modelinfo/hardware.py | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/src/modelinfo/hardware.py b/src/modelinfo/hardware.py index 57cfb2d..f9d2d85 100644 --- a/src/modelinfo/hardware.py +++ b/src/modelinfo/hardware.py @@ -221,6 +221,21 @@ def _detect_amd_gpu() -> Optional[Tuple[str, float, int]]: return None +def _parse_intel_vram(size_str: str) -> Optional[float]: + match = re.search(r"([\d\.]+)\s*([a-zA-Z]*)", size_str) + if not match: + return None + val = float(match.group(1)) + unit = match.group(2).lower() + if unit in ("gib", "gb"): + val *= 1024.0 + elif unit in ("kib", "kb"): + val /= 1024.0 + elif unit == "b": + val /= (1024.0 * 1024.0) + return val + + def _detect_intel_gpu() -> Optional[Tuple[str, float, int]]: try: result = subprocess.run( @@ -243,16 +258,8 @@ def _detect_intel_gpu() -> Optional[Tuple[str, float, int]]: elif "memory physical size:" in lower_line: idx = lower_line.index("memory physical size:") size_str = line[idx + len("memory physical size:"):].split("|")[0].strip() - match = re.search(r"([\d\.]+)\s*([a-zA-Z]*)", size_str) - if match: - val = float(match.group(1)) - unit = match.group(2).lower() - if unit in ("gib", "gb"): - val *= 1024.0 - elif unit in ("kib", "kb"): - val /= 1024.0 - elif unit == "b": - val /= (1024.0 * 1024.0) + val = _parse_intel_vram(size_str) + if val is not None: total_mib += val parsed_memory_entries += 1 From 52c83f0f1385c2ccbedbf0a0edae6eb4de3aca25 Mon Sep 17 00:00:00 2001 From: Felipe Arce Date: Fri, 26 Jun 2026 19:45:36 -0400 Subject: [PATCH 6/6] further reduce _detect_intel_gpu complexity by extracting output parsing --- src/modelinfo/hardware.py | 40 ++++++++++++++++++++++----------------- 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/src/modelinfo/hardware.py b/src/modelinfo/hardware.py index f9d2d85..a785944 100644 --- a/src/modelinfo/hardware.py +++ b/src/modelinfo/hardware.py @@ -236,6 +236,28 @@ def _parse_intel_vram(size_str: str) -> Optional[float]: return val +def _parse_xpu_smi_output(stdout: str) -> Tuple[list[str], float, int]: + gpu_names: list[str] = [] + total_mib: float = 0.0 + parsed_memory_entries: int = 0 + + for line in stdout.splitlines(): + lower_line = line.lower() + if "device name:" in lower_line: + idx = lower_line.index("device name:") + name = line[idx + len("device name:"):].split("|")[0].strip() + gpu_names.append(name) + elif "memory physical size:" in lower_line: + idx = lower_line.index("memory physical size:") + size_str = line[idx + len("memory physical size:"):].split("|")[0].strip() + val = _parse_intel_vram(size_str) + if val is not None: + total_mib += val + parsed_memory_entries += 1 + + return gpu_names, total_mib, parsed_memory_entries + + def _detect_intel_gpu() -> Optional[Tuple[str, float, int]]: try: result = subprocess.run( @@ -245,23 +267,7 @@ def _detect_intel_gpu() -> Optional[Tuple[str, float, int]]: check=True, timeout=2.0, ) - gpu_names: list[str] = [] - total_mib: float = 0.0 - parsed_memory_entries: int = 0 - - for line in result.stdout.splitlines(): - lower_line = line.lower() - if "device name:" in lower_line: - idx = lower_line.index("device name:") - name = line[idx + len("device name:"):].split("|")[0].strip() - gpu_names.append(name) - elif "memory physical size:" in lower_line: - idx = lower_line.index("memory physical size:") - size_str = line[idx + len("memory physical size:"):].split("|")[0].strip() - val = _parse_intel_vram(size_str) - if val is not None: - total_mib += val - parsed_memory_entries += 1 + gpu_names, total_mib, parsed_memory_entries = _parse_xpu_smi_output(result.stdout) if gpu_names and parsed_memory_entries == len(gpu_names) and total_mib > 0.0: gpu_count = len(gpu_names)