pub struct GpuUtilizationReader { /* private fields */ }Expand description
One-shot accumulator that opens NVML once and reads per-GPU utilisation for every NVIDIA device on each load tick. Holding the NVML handle across reads avoids the init cost (microseconds) on every tick and is the documented pattern.
Implementations§
Source§impl GpuUtilizationReader
impl GpuUtilizationReader
Sourcepub fn new() -> Self
pub fn new() -> Self
Build a reader. NVML init failure is non-fatal — the reader folds to “all zeroes” on every NVIDIA device and the rest of the load-tick path stays alive. Logged once at startup so operators can tell “no NVIDIA card” from “NVIDIA card but driver missing”.
Sourcepub fn read(&self, device: &GpuDevice) -> GpuUtilization
pub fn read(&self, device: &GpuDevice) -> GpuUtilization
Read the per-tick snapshot for one device. Cheap when NVML is available (handful of FFI calls); free when it’s not (returns the zero-initialised default).
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for GpuUtilizationReader
impl !UnwindSafe for GpuUtilizationReader
impl Freeze for GpuUtilizationReader
impl Send for GpuUtilizationReader
impl Sync for GpuUtilizationReader
impl Unpin for GpuUtilizationReader
impl UnsafeUnpin for GpuUtilizationReader
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more