Skip to main content

Module gpu_detector

Module gpu_detector 

Source
Expand description

GPU inventory detection

Platform-specific GPU detection:

  • Linux: Scans /sys/bus/pci/devices for display controllers (VGA and 3D controllers). Identifies vendor (NVIDIA, AMD, Intel) by PCI vendor ID, reads VRAM from PCI BAR regions, and optionally uses nvidia-smi for NVIDIA-specific model and memory information.
  • macOS: Uses system_profiler SPDisplaysDataType -json to detect Apple Silicon GPUs and unified memory via sysctl -n hw.memsize.
  • Windows: Layers NVML (via nvml-wrapper, loads nvml.dll at runtime) on top of WMI Win32_VideoController enumeration (via the wmi crate). AMD VRAM is corrected by reading HardwareInformation.qwMemorySize from the display-class registry subtree (HKLM\SYSTEM\CurrentControlSet\Control\Class\{4d36e968-...}\<xxxx>) because WMI’s AdapterRAM is a u32 capped at 4 GiB. NVML data is preferred when both surface the same card.
  • Other: Returns an empty GPU list.

Linux/macOS require no external crates – pure sysfs/system_profiler scanning with optional subprocess calls. Windows pulls in nvml-wrapper, wmi, and windows-registry (all gated to target_os = "windows" in the crate manifest).

Structs§

GpuInfo
Detected GPU information

Functions§

detect_gpus
Scan the system for GPU devices via sysfs PCI enumeration (Linux only)