$ show rust-nvml/nvml-wrapper
nvml-wrapper is a Rust workspace providing safe, high-level bindings to the NVIDIA Management Library (NVML). It is a library crate, not an application: there are no binaries, servers, or CLIs. The workspace is split into `nvml-wrapper-sys` (low-level FFI bindings, including runtime loading of `libnvidia-ml.so`/`nvml.dll` via `libloading`) and `nvml-wrapper` (a safe, typed API). The primary entry point is `Nvml::init()`, which loads the NVML library and returns a handle; from there, `Device` exposes 100+ methods for querying GPU state such as memory, clocks, temperature, power, ECC, NvLink, vGPU, MIG, and GPM metrics. The crate also supports mutating operations like setting application clocks and fan speed, and includes a `legacy-functions` feature for older NVML versions.
The LLM identified 3 files worth highlighting for reuse:
Hand-written safe Rust API exposing 100+ NVML device operations (memory, clocks, power, ECC, NvLink, vGPU, MIG, GPM). Includes field-ID remapping logic to handle NVML ABI changes between driver versions. This module is the core reusable value of the crate and demonstrates how to wrap a large C API safely.
Top-level `Nvml` handle and initialization logic. `Nvml::init()` loads the NVML library, manages its lifecycle, and provides access to devices and subprocesses. This RAII pattern for FFI resources is a reusable template for any Rust library that wraps a system-level C API.
Low-level NVML FFI bindings with a hand-rolled `NvmlLib` struct that loads NVML at runtime via `libloading`. This avoids link-time dependencies on NVIDIA's proprietary library and is a reusable pattern for integrating with system libraries that may not be present at build time.