Improve device naming

This commit is contained in:
Nicolas Mowen 2026-05-13 14:30:39 -06:00
parent 740c03e627
commit 6c83a4fc80

View File

@ -39,6 +39,15 @@ class IntelGpuNameResolver:
self._names = names self._names = names
return names return names
cpu_name: Optional[str] = None
if "CPU" in devices:
try:
cpu_name = self._strip_trademarks(
core.get_property("CPU", "FULL_DEVICE_NAME")
)
except Exception as exc:
logger.debug(f"Failed to read CPU FULL_DEVICE_NAME: {exc}")
for device in devices: for device in devices:
if not device.startswith("GPU"): if not device.startswith("GPU"):
continue continue
@ -46,6 +55,7 @@ class IntelGpuNameResolver:
try: try:
pci = core.get_property(device, "DEVICE_PCI_INFO") pci = core.get_property(device, "DEVICE_PCI_INFO")
raw_name = core.get_property(device, "FULL_DEVICE_NAME") raw_name = core.get_property(device, "FULL_DEVICE_NAME")
device_type = core.get_property(device, "DEVICE_TYPE")
except Exception as exc: except Exception as exc:
logger.debug(f"Failed to read properties for {device}: {exc}") logger.debug(f"Failed to read properties for {device}: {exc}")
continue continue
@ -54,7 +64,7 @@ class IntelGpuNameResolver:
if not pdev: if not pdev:
continue continue
names[pdev] = self._normalize_name(raw_name) names[pdev] = self._resolve_name(raw_name, device_type, cpu_name)
self._names = names self._names = names
return names return names
@ -66,11 +76,34 @@ class IntelGpuNameResolver:
except AttributeError: except AttributeError:
return None return None
@staticmethod @classmethod
def _normalize_name(name: str) -> str: def _resolve_name(cls, raw_name: str, device_type, cpu_name: Optional[str]) -> str:
cleaned = re.sub(r"\(R\)|\(TM\)", "", name) """Build a display name for a GPU.
Modern integrated Intel GPUs are reported by OpenVINO with a generic
FULL_DEVICE_NAME like "Intel(R) Graphics (iGPU)" that gives no model
information. Since the iGPU is part of the CPU on these platforms, fall
back to the CPU name (which OpenVINO does report specifically) and
suffix it with "iGPU" so it's clear what the entry is.
"""
is_integrated = "INTEGRATED" in str(device_type).upper()
if is_integrated and cpu_name:
short_cpu = re.sub(r"^Intel\s+", "", cpu_name)
return f"{short_cpu} iGPU"
return cls._normalize_name(raw_name)
@classmethod
def _normalize_name(cls, name: str) -> str:
cleaned = cls._strip_trademarks(name)
cleaned = re.sub(r"\s*\((?:i|d)GPU\)\s*$", "", cleaned, flags=re.IGNORECASE) cleaned = re.sub(r"\s*\((?:i|d)GPU\)\s*$", "", cleaned, flags=re.IGNORECASE)
return " ".join(cleaned.split()) return " ".join(cleaned.split())
@staticmethod
def _strip_trademarks(name: str) -> str:
cleaned = re.sub(r"\(R\)|\(TM\)", "", name)
return " ".join(cleaned.split())
intel_gpu_name_resolver = IntelGpuNameResolver() intel_gpu_name_resolver = IntelGpuNameResolver()