Skip to main content

detect

Function detect 

Source
pub fn detect() -> Vec<GpuInfo>
Expand description

Detect all GPUs visible on the host.

Best-effort: spawns only read-only platform queries (NVML, system_profiler, sysctl) and reads sysfs. Returns an empty Vec on unsupported platforms or when no GPU is found.

Examples found in repository?
examples/detect.rs (line 5)
4fn main() {
5    let gpus = gpu_probe::detect();
6    if gpus.is_empty() {
7        println!("No GPUs detected.");
8        return;
9    }
10    for (index, gpu) in gpus.iter().enumerate() {
11        println!("GPU {index}: {gpu}");
12    }
13}