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) vianvml-wrapper, loaded at runtime. The CUDA toolkit is not required and nothing links at build time. Behind the defaultnvidiafeature. - 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 (seeGpuInfo::total_bytes). AMD cards additionally report theirgfxtarget from KFD sysfs — noROCminstall needed. - Apple/macOS:
system_profiler+sysctlfor the chip and its memory ceiling, plusvm_statfor 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§
- Apple
Family - Apple GPU family, e.g.
apple8for an M2. - Compute
Capability - CUDA compute capability, e.g.
8.6forsm_86. - Cuda
Host - Host-wide CUDA properties reported by the NVIDIA driver.
- Cuda
Version - A CUDA version, e.g.
12.9. - GfxTarget
- AMD GPU architecture target, e.g.
gfx1013— the identifier aROCm/HIP code object is built for (--offload-arch=gfx1013). - GpuInfo
- A single detected GPU and its memory.
- OneApi
Host - The host’s Intel
oneAPIinstallation. - OneApi
Version - An Intel
oneAPItoolkit version, e.g.2024.2.1. - Rocm
Host - The host’s
ROCminstallation. - Rocm
Version - A
ROCmrelease version, e.g.6.2.4. - Vulkan
Host - The host’s Vulkan runtime.
- Vulkan
Version - A Vulkan API version, e.g.
1.3.280.
Enums§
- Arch
Target - The architecture a prebuilt GPU artifact must target.
- Intel
Arch - Intel GPU architecture family, e.g.
IntelArch::XeHpgfor an Arc A-series card. - Vendor
- GPU hardware vendor.
Functions§
- cuda_
host - Host-wide CUDA properties, or
Nonewhen NVML is unavailable — no NVIDIA driver, thenvidiafeature 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
oneAPIinstallation, orNonewhen it is not installed. - rocm_
host - The host’s
ROCminstallation, orNonewhenROCmis not installed. - vulkan_
host - The host’s Vulkan runtime, or
Nonewhen no loader is installed.