Skip to main content

Crate gpu_probe

Crate gpu_probe 

Source
Expand description

Cross-platform GPU memory (VRAM) detection with no vendor SDKs.

gpu_probe reports the GPUs visible on the host and how much memory each has, using only facilities the OS or driver already ship:

  • NVIDIA (Linux, Windows): NVML (libnvidia-ml) via nvml-wrapper, loaded at runtime. The CUDA toolkit is not required and nothing links at build time. Behind the default nvidia feature.
  • AMD & Intel (Linux): DRM sysfs under /sys/class/drm. Discrete cards report dedicated VRAM; integrated GPUs report the shared system-memory ceiling, and AMD APUs their VRAM carveout plus GTT pool (see GpuInfo::total_bytes). AMD cards additionally report their gfx target from KFD sysfs — no ROCm install needed.
  • Apple/macOS: system_profiler + sysctl for the chip and its memory ceiling, plus vm_stat for the used/free split (Apple Silicon reports unified memory, so that split is system-wide).

Host toolchain properties are reported separately from any one GPU: cuda_host for the CUDA driver, rocm_host for the ROCm install, oneapi_host for the Intel oneAPI install, and vulkan_host for the Vulkan runtime.

Detection is best-effort: detect returns an empty Vec when no GPU is found or the platform is unsupported — never an error.

for gpu in gpu_probe::detect() {
    println!("{gpu}");
}

Structs§

AppleFamily
Apple GPU family, e.g. apple8 for an M2.
ComputeCapability
CUDA compute capability, e.g. 8.6 for sm_86.
CudaHost
Host-wide CUDA properties reported by the NVIDIA driver.
CudaVersion
A CUDA version, e.g. 12.9.
GfxTarget
AMD GPU architecture target, e.g. gfx1013 — the identifier a ROCm/HIP code object is built for (--offload-arch=gfx1013).
GpuInfo
A single detected GPU and its memory.
OneApiHost
The host’s Intel oneAPI installation.
OneApiVersion
An Intel oneAPI toolkit version, e.g. 2024.2.1.
RocmHost
The host’s ROCm installation.
RocmVersion
A ROCm release version, e.g. 6.2.4.
VulkanHost
The host’s Vulkan runtime.
VulkanVersion
A Vulkan API version, e.g. 1.3.280.

Enums§

ArchTarget
The architecture a prebuilt GPU artifact must target.
IntelArch
Intel GPU architecture family, e.g. IntelArch::XeHpg for an Arc A-series card.
Vendor
GPU hardware vendor.

Functions§

cuda_host
Host-wide CUDA properties, or None when NVML is unavailable — no NVIDIA driver, the nvidia feature disabled, no device, or a driver reporting values that aren’t usable.
detect
Detect all GPUs visible on the host.
oneapi_host
The host’s Intel oneAPI installation, or None when it is not installed.
rocm_host
The host’s ROCm installation, or None when ROCm is not installed.
vulkan_host
The host’s Vulkan runtime, or None when no loader is installed.