Skip to main content

detect_gpu_count

Function detect_gpu_count 

Source
pub(crate) fn detect_gpu_count(override_val: Option<usize>) -> usize
Expand description

Detects the number of NVIDIA GPU devices available on this instance.

Detection order (first success wins):

  1. override_val — the parsed value of BGE_M3_GPU_COUNT env var, if set.
  2. Linux /proc/driver/nvidia/gpus/ directory entry count (compiled out on non-Linux targets).
  3. Default: 1 (macOS CoreML is always single-device; Linux fallback when the NVIDIA driver proc path is absent or empty).

Returns at least 1 regardless of the detection path. Logs the chosen count and source at INFO.