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
Nvmlexists only after its table’sinitsucceeded, and its drop calls the table’sshutdownonce.
Structs§
- Nvml
- 2026-09-26: An initialised NVML session over a function table.
nvmlShutdownruns on drop, balancing the successful init. - Nvml
Device - 2026-09-26: One device’s queries.
Ok(None)when the entry point is absent or answersNVML_ERROR_NOT_SUPPORTEDorNVML_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
Nonewhen the library does not export it. - Nvml
Library - 2026-09-26: An opened
libnvidia-mland the table resolved from it. The library stays loaded as long as this value lives. - Nvml
Memory - 2026-09-26:
nvmlMemory_t(v1), in bytes.
Enums§
- Nvml
Unavailable - 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_tvalues. - NVML_
CLOCK_ MEM - NVML_
CLOCK_ SM - NVML_
ERROR_ NOT_ SUPPORTED - NVML_
ERROR_ NO_ PERMISSION - NVML_
NVLINK_ MAX_ LINKS - 2026-09-26:
NVML_NVLINK_MAX_LINKSin the CUDA toolkit’s nvml.h. - NVML_
PCIE_ UTIL_ RX_ BYTES - NVML_
PCIE_ UTIL_ TX_ BYTES - 2026-09-26:
nvmlPcieUtilCounter_tvalues. - NVML_
SUCCESS - NVML_
TEMPERATURE_ GPU - 2026-09-26:
nvmlTemperatureSensors_t::NVML_TEMPERATURE_GPU.
Type Aliases§
- FnDev
ArgU32 - FnDev
Memory - FnDev
U32 - FnDev
U64 - FnHandle
ByIndex - FnVoid
- Nvml
Device Handle - 2026-09-26:
nvmlDevice_t, an opaque handle owned by the library. - Nvml
Return - 2026-09-26:
nvmlReturn_t.