Skip to main content

detect_amd_gpus

Function detect_amd_gpus 

Source
pub fn detect_amd_gpus() -> Vec<AmdGpu>
Expand description

Detect ALL AMD GPUs via lspci + sysfs (includes iGPU; use detect_discrete_amd_gpus to filter).

Primary source: lspci -nn (universally available, no rocminfo needed). Parses AMD VGA [0300] / 3D [0302] lines to extract PCI slot, device NAME, and PCI ID [1002:xxxx]. This provides reliable device names without rocminfo.

Per-device enrichment:

  • PCI slot: from lspci
  • Marketing name: from lspci (e.g. “Navi 31 [Radeon RX 7900 XT/…]”)
  • PCI ID: from lspci [1002:xxxx] format
  • VRAM: from sysfs mem_info_vram_total via read_vram_bytes
  • gfx arch: from PCI ID table (DISCRETE_PCI_ID_TO_GFX), or marketing name fallback (gfx_from_marketing_name), or None for unknown

iGPU classification: Uses name+ID tandem via device_is_integrated with BOTH marketing_name (from lspci) AND pci_id. A device is integrated only if all signals agree (PCI ID, name, gfx arch, VRAM). Verified dGPU iff !is_integrated.

rocminfo enrichment (optional): If rocminfo is on PATH and runs, parses its agent list for authoritative ROCm device names + gfx archs and cross-verifies against lspci/sysfs devices (match by name/PCI). Uses rocminfo’s device ordering to inform HIP_VISIBLE_DEVICES when available; else falls back to verified lspci/sysfs dGPU list in pci-slot order. rocminfo NEVER required — detection works fully without it.

Returns all AMD GPUs (iGPU + dGPU), each with verified name+PCI_ID+gfx+VRAM.