Module nvml

Module nvml 

Source
Expand description

2026-09-26: NVML (the NVIDIA management library), resolved with dlopen.

There is no link-time dependency: on a host without the driver, NvmlLibrary::open returns NvmlUnavailable instead of the process failing to load. Only nvmlInit_v2, nvmlShutdown and nvmlDeviceGetHandleByIndex_v2 are required; a missing query symbol leaves its NvmlFns slot None.

NvmlFns is a table of function pointers. NvmlLibrary fills it from the shared object; tests, here and in the telemetry crate, fill it with functions of their own through Nvml::with_fns. Nvml and NvmlDevice run the same code over either.

Values are in NVML’s units, which the accessor names carry: power_mw (milliwatts), total_energy_mj (millijoules), clock_mhz, temperature_c, pcie_kbps (KB/s); memory is in bytes.

Owner: metrale-gpu-sys. Invariants:

  • An Nvml exists only after its table’s init succeeded, and its drop calls the table’s shutdown once.

Structs§

Nvml
2026-09-26: An initialised NVML session over a function table. nvmlShutdown runs on drop, balancing the successful init.
NvmlDevice
2026-09-26: One device’s queries. Ok(None) when the entry point is absent or answers NVML_ERROR_NOT_SUPPORTED or NVML_ERROR_NO_PERMISSION; Err(code) for any other failure.
NvmlFns
2026-09-26: The entry points this crate binds. The first three are required; each query is None when the library does not export it.
NvmlLibrary
2026-09-26: An opened libnvidia-ml and the table resolved from it. The library stays loaded as long as this value lives.
NvmlMemory
2026-09-26: nvmlMemory_t (v1), in bytes.

Enums§

NvmlUnavailable
2026-09-26: Why NVML cannot be used. The telemetry sampler records it as the device being unavailable and serving continues.

Constants§

LIBRARY_NAMES
2026-09-26: The shared object names tried, in order.
NVML_CLOCK_GRAPHICS
2026-09-26: nvmlClockType_t values.
NVML_CLOCK_MEM
NVML_CLOCK_SM
NVML_ERROR_NOT_SUPPORTED
NVML_ERROR_NO_PERMISSION
NVML_NVLINK_MAX_LINKS
2026-09-26: NVML_NVLINK_MAX_LINKS in the CUDA toolkit’s nvml.h.
NVML_PCIE_UTIL_RX_BYTES
NVML_PCIE_UTIL_TX_BYTES
2026-09-26: nvmlPcieUtilCounter_t values.
NVML_SUCCESS
NVML_TEMPERATURE_GPU
2026-09-26: nvmlTemperatureSensors_t::NVML_TEMPERATURE_GPU.

Type Aliases§

FnDevArgU32
FnDevMemory
FnDevU32
FnDevU64
FnHandleByIndex
FnVoid
NvmlDeviceHandle
2026-09-26: nvmlDevice_t, an opaque handle owned by the library.
NvmlReturn
2026-09-26: nvmlReturn_t.