Skip to main content

Device

Struct Device 

Source
pub struct Device(/* private fields */);

Implementations§

Source§

impl Device

Source

pub const unsafe fn from_raw(handle: nvmlDevice_t) -> Self

Source

pub const fn as_raw(self) -> nvmlDevice_t

Source

pub const fn is_null(self) -> bool

Source

pub fn index(self) -> Result<u32>

Returns the NVML index of this device.

For all products.

Valid indices are derived from the accessible device count returned by Library::device_count. For example, if the count is 2 the valid indices are 0 and 1, corresponding to GPU 0 and GPU 1.

The order in which NVML enumerates devices has no guarantees of consistency between reboots. Prefer PCI bus IDs or GPU UUIDs for stable device lookup. See Library::device_by_pci_bus_id and Library::device_by_uuid.

With MIG device handles, this returns indices that can be passed to Device::mig_device to retrieve an identical handle. MIG device indices are unique within a device.

The NVML index may not correlate with other APIs, such as the CUDA device index.

§Errors

Returns an error if the device is inaccessible, if NVML rejects the handle or index output, if NVML has not been initialized, or if NVML reports an unexpected failure.

Source

pub fn name(self) -> Result<String>

Returns the name of this device.

For all products.

The name is an alphanumeric product identifier such as Tesla C2070. It does not exceed 96 bytes including the terminating NUL byte. This wrapper allocates the required NVML buffer internally.

With MIG device handles, this returns MIG device names that can identify devices based on their attributes.

§Errors

Returns an error if the device is inaccessible, if the internal name buffer is too small, if NVML rejects the handle or output buffer, if NVML has not been initialized, or if NVML reports an unexpected failure.

Examples found in repository?
examples/fan_curve.rs (line 15)
12fn main() -> Result<(), Box<dyn Error>> {
13    let nvml = Library::create()?;
14    let device = nvml.device(GPU_INDEX)?;
15    let name = device.name()?;
16    let fans = device.num_fans()?;
17    let fan_limits = device.min_max_fan_speed()?;
18
19    println!("controlling GPU {GPU_INDEX}: {name}");
20    println!("fan speed range: {}%-{}%", fan_limits.min, fan_limits.max);
21    println!("curve: {CURVE:?}");
22    if !APPLY_CHANGES {
23        println!("dry run: set APPLY_CHANGES to true to write fan speeds");
24    }
25
26    for _ in 0..POLLS {
27        // Read the GPU temperature and choose a speed from the curve.
28        let temperature = device.temperature_reading(TemperatureSensor::Gpu)?;
29        let target_speed =
30            fan_speed_for_temperature(temperature).clamp(fan_limits.min, fan_limits.max);
31
32        // Apply the same target to every fan controller on the selected GPU.
33        for fan in 0..fans {
34            let current_speed = device.fan_speed(fan)?;
35            println!("fan {fan}: {temperature} C -> {target_speed}% (currently {current_speed}%)");
36
37            if APPLY_CHANGES && current_speed != target_speed {
38                device.set_fan_speed(fan, target_speed)?;
39            }
40        }
41
42        thread::sleep(POLL_INTERVAL);
43    }
44
45    Ok(())
46}
Source

pub fn hostname(self) -> Result<String>

Returns the hostname for the device.

For Blackwell or newer fully supported devices. Supported on Linux only.

Returns the hostname string for the GPU device that was set using sys::nvmlDeviceSetHostname_v1.

§Errors

Returns an error if the device is inaccessible, if NVML rejects the handle or hostname output, if the device does not support hostnames, if NVML has not been initialized, or if NVML reports an unexpected failure.

Source

pub fn brand(self) -> Result<Brand>

Returns the brand of this device.

For all products.

The type is a member of Brand defined above.

§Errors

Returns an error if the device is inaccessible, if NVML rejects the handle or brand output, if NVML has not been initialized, or if NVML reports an unexpected failure.

Source

pub fn architecture(self) -> Result<Architecture>

Returns architecture for the device.

§Errors

Returns an error if NVML rejects the handle or architecture output, or if NVML has not been initialized.

Source

pub fn serial(self) -> Result<String>

Source

pub fn uuid(self) -> Result<String>

Source

pub fn vbios_version(self) -> Result<String>

Source

pub fn board_part_number(self) -> Result<String>

Source

pub fn module_id(self) -> Result<u32>

Returns a unique identifier for the device module on the baseboard.

Returns a unique identifier for each GPU module on a given baseboard. For non-baseboard products, this ID would always be 0.

§Errors

Returns an error if NVML rejects the handle or module ID output, if NVML has not been initialized, or if NVML reports an unexpected failure.

Source

pub fn is_multi_gpu_board(self) -> Result<bool>

Returns whether the device is on a multi-GPU board.

For Fermi or newer fully supported devices.

§Errors

Returns an error if the device is inaccessible, if NVML rejects the handle or output, if the device does not support this query, if NVML has not been initialized, or if NVML reports an unexpected failure.

Source

pub fn attributes(self) -> Result<DeviceAttributes>

Returns attributes (engine counts etc.) for the given NVML device handle.

This currently supports only MIG device handles.

For Ampere or newer fully supported devices. Supported on Linux only.

§Errors

Returns an error if NVML rejects the device handle, if the device does not support this query, if NVML has not been initialized, or if NVML reports an unexpected failure.

Source

pub fn is_api_restricted(self, api: RestrictedApi) -> Result<EnableState>

Returns the root/admin permissions for the target NVML operation. See RestrictedApi for the list of supported operations. If an operation is restricted, only callers with root privileges can call it. See sys::nvmlDeviceSetAPIRestriction to change current permissions.

For all fully supported products.

§Errors

Returns an error if the device is inaccessible, if NVML rejects the handle, API restriction, or output, if the device or queried feature does not support API restriction reporting, if NVML has not been initialized, or if NVML reports an unexpected failure.

Source

pub fn platform_info(self) -> Result<PlatformInfo>

Returns platform information of this device.

For Blackwell or newer fully supported devices.

Returns the platform information reported by NVML for this device.

§Errors

Returns an error if the installed NVML version does not support the request layout, if NVML rejects the request, if system memory is insufficient, if the device does not support this query, or if NVML reports an unexpected failure.

Source

pub fn pdi(self) -> Result<Pdi>

Returns the Per Device Identifier (PDI) associated with this device.

For Pascal or newer fully supported devices.

Returns the per-device identifier reported by NVML.

§Errors

Returns an error if the installed NVML version does not support the request layout, if the device is inaccessible, if NVML rejects the handle or output, if the device does not support PDI reporting, if NVML has not been initialized, or if NVML reports an unexpected failure.

Source

pub fn c2c_mode_info(self) -> Result<C2cModeInfo>

Returns the Device’s C2C Mode information.

§Errors

Returns an error if the device is inaccessible, if NVML rejects the handle or output, if the device does not support C2C mode reporting, or if NVML reports an unexpected failure.

Source

pub fn auto_boosted_clocks(self) -> Result<AutoBoostClocks>

Returns the current Auto Boosted clocks state for this device.

For Kepler or newer fully supported devices.

Auto Boosted clocks are enabled by default on some hardware, allowing the GPU to run at higher clock rates to maximize performance as thermal limits allow.

On Pascal and newer hardware, Auto Boosted clocks are controlled through application clocks. Use sys::nvmlDeviceSetApplicationsClocks and sys::nvmlDeviceResetApplicationsClocks to control Auto Boost behavior.

§Errors

Returns an error if the device is inaccessible, if NVML rejects the handle or output, if the device does not support Auto Boosted clocks, if NVML has not been initialized, or if NVML reports an unexpected failure.

Source

pub fn set_default_auto_boosted_clocks_enabled( self, enabled: EnableState, flags: DriverModelFlags, ) -> Result<()>

Tries to set the default state of Auto Boosted clocks on a device. Auto Boosted clocks return to this default state when no compute processes, such as CUDA applications with active contexts, are running.

For Kepler or newer non-GeForce fully supported devices and Maxwell or newer GeForce devices. Requires root/admin permissions.

Auto Boosted clocks are enabled by default on some hardware, allowing the GPU to run at higher clock rates to maximize performance as thermal limits allow. Disable Auto Boosted clocks when fixed clock rates are required.

On Pascal and newer hardware, Auto Boosted clocks are controlled through application clocks. Use sys::nvmlDeviceSetApplicationsClocks and sys::nvmlDeviceResetApplicationsClocks to control Auto Boost behavior.

§Errors

Returns an error if the device is inaccessible, if NVML rejects the handle, if the device does not support Auto Boosted clocks, if the current process lacks permission to change the default state, if NVML has not been initialized, or if NVML reports an unexpected failure.

Source

pub fn pci_info(self) -> Result<PciInfo>

Returns the PCI attributes of this device.

For all products.

Returns the PCI information reported by NVML.

§Errors

Returns an error if the device is inaccessible, if NVML rejects the handle or PCI info output, if NVML has not been initialized, or if NVML reports an unexpected failure.

Source

pub fn pci_info_ext(self) -> Result<PciInfoExt>

Returns PCI attributes of this device.

For all products.

Returns the extended PCI information reported by NVML.

§Errors

Returns an error if the device is inaccessible, if NVML rejects the handle or PCI info output, if NVML has not been initialized, or if NVML reports an unexpected failure.

Source

pub fn bridge_chip_hierarchy(self) -> Result<BridgeChipHierarchy>

Returns bridge chip information for all the bridge chips on the board.

For all fully supported products. Only applicable to multi-GPU products.

§Errors

Returns an error if the device is inaccessible, if NVML rejects the handle or output, if bridge-chip reporting is not supported for the device, if NVML has not been initialized, or if NVML reports an unexpected failure.

Returns the current PCIe link generation.

For Fermi or newer fully supported devices.

§Errors

Returns an error if the device is inaccessible, if NVML rejects the query, if PCIe link information is unavailable, if NVML has not been initialized, or if NVML reports an unexpected failure.

Returns the current PCIe link width.

For Fermi or newer fully supported devices.

§Errors

Returns an error if the device is inaccessible, if NVML rejects the query, if PCIe link information is unavailable, if NVML has not been initialized, or if NVML reports an unexpected failure.

Returns the maximum PCIe link generation possible with this device and system.

For example, a generation 2 PCIe device attached to a generation 1 PCIe bus reports generation 1.

For Fermi or newer fully supported devices.

§Errors

Returns an error if the device is inaccessible, if NVML rejects the query, if PCIe link information is unavailable, if NVML has not been initialized, or if NVML reports an unexpected failure.

Returns the maximum PCIe link generation supported by this device.

For Fermi or newer fully supported devices.

§Errors

Returns an error if the device is inaccessible, if NVML rejects the query, if PCIe link information is unavailable, if NVML has not been initialized, or if NVML reports an unexpected failure.

Returns the maximum PCIe link width possible with this device and system.

For example, a device with a 16x PCIe bus width attached to an 8x PCIe system bus reports a maximum link width of 8.

For Fermi or newer fully supported devices.

§Errors

Returns an error if the device is inaccessible, if NVML rejects the handle or output, if PCIe link information is unavailable, if NVML has not been initialized, or if NVML reports an unexpected failure.

Source

pub fn pcie_throughput(self, counter: PcieUtilCounter) -> Result<u32>

Returns PCIe utilization information. Queries a byte counter over a 20 ms interval to report PCIe throughput.

For Maxwell or newer fully supported devices.

Not supported in virtual machines running virtual GPU (vGPU).

§Errors

Returns an error if the device is inaccessible, if NVML rejects the handle, counter, or output, if the device does not support PCIe utilization queries, if NVML has not been initialized, or if NVML reports an unexpected failure.

Source

pub fn pcie_replay_counter(self) -> Result<u32>

Returns the PCIe replay counter.

For Kepler or newer fully supported devices.

§Errors

Returns an error if the device is inaccessible, if NVML rejects the handle or output, if the device does not support replay-counter queries, if NVML has not been initialized, or if NVML reports an unexpected failure.

Returns the device’s PCIe Max Link speed in MB/s.

§Errors

Returns an error if the device is inaccessible, if NVML rejects the handle or output, if the device does not support this query, or if NVML has not been initialized.

Source

pub fn pcie_speed(self) -> Result<u32>

Returns the device’s PCIe Link speed in Mbps.

§Errors

Returns an error if NVML rejects the handle or output, if the device does not support PCIe speed queries, if NVML has not been initialized, or if NVML reports an unexpected failure.

Source

pub fn gpm_support(self) -> Result<GpmSupport>

Indicates whether the supplied device supports GPM.

For Hopper or newer fully supported devices.

This supports device handles and MIG device handles.

§Errors

Returns an error if NVML rejects the handle or cannot query GPM support.

Source

pub fn gpm_streaming_enabled(self) -> Result<EnableState>

Returns GPM stream state.

For Hopper or newer fully supported devices. Supported on Linux, Windows TCC.

§Errors

Returns an error if NVML rejects the handle or output, if the device does not support GPM streaming-state queries, or if NVML has not been initialized.

Source

pub fn gpm_sample(self, sample: &GpmSample) -> Result<()>

Read a sample of GPM metrics into the provided sample buffer. After two samples are gathered, you can call Library::gpm_metrics on those samples to retrieve metrics.

For Hopper or newer fully supported devices.

  • The interval between two Device::gpm_sample calls must be greater than 100 ms due to the internal sample refresh rate.
  • Supports device handles and MIG device handles.
§Errors

Returns an error if NVML rejects the handle or sample buffer, if the device does not support GPM sampling, or if samples are requested too quickly.

Source

pub fn gpm_mig_sample( self, gpu_instance_id: u32, sample: &GpmSample, ) -> Result<()>

Read a sample of GPM metrics into the provided sample buffer for a MIG GPU instance.

After two samples are gathered, you can call Library::gpm_metrics on those samples to retrieve metrics.

For Hopper or newer fully supported devices.

The interval between two Device::gpm_mig_sample calls must be greater than 100 ms due to the internal sample refresh rate.

§Errors

Returns an error if NVML rejects the handle, GPU instance id, or sample buffer, if the device does not support GPM MIG sampling, or if samples are requested too quickly.

Source

pub fn memory_info(self) -> Result<MemoryInfo>

Source

pub fn utilization(self) -> Result<Utilization>

Returns the current utilization rates for the device’s major subsystems.

For Fermi or newer fully supported devices.

  • During driver initialization when ECC is enabled, GPU and memory utilization readings can be high. ECC memory scrubbing during driver initialization causes this.
  • On MIG-enabled GPUs, querying device utilization rates is not currently supported.
§Errors

Returns an error if the device is inaccessible, if NVML rejects the handle or output, if the device does not support utilization queries, if NVML has not been initialized, or if NVML reports an unexpected failure.

Source

pub fn encoder_utilization(self) -> Result<UtilizationCounter>

Source

pub fn decoder_utilization(self) -> Result<UtilizationCounter>

Source

pub fn jpg_utilization(self) -> Result<UtilizationCounter>

Source

pub fn ofa_utilization(self) -> Result<UtilizationCounter>

Source

pub fn encoder_capacity(self, encoder: EncoderType) -> Result<u32>

Returns the current capacity of the device’s encoder, as a percentage of maximum encoder capacity with valid values in the range 0-100.

For Maxwell or newer fully supported devices.

§Errors

Returns an error if the device is inaccessible, if NVML rejects the query, if the device does not support the requested encoder, if NVML has not been initialized, or if NVML reports an unexpected failure.

Source

pub fn encoder_stats(self) -> Result<EncoderStats>

Returns the current encoder statistics for the given device.

For Maxwell or newer fully supported devices.

§Errors

Returns an error if the device is inaccessible, if NVML rejects the query, if NVML has not been initialized, or if NVML reports an unexpected failure.

Source

pub fn encoder_sessions(self) -> Result<Vec<EncoderSessionInfo>>

Returns information about active encoder sessions on a target device.

This wrapper queries the required session count first, then returns the active encoder sessions as a Vec.

For Maxwell or newer fully supported devices.

§Errors

Returns an error if the device is inaccessible, if the active-session count changes while the wrapper is fetching sessions, if NVML reports an invalid session count, if the device does not support this query, if NVML has not been initialized, or if NVML reports an unexpected failure.

Source

pub fn bar1_memory_info(self) -> Result<Bar1MemoryInfo>

Returns total, available, and used size of BAR1 memory.

BAR1 maps framebuffer memory so the CPU or third-party PCIe peer devices can access it directly.

In MIG mode, a device handle returns aggregate information only if the caller has appropriate privileges. Per-instance information can be queried by using specific MIG device handles.

For Kepler or newer fully supported devices.

§Errors

Returns an error if the device is inaccessible, if NVML rejects the query, if the device does not support BAR1 memory reporting, if NVML has not been initialized, or if NVML reports an unexpected failure.

Source

pub fn clock(self, kind: ClockType) -> Result<u32>

Returns the current clock speeds for the device.

For Fermi or newer fully supported devices.

See ClockType for details on available clock information.

§Errors

Returns an error if the device is inaccessible, if NVML rejects the handle, clock type, or output, if the device cannot report the requested clock, if NVML has not been initialized, or if NVML reports an unexpected failure.

Source

pub fn clock_with_id(self, kind: ClockType, clock_id: ClockId) -> Result<u32>

Returns the clock speed for the clock specified by the clock type and clock ID.

For Kepler or newer fully supported devices.

§Errors

Returns an error if the device is inaccessible, if NVML rejects the handle, clock type, clock ID, or output, if the device does not support this clock query, if NVML has not been initialized, or if NVML reports an unexpected failure.

Source

pub fn max_clock(self, kind: ClockType) -> Result<u32>

Returns the maximum clock speeds for the device.

For Fermi or newer fully supported devices.

See ClockType for details on available clock information.

Current P0 clocks (reported by Device::clock) can differ from max clocks by a few MHz.

§Errors

Returns an error if the device is inaccessible, if NVML rejects the handle, clock type, or output, if the device cannot report the requested maximum clock, if NVML has not been initialized, or if NVML reports an unexpected failure.

Source

pub fn current_clock_freqs(self) -> Result<CurrentClockFreqs>

Returns a string with the associated current GPU Clock and Memory Clock values.

Not all tokens are reported on all GPUs, and additional tokens may be added in the future.

These clock values include the offset set by clients through Device::set_clock_offsets.

Clock values are returned as a comma-separated list of “token=value” pairs. Valid tokens:

  • perf: performance level.
  • nvclock: GPU clock in MHz for the performance level.
  • nvclockmin: minimum GPU clock in MHz for the performance level.
  • nvclockmax: maximum GPU clock in MHz for the performance level.
  • nvclockeditable: whether the GPU clock domain is editable for the performance level.
  • memclock: memory clock in MHz for the performance level.
  • memclockmin: minimum memory clock in MHz for the performance level.
  • memclockmax: maximum memory clock in MHz for the performance level.
  • memclockeditable: whether the memory clock domain is editable for the performance level.
  • memtransferrate: memory transfer rate in MHz for the performance level.
  • memtransferratemin: minimum memory transfer rate in MHz for the performance level.
  • memtransferratemax: maximum memory transfer rate in MHz for the performance level.
  • memtransferrateeditable: whether the memory transfer rate is editable for the performance level.

Example:

nvclock=324, nvclockmin=324, nvclockmax=324, nvclockeditable=0, memclock=324, memclockmin=324, memclockmax=324, memclockeditable=0, memtransferrate=648, memtransferratemin=648, memtransferratemax=648, memtransferrateeditable=0;

§Errors

Returns an error if the device is inaccessible, if the internal clock-frequency buffer is too small, if NVML rejects the handle or output, if NVML has not been initialized, or if NVML reports an unexpected failure.

Source

pub fn performance_modes(self) -> Result<PerformanceModes>

Returns a performance mode string with all the performance modes defined for this device along with their associated GPU Clock and Memory Clock values. Not all tokens are reported on all GPUs, and additional tokens may be added in the future. For backward compatibility, NVML still provides nvclock and memclock; those are the same as nvclockmin and memclockmin.

These clock values include the offset set by clients through Device::set_clock_offsets.

Maximum available Pstate (P15) shows the minimum performance level (0) and vice versa.

Each performance mode is returned as a comma-separated list of “token=value” pairs. Performance-mode token sets are separated by semicolons. Valid tokens:

  • perf: performance level.
  • nvclock: GPU clock in MHz for the performance level.
  • nvclockmin: minimum GPU clock in MHz for the performance level.
  • nvclockmax: maximum GPU clock in MHz for the performance level.
  • nvclockeditable: whether the GPU clock domain is editable for the performance level.
  • memclock: memory clock in MHz for the performance level.
  • memclockmin: minimum memory clock in MHz for the performance level.
  • memclockmax: maximum memory clock in MHz for the performance level.
  • memclockeditable: whether the memory clock domain is editable for the performance level.
  • memtransferrate: memory transfer rate in MHz for the performance level.
  • memtransferratemin: minimum memory transfer rate in MHz for the performance level.
  • memtransferratemax: maximum memory transfer rate in MHz for the performance level.
  • memtransferrateeditable: whether the memory transfer rate is editable for the performance level.

Example:

perf=0, nvclock=324, nvclockmin=324, nvclockmax=324, nvclockeditable=0, memclock=324, memclockmin=324, memclockmax=324, memclockeditable=0, memtransferrate=648, memtransferratemin=648, memtransferratemax=648, memtransferrateeditable=0; perf=1, nvclock=324, nvclockmin=324, nvclockmax=640, nvclockeditable=0, memclock=810, memclockmin=810, memclockmax=810, memclockeditable=0, memtransferrate=1620, memtransferrate=1620, memtransferrate=1620, memtransferrateeditable=0;

§Errors

Returns an error if the device is inaccessible, if the internal performance-mode buffer is too small, if NVML rejects the handle or output, if NVML has not been initialized, or if NVML reports an unexpected failure.

Source

pub fn applications_clock(self, kind: ClockType) -> Result<u32>

Source

pub fn default_applications_clock(self, kind: ClockType) -> Result<u32>

Source

pub fn max_customer_boost_clock(self, kind: ClockType) -> Result<u32>

Returns the customer-defined maximum boost clock speed specified by kind.

For Pascal or newer fully supported devices.

§Errors

Returns an error if the device is inaccessible, if NVML rejects the handle, clock type, or output, if the device or requested clock type does not support customer boost clocks, if NVML has not been initialized, or if NVML reports an unexpected failure.

Source

pub fn min_max_clock_of_pstate( self, kind: ClockType, pstate: PerformanceState, ) -> Result<ClockRange>

Returns the minimum and maximum clocks of a clock domain for a P-state.

§Errors

Returns an error if NVML rejects the handle, clock type, P-state, or outputs, if the device does not support this query, if NVML has not been initialized, or if NVML reports an unexpected failure.

Source

pub fn clock_offsets( self, kind: ClockType, pstate: PerformanceState, ) -> Result<ClockOffset>

Returns the minimum, maximum, and current clock offset for a clock domain and P-state.

For Maxwell or newer fully supported devices.

Device::gpc_clock_vf_offset, Device::memory_clock_vf_offset, sys::nvmlDeviceGetGpcClkMinMaxVfOffset, and sys::nvmlDeviceGetMemClkMinMaxVfOffset are deprecated and are planned for removal in a future release. Use Device::clock_offsets instead.

§Errors

Returns an error if the installed NVML version does not support the request layout, if NVML rejects the device, clock type, P-state, or outputs, if the device does not support clock-offset queries, or if NVML has not been initialized.

Source

pub fn set_clock_offsets(self, offset: ClockOffset) -> Result<()>

Controls current clock offset of some clock domain for the given PState

For Maxwell or newer fully supported devices.

Requires privileged access.

§Errors

Returns an error if the installed NVML version does not support the request layout, if NVML rejects the handle, clock type, P-state, or offset, if the device does not support clock-offset control, if the current process lacks permission, or if NVML has not been initialized.

Source

pub fn gpc_clock_vf_offset(self) -> Result<i32>

Returns the GPCCLK VF offset value.

§Errors

Returns an error if NVML rejects the handle or output, if the device does not support this deprecated offset query, if NVML has not been initialized, or if NVML reports an unexpected failure.

Source

pub fn memory_clock_vf_offset(self) -> Result<i32>

Returns the MemClk (Memory Clock) VF offset value.

§Errors

Returns an error if NVML rejects the handle or output, if the device does not support this deprecated offset query, if NVML has not been initialized, or if NVML reports an unexpected failure.

Source

pub fn gpc_clock_vf_offset_range(self) -> Result<ClockRangeI32>

Source

pub fn memory_clock_vf_offset_range(self) -> Result<ClockRangeI32>

Source

pub fn supported_memory_clocks(self) -> Result<Vec<u32>>

Returns the list of possible memory clocks that can be used as an argument for sys::nvmlDeviceSetMemoryLockedClocks.

For Kepler or newer fully supported devices.

§Errors

Returns an error if the device is inaccessible, if the clock list changes while the wrapper is fetching it, if NVML rejects the handle or count output, if the device does not support this query, if NVML has not been initialized, or if NVML reports an unexpected failure.

Source

pub fn supported_graphics_clocks( self, memory_clock_mhz: u32, ) -> Result<Vec<u32>>

Returns the list of possible graphics clocks that can be used as an argument for sys::nvmlDeviceSetGpuLockedClocks.

For Kepler or newer fully supported devices.

§Errors

Returns an error if the device is inaccessible, if the clock list changes while the wrapper is fetching it, if NVML rejects the handle, memory clock, or output, if memory_clock_mhz is unsupported, if the device does not support this query, if NVML has not been initialized, or if NVML reports an unexpected failure.

Source

pub fn temperature_reading(self, sensor: TemperatureSensor) -> Result<u32>

Examples found in repository?
examples/fan_curve.rs (line 28)
12fn main() -> Result<(), Box<dyn Error>> {
13    let nvml = Library::create()?;
14    let device = nvml.device(GPU_INDEX)?;
15    let name = device.name()?;
16    let fans = device.num_fans()?;
17    let fan_limits = device.min_max_fan_speed()?;
18
19    println!("controlling GPU {GPU_INDEX}: {name}");
20    println!("fan speed range: {}%-{}%", fan_limits.min, fan_limits.max);
21    println!("curve: {CURVE:?}");
22    if !APPLY_CHANGES {
23        println!("dry run: set APPLY_CHANGES to true to write fan speeds");
24    }
25
26    for _ in 0..POLLS {
27        // Read the GPU temperature and choose a speed from the curve.
28        let temperature = device.temperature_reading(TemperatureSensor::Gpu)?;
29        let target_speed =
30            fan_speed_for_temperature(temperature).clamp(fan_limits.min, fan_limits.max);
31
32        // Apply the same target to every fan controller on the selected GPU.
33        for fan in 0..fans {
34            let current_speed = device.fan_speed(fan)?;
35            println!("fan {fan}: {temperature} C -> {target_speed}% (currently {current_speed}%)");
36
37            if APPLY_CHANGES && current_speed != target_speed {
38                device.set_fan_speed(fan, target_speed)?;
39            }
40        }
41
42        thread::sleep(POLL_INTERVAL);
43    }
44
45    Ok(())
46}
Source

pub fn temperature_threshold( self, threshold: TemperatureThreshold, ) -> Result<u32>

Returns the temperature threshold for the GPU with the specified threshold type in degrees C.

For Kepler or newer fully supported devices.

See TemperatureThreshold for details on available temperature thresholds.

This is no longer the preferred interface for retrieving the following temperature thresholds on Ada and later architectures: TemperatureThreshold::Shutdown, TemperatureThreshold::Slowdown, TemperatureThreshold::MemoryMax and TemperatureThreshold::GpuMax.

Support for reading these temperature thresholds for Ada and later architectures may be removed in future releases. Use Device::field_values with NVML_FI_DEV_TEMPERATURE_* fields to retrieve temperature thresholds on these architectures.

§Errors

Returns an error if the device is inaccessible, if NVML rejects the handle, threshold type, or output, if the device does not support the requested temperature threshold, if NVML has not been initialized, or if NVML reports an unexpected failure.

Source

pub fn set_temperature_threshold( self, threshold: TemperatureThreshold, temperature: i32, ) -> Result<i32>

Sets the temperature threshold for the GPU with the specified threshold type in degrees C.

For Maxwell or newer fully supported devices.

See TemperatureThreshold for details on available temperature thresholds.

§Errors

Returns an error if the device is inaccessible, if NVML rejects the handle, threshold type, or temperature value, if the device does not support setting this threshold, if NVML has not been initialized, or if NVML reports an unexpected failure.

Source

pub fn margin_temperature(self) -> Result<MarginTemperature>

Returns the thermal margin temperature (distance to nearest slowdown threshold).

§Errors

Returns an error if the installed NVML version does not support the request layout, if the device is inaccessible, if NVML rejects the handle or output, if the platform does not support this query, or if NVML reports an unexpected failure.

Source

pub fn thermal_settings(self, sensor_index: u32) -> Result<ThermalSettings>

Used to execute a list of thermal system instructions.

§Errors

Returns an error if the device is inaccessible, if NVML rejects the handle, sensor index, or output, if the device does not support thermal settings, if NVML has not been initialized, or if NVML reports an unexpected failure.

Source

pub fn power_usage(self) -> Result<u32>

Returns power usage for this GPU and its associated circuitry, such as memory, in milliwatts.

For Fermi or newer fully supported devices.

On Fermi and Kepler GPUs the reading is accurate to within +/- 5% of current power draw. On Ampere (except GA100) or newer GPUs, this returns power averaged over a one-second interval. On GA100 and older architectures, instantaneous power is returned.

See NVML_FI_DEV_POWER_AVERAGE on newer architectures and NVML_FI_DEV_POWER_INSTANT to query specific power values.

It is only available if power management mode is supported. See sys::nvmlDeviceGetPowerManagementMode.

§Errors

Returns an error if the device is inaccessible, if NVML rejects the handle or output, if the device does not support power readings, if NVML has not been initialized, or if NVML reports an unexpected failure.

Source

pub fn power_management_mode(self) -> Result<EnableState>

Source

pub fn power_management_limit(self) -> Result<u32>

Returns the power management limit associated with this device.

For Fermi or newer fully supported devices.

The power limit defines the upper boundary for the card’s power draw. If the card’s total power draw reaches this limit the power management algorithm kicks in.

This reading is only available if power management mode is supported. See sys::nvmlDeviceGetPowerManagementMode.

§Errors

Returns an error if the device is inaccessible, if NVML rejects the handle or output, if the device does not support power limits, if NVML has not been initialized, or if NVML reports an unexpected failure.

Source

pub fn set_power_management_limit(self, limit: u32) -> Result<()>

Sets a new power limit for this device.

For Kepler or newer fully supported devices. Requires root/admin permissions.

See Device::power_management_limit_constraints to check the allowed ranges of values.

Limit is not persistent across reboots or driver unloads. Enable persistent mode to prevent driver from unloading when no application is using the device.

§Errors

Returns an error if the device is inaccessible, if NVML rejects the handle or power limit, if the device does not support power-limit control, if NVML has not been initialized, or if NVML reports an unexpected failure.

Source

pub fn power_management_default_limit(self) -> Result<u32>

Returns default power management limit on this device, in milliwatts. Default power management limit is a power management limit that the device boots with.

For Kepler or newer fully supported devices.

§Errors

Returns an error if the device is inaccessible, if NVML rejects the handle or output, if the device does not support power limits, if NVML has not been initialized, or if NVML reports an unexpected failure.

Source

pub fn enforced_power_limit(self) -> Result<u32>

Returns the effective power limit that the driver enforces after taking into account all limiters.

This can differ from Device::power_management_limit if other limits are set elsewhere. This includes the out-of-band power-limit interface.

For Kepler or newer fully supported devices.

§Errors

Returns an error if the device is inaccessible, if NVML rejects the handle or output, if the device does not support power limits, if NVML has not been initialized, or if NVML reports an unexpected failure.

Source

pub fn power_management_limit_constraints(self) -> Result<PowerLimits>

Returns information about possible values of power management limits on this device.

For Kepler or newer fully supported devices.

§Errors

Returns an error if the device is inaccessible, if NVML rejects the handle or outputs, if the device does not support power-limit ranges, if NVML has not been initialized, or if NVML reports an unexpected failure.

Source

pub fn power_mizer_mode(self) -> Result<PowerMizerModes>

Returns current power mizer mode on this device.

PowerMizerMode provides a hint to the driver as to how to manage the performance of the GPU.

For Maxwell or newer fully supported devices.

§Errors

Returns an error if the device is inaccessible, if NVML rejects the handle or output, if the device does not support PowerMizer mode readings, if NVML has not been initialized, or if NVML reports an unexpected failure.

Source

pub fn set_power_mizer_mode(self, mode: PowerMizerMode) -> Result<()>

Sets the new power mizer mode.

For Maxwell or newer fully supported devices.

§Errors

Returns an error if the device is inaccessible, if NVML rejects the handle or mode, if the device does not support PowerMizer mode changes, if NVML has not been initialized, or if NVML reports an unexpected failure.

Source

pub fn total_energy_consumption(self) -> Result<u64>

Returns total energy consumption for this GPU in millijoules (mJ) since the driver was last reloaded.

For Volta or newer fully supported devices.

§Errors

Returns an error if the device is inaccessible, if NVML rejects the handle or output, if the device does not support energy readings, if NVML has not been initialized, or if NVML reports an unexpected failure.

Source

pub fn compute_capability(self) -> Result<ComputeCapability>

Returns the CUDA compute capability of the device.

For all products.

Returns the major and minor compute capability version numbers of the device. The major and minor versions are equivalent to the CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MINOR and CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MAJOR attributes returned by cuDeviceGetAttribute.

§Errors

Returns an error if the device is inaccessible, if NVML rejects the handle or outputs, if NVML has not been initialized, or if NVML reports an unexpected failure.

Source

pub fn performance_state(self) -> Result<PerformanceState>

Returns the current performance state for the device.

For Fermi or newer fully supported devices.

See PerformanceState for details on allowed performance states.

§Errors

Returns an error if the device is inaccessible, if NVML rejects the handle or output, if the device does not support performance-state queries, if NVML has not been initialized, or if NVML reports an unexpected failure.

Source

pub fn power_state(self) -> Result<PerformanceState>

Source

pub fn supported_performance_states(self) -> Result<Vec<PerformanceState>>

Returns all supported performance states (P-states) for the device.

The returned array contains a contiguous list of valid P-states supported by the device. If the number of supported P-states is smaller than the supplied array, missing elements contain PerformanceState::Unknown.

The number of returned elements never exceeds NVML_MAX_GPU_PERF_PSTATES.

§Errors

Returns an error if the fixed internal P-state buffer is too small, if NVML rejects the query, if the device does not support performance-state readings, if NVML has not been initialized, or if NVML reports an unexpected failure.

Source

pub fn current_clocks_event_reasons(self) -> Result<u64>

Returns current clocks event reasons.

For all fully supported products.

More than one bit can be enabled at the same time. Multiple reasons can be affecting clocks at once.

§Errors

Returns an error if the device is inaccessible, if NVML rejects the handle or output, if the device does not support clocks-event reasons, if NVML has not been initialized, or if NVML reports an unexpected failure.

Source

pub fn current_clocks_throttle_reasons(self) -> Result<u64>

Source

pub fn supported_clocks_event_reasons(self) -> Result<u64>

Returns bitmask of supported clocks event reasons that can be returned by Device::current_clocks_event_reasons.

For all fully supported products.

Not supported in virtual machines running virtual GPU (vGPU).

§Errors

Returns an error if the device is inaccessible, if NVML rejects the handle or output, if NVML has not been initialized, or if NVML reports an unexpected failure.

Source

pub fn supported_clocks_throttle_reasons(self) -> Result<u64>

Source

pub fn supported_event_types(self) -> Result<EventTypes>

Returns the event types supported by this device.

For Fermi or newer fully supported devices.

Events are not supported on Windows. Therefore, this call returns an empty event mask on Windows.

§Errors

Returns an error if the device is inaccessible, if NVML rejects the event mask output, if NVML has not been initialized, or if NVML reports an unexpected failure.

Source

pub fn board_id(self) -> Result<u32>

Returns the device board ID in the range 0..N. Devices with the same board ID indicate GPUs connected to the same PLX. Use in conjunction with Device::is_multi_gpu_board to decide if they are on the same board as well. The returned board ID is unique for the current configuration. Uniqueness and ordering across reboots and system configurations are not guaranteed, but IDs remain distinct within one configuration.

For Fermi or newer fully supported devices.

§Errors

Returns an error if the device is inaccessible, if NVML rejects the handle or output, if the device does not support board IDs, if NVML has not been initialized, or if NVML reports an unexpected failure.

Source

pub fn display_mode(self) -> Result<EnableState>

Returns the display mode for the device.

For all products.

Indicates whether a physical display, such as a monitor, is currently connected to any of the device’s connectors.

See EnableState for details on allowed modes.

§Errors

Returns an error if the device is inaccessible, if NVML rejects the handle or output, if the device does not support display-mode reporting, if NVML has not been initialized, or if NVML reports an unexpected failure.

Source

pub fn display_active(self) -> Result<EnableState>

Returns the display active state for the device.

For all products.

Indicates whether a display is initialized on the device. For example whether X Server is attached to this device and has allocated memory for the screen.

Display can be active even when no monitor is physically attached.

See EnableState for details on allowed modes.

§Errors

Returns an error if the device is inaccessible, if NVML rejects the query, if the device does not support display-active reporting, if NVML has not been initialized, or if NVML reports an unexpected failure.

Source

pub fn ecc_mode(self) -> Result<CurrentPending<EnableState>>

Returns the current and pending ECC modes for the device.

For Fermi or newer fully supported devices. Only applicable to devices with ECC. Requires InforomObject::Ecc version 1.0 or higher.

Changing ECC modes requires a reboot. The “pending” ECC mode refers to the target mode following the next reboot.

See EnableState for details on allowed modes.

§Errors

Returns an error if the device is inaccessible, if NVML rejects the handle or outputs, if the device does not support ECC mode reporting, if NVML has not been initialized, or if NVML reports an unexpected failure.

Source

pub fn default_ecc_mode(self) -> Result<EnableState>

Returns the default ECC modes for the device.

For Fermi or newer fully supported devices. Only applicable to devices with ECC. Requires InforomObject::Ecc version 1.0 or higher.

See EnableState for details on allowed modes.

§Errors

Returns an error if the device is inaccessible, if NVML rejects the handle or output, if the device does not support ECC mode reporting, if NVML has not been initialized, or if NVML reports an unexpected failure.

Source

pub fn gpu_operation_mode(self) -> Result<CurrentPending<GpuOperationMode>>

Returns the current GPU operation mode and the pending mode that will take effect after reboot.

For GK110 M-class and X-class Tesla products from the Kepler family. Modes GpuOperationMode::LowDp and GpuOperationMode::AllOn are supported on fully supported GeForce products. Not supported on Quadro and Tesla C-class products.

§Errors

Returns an error if the device is inaccessible, if NVML rejects the handle or outputs, if the device does not support GPU operation modes, if NVML has not been initialized, or if NVML reports an unexpected failure.

Source

pub fn driver_model(self) -> Result<CurrentPending<DriverModel>>

Returns the current and pending driver model for the device.

For Kepler or newer fully supported devices. For windows only.

On Windows platforms the device driver can run in either WDDM, MCDM or WDM (TCC) modes. If a display is attached to the device it must run in WDDM mode. MCDM mode is preferred if a display is not attached. TCC mode is deprecated.

See DriverModel for details on available driver models.

§Errors

Returns an error if the device is inaccessible, if NVML rejects the handle or outputs, if the platform is not Windows, if NVML has not been initialized, or if NVML reports an unexpected failure.

Source

pub fn set_driver_model( self, model: DriverModel, flags: DriverModelFlags, ) -> Result<()>

Sets the driver model for the device.

For Fermi or newer fully supported devices. For windows only. Requires root/admin permissions.

On Windows platforms the device driver can run in either WDDM or WDM (TCC) mode. If a display is attached to the device it must run in WDDM mode.

It is possible to force the change to WDM (TCC) while the display is still attached with a force flag (nvmlFlagForce). Use the force flag only if the host is powered down afterward and the display is detached from the device before the next reboot.

This operation takes effect after the next reboot.

Windows driver model may only be set to WDDM when running in DEFAULT compute mode.

Changing the driver model to WDDM is not supported when the GPU does not support graphics acceleration, or would not support it after reboot. See Device::set_gpu_operation_mode.

See DriverModel for details on available driver models. See DriverModelFlags for the available flag values.

§Errors

Returns an error if the device is inaccessible, if NVML rejects the handle, driver model, or flags, if the platform is not Windows or the device does not support driver-model changes, if the current process lacks permission, if NVML has not been initialized, or if NVML reports an unexpected failure.

Source

pub fn set_gpu_operation_mode(self, mode: GpuOperationMode) -> Result<()>

Sets the GPU operation mode. See GpuOperationMode for details.

For GK110 M-class and X-class Tesla products from the Kepler family. Modes GpuOperationMode::LowDp and GpuOperationMode::AllOn are supported on fully supported GeForce products. Not supported on Quadro and Tesla C-class products. Requires root/admin permissions.

Changing GOMs requires a reboot. The reboot requirement might be removed in the future.

Compute-only GOMs do not support graphics acceleration. On Windows, switching to these GOMs is not supported when the pending driver model is WDDM. See Device::set_driver_model.

§Errors

Returns an error if the device is inaccessible, if NVML rejects the handle or mode, if the device does not support GPU operation mode changes or the requested mode, if the current process lacks permission, if NVML has not been initialized, or if NVML reports an unexpected failure.

Source

pub fn inforom_image_version(self) -> Result<String>

Source

pub fn inforom_version(self, object: InforomObject) -> Result<String>

Returns the version information for the device’s infoROM object.

For all products with an inforom.

Fermi and higher parts have non-volatile on-board memory for persisting device info, such as aggregate ECC counts. The version of the data structures in this memory may change from time to time. It does not exceed 16 bytes including the terminating NUL byte. This wrapper allocates the required NVML buffer internally.

See InforomObject for details on the available infoROM objects.

§Errors

Returns an error if the device is inaccessible, if the internal infoROM version buffer is too small, if NVML rejects the output, if the device does not have an infoROM, if NVML has not been initialized, or if NVML reports an unexpected failure.

Source

pub fn inforom_configuration_checksum(self) -> Result<u32>

Returns the checksum of the configuration stored in the device’s infoROM.

For all products with an inforom.

Can be used to make sure that two GPUs have the exact same configuration. Current checksum takes into account configuration stored in PWR and ECC infoROM objects. The checksum can change between driver releases or when configuration changes, such as disabling or enabling ECC.

§Errors

Returns an error if the infoROM checksum cannot be read because the infoROM is corrupted, if the device is inaccessible, if NVML rejects the output, if the device does not support checksums, if NVML has not been initialized, or if NVML reports an unexpected failure.

Source

pub fn validate_inforom(self) -> Result<()>

Reads the infoROM from the flash and verifies the checksums.

For all products with an inforom.

§Errors

Returns an error if the infoROM is corrupted, if the device is inaccessible, if the device does not support infoROM validation, if NVML has not been initialized, or if NVML reports an unexpected failure.

Source

pub fn last_bbx_flush_time(self) -> Result<BbxFlushTime>

Returns the timestamp and the duration of the last flush of the BBX (blackbox) infoROM object during the current run.

For all products with an inforom.

§Errors

Returns an error if the device is inaccessible, if the BBX object has not been flushed yet, if the device does not have an infoROM, or if NVML reports an unexpected failure.

Source

pub fn adaptive_clock_info_status(self) -> Result<AdaptiveClockInfoStatus>

Returns the device’s Adaptive Clock status.

§Errors

Returns an error if the device is inaccessible, if NVML rejects the handle or output, if the device does not support adaptive-clock status, or if NVML has not been initialized.

Source

pub fn clk_mon_status(self) -> Result<ClkMonStatus>

Returns the frequency monitor fault status for the device.

For Ampere or newer fully supported devices. Requires root privileges.

Returns the decoded frequency-monitor fault status reported by NVML.

§Errors

Returns an error if the device is inaccessible, if NVML rejects the handle or output, if the device does not support frequency-monitor status, if NVML has not been initialized, or if NVML reports an unexpected failure.

Source

pub fn sram_ecc_error_status(self) -> Result<EccSramErrorStatus>

Returns SRAM ECC error status of this device.

For Ampere or newer fully supported devices. Requires root/admin permissions.

Returns the SRAM ECC error status reported by NVML.

§Errors

Returns an error if the installed NVML version does not support the request layout, if the device is inaccessible, if NVML rejects the handle or output, if the device does not support SRAM ECC status, if NVML has not been initialized, or if NVML reports an unexpected failure.

Source

pub fn sram_unique_uncorrected_ecc_error_counts( self, ) -> Result<EccSramUniqueUncorrectedErrorCounts>

Source

pub fn irq_number(self) -> Result<u32>

Returns the device’s interrupt number.

§Errors

Returns an error if the device is inaccessible, if NVML rejects the handle or output, if the device does not support IRQ-number reporting, or if NVML has not been initialized.

Source

pub fn num_gpu_cores(self) -> Result<u32>

Returns the device’s core count.

On MIG-enabled GPUs, querying the device’s core count is currently not supported by this operation. Use sys::nvmlDeviceGetGpuInstanceProfileInfo to fetch the MIG device’s core count.

§Errors

Returns an error if the device is inaccessible, if NVML rejects the handle or output, if the device or MIG device does not support core-count reporting, or if NVML has not been initialized.

Source

pub fn memory_bus_width(self) -> Result<u32>

Returns the device’s memory bus width.

§Errors

Returns an error if the device is inaccessible, if NVML rejects the handle or output, if the device does not support memory-bus-width reporting, or if NVML has not been initialized.

Source

pub fn bus_type(self) -> Result<BusType>

Returns the GPU bus type, such as PCIe or PCI.

§Errors

Returns an error if NVML has not been initialized, if NVML rejects the handle or output, or if NVML reports an unexpected failure.

Source

pub fn power_source(self) -> Result<PowerSource>

Returns the device power source.

§Errors

Returns an error if the device is inaccessible, if NVML rejects the handle or output, if the device does not support power-source reporting, or if NVML has not been initialized.

Source

pub fn total_ecc_errors( self, error_type: MemoryErrorType, counter_type: EccCounterType, ) -> Result<u64>

Returns the total ECC error counts for the device.

For Fermi or newer fully supported devices. Only applicable to devices with ECC. Requires InforomObject::Ecc version 1.0 or higher. Requires ECC Mode to be enabled.

The total error count is the sum of errors across each separate memory system, that is, the total set of errors across the entire device.

See MemoryErrorType for a description of available error types. See EccCounterType for a description of available counter types.

§Errors

Returns an error if the device is inaccessible, if NVML rejects the handle, error type, counter type, or output, if the device does not support ECC error reporting, if NVML has not been initialized, or if NVML reports an unexpected failure.

Source

pub fn detailed_ecc_errors( self, error_type: MemoryErrorType, counter_type: EccCounterType, ) -> Result<EccErrorCounts>

Source

pub fn memory_error_counter( self, error_type: MemoryErrorType, counter_type: EccCounterType, location: MemoryLocation, ) -> Result<u64>

Returns the requested memory error counter for the device.

For Fermi or newer fully supported devices. Requires InforomObject::Ecc version 2.0 or higher to report aggregate location-based memory error counts. Requires InforomObject::Ecc version 1.0 or higher to report all other memory error counts.

Only applicable to devices with ECC.

Requires ECC Mode to be enabled.

On MIG-enabled GPUs, per instance information can be queried using specific MIG device handles. Per instance information is currently only supported for non-DRAM uncorrectable volatile errors. Querying volatile errors using device handles is currently not supported.

See MemoryErrorType for a description of available memory error types. See EccCounterType for a description of available counter types. See MemoryLocation for a description of available counter locations.

§Errors

Returns an error if the device is inaccessible, if NVML rejects the handle, error type, counter type, memory location, or output, if the device does not support ECC error reporting for the requested memory location, if NVML has not been initialized, or if NVML reports an unexpected failure.

Source

pub fn violation_status( self, perf_policy: PerfPolicyType, ) -> Result<ViolationTime>

Source

pub fn retired_pages( self, cause: PageRetirementCause, ) -> Result<Vec<RetiredPage>>

Returns the list of retired pages by source, including pages that are pending retirement. The returned address information is the hardware address of the retired page. This does not match the virtual address used in CUDA, but it matches the address information in Xid 63.

Device::retired_pages adds an additional timestamps parameter to return the time of each page’s retirement. This is supported for Pascal and newer architecture.

For Kepler or newer fully supported devices.

§Errors

Returns an error if the device is inaccessible, if the retired-page list changes while the wrapper is fetching it, if NVML rejects the handle, cause, count, or outputs, if the device does not support page retirement, if NVML has not been initialized, or if NVML reports an unexpected failure.

Source

pub fn retired_pages_pending_status(self) -> Result<EnableState>

Check if any pages are pending retirement and need a reboot to fully retire.

For Kepler or newer fully supported devices.

§Errors

Returns an error if the device is inaccessible, if NVML rejects the handle or output, if the device does not support page-retirement status, if NVML has not been initialized, or if NVML reports an unexpected failure.

Source

pub fn remapped_rows(self) -> Result<RemappedRows>

Returns the number of remapped rows. The number of rows reported is based on the remapping cause. is_pending indicates whether there are pending remappings. A reset is required to actually remap the row. failure_occurred is set if a row remapping ever failed in the past. A pending remapping does not affect future GPU work because error containment and dynamic page blacklisting handle it.

On MIG-enabled GPUs with active instances, querying the number of remapped rows is not supported.

For Ampere or newer fully supported devices.

§Errors

Returns an error if NVML rejects the handle or outputs, if MIG is enabled or the device does not support remapped-row reporting, or if NVML reports an unexpected failure.

Source

pub fn row_remapper_histogram(self) -> Result<RowRemapperHistogram>

Returns the row remapper histogram. Returns the remap availability for each bank on the GPU.

§Errors

Returns an error if NVML reports an unexpected row-remapper query failure.

Source

pub fn field_values(self, queries: &[FieldQuery]) -> Result<Vec<FieldSample>>

Requests values for a list of device fields. Allows multiple fields to be queried at once. If multiple field IDs are populated by the same driver call, NVML populates those results from one call rather than one call per field ID.

§Errors

Returns an error if NVML rejects the device handle or field-value buffer.

Source

pub fn clear_field_values( self, queries: &[FieldQuery], ) -> Result<Vec<FieldSample>>

Clear values for a list of fields for a device. Allows multiple fields to be cleared at once.

§Errors

Returns an error if NVML rejects the device handle or field-value buffer.

Source

pub fn samples( self, kind: SamplingType, last_seen_timestamp: u64, ) -> Result<Samples>

Returns recent samples for the GPU.

For Kepler or newer fully supported devices.

Fetches power, utilization, or clock samples maintained in the driver’s buffer, depending on the requested sample type.

Power, utilization, and clock samples are returned as unsigned integer values.

This wrapper performs the size query internally and returns the samples as an owned collection.

last_seen_timestamp represents a CPU timestamp in microseconds. Use 0 to fetch all samples maintained by the buffer. Use a timestamp returned by a previous query to get more recent samples.

This wrapper performs the NVML size query internally and returns the samples that were actually retrieved. Compared with polling the current-value methods, samples provide higher-frequency data at lower polling cost.

On MIG-enabled GPUs, querying the following sample types, SamplingType::GpuUtilization, SamplingType::MemoryUtilization, SamplingType::EncoderUtilization, and SamplingType::DecoderUtilization, is not currently supported.

§Errors

Returns an error if the device is inaccessible, if NVML rejects the query, if the device does not support the requested sample type, if NVML has not been initialized, or if NVML reports an unexpected failure. Missing sample entries are returned as an empty sample list.

Source

pub fn gsp_firmware_version(self) -> Result<String>

Returns GSP firmware version.

This wrapper allocates the firmware-version buffer internally and returns it as a String.

§Errors

Returns an error if NVML rejects the device or output buffer, if GSP firmware is not enabled for the GPU, or if NVML reports an unexpected failure.

Source

pub fn gsp_firmware_mode(self) -> Result<GspFirmwareMode>

Returns GSP firmware mode.

Returns GSP firmware enablement and default mode information.

§Errors

Returns an error if NVML rejects the query, if GSP firmware is not enabled for the GPU, or if NVML reports an unexpected failure.

Source

pub fn num_fans(self) -> Result<u32>

Returns the number of fans on the device.

For all discrete products with dedicated fans.

§Errors

Returns an error if the device is inaccessible, if NVML rejects the handle or output, if the device does not have a fan, if NVML has not been initialized, or if NVML reports an unexpected failure.

Examples found in repository?
examples/fan_curve.rs (line 16)
12fn main() -> Result<(), Box<dyn Error>> {
13    let nvml = Library::create()?;
14    let device = nvml.device(GPU_INDEX)?;
15    let name = device.name()?;
16    let fans = device.num_fans()?;
17    let fan_limits = device.min_max_fan_speed()?;
18
19    println!("controlling GPU {GPU_INDEX}: {name}");
20    println!("fan speed range: {}%-{}%", fan_limits.min, fan_limits.max);
21    println!("curve: {CURVE:?}");
22    if !APPLY_CHANGES {
23        println!("dry run: set APPLY_CHANGES to true to write fan speeds");
24    }
25
26    for _ in 0..POLLS {
27        // Read the GPU temperature and choose a speed from the curve.
28        let temperature = device.temperature_reading(TemperatureSensor::Gpu)?;
29        let target_speed =
30            fan_speed_for_temperature(temperature).clamp(fan_limits.min, fan_limits.max);
31
32        // Apply the same target to every fan controller on the selected GPU.
33        for fan in 0..fans {
34            let current_speed = device.fan_speed(fan)?;
35            println!("fan {fan}: {temperature} C -> {target_speed}% (currently {current_speed}%)");
36
37            if APPLY_CHANGES && current_speed != target_speed {
38                device.set_fan_speed(fan, target_speed)?;
39            }
40        }
41
42        thread::sleep(POLL_INTERVAL);
43    }
44
45    Ok(())
46}
Source

pub fn default_fan_speed(self) -> Result<u32>

Returns the intended operating speed of the device’s fan.

The reported speed is the intended fan speed. If the fan is physically blocked and unable to spin, the output does not match the actual fan speed.

For all discrete products with dedicated fans.

The fan speed is expressed as a percentage of the product’s maximum noise tolerance fan speed. This value may exceed 100% in certain cases.

§Errors

Returns an error if the device is inaccessible, if NVML rejects the handle or output, if the device does not have a fan, if NVML has not been initialized, or if NVML reports an unexpected failure.

Source

pub fn fan_speed(self, fan: u32) -> Result<u32>

Returns the intended operating speed of the device’s specified fan.

The reported speed is the intended fan speed. If the fan is physically blocked and unable to spin, the output does not match the actual fan speed.

For all discrete products with dedicated fans.

The fan speed is expressed as a percentage of the product’s maximum noise tolerance fan speed. This value may exceed 100% in certain cases.

§Errors

Returns an error if the device is inaccessible, if NVML rejects the handle, fan index, or output, if the device does not have a supported fan interface, if NVML has not been initialized, or if NVML reports an unexpected failure.

Examples found in repository?
examples/fan_curve.rs (line 34)
12fn main() -> Result<(), Box<dyn Error>> {
13    let nvml = Library::create()?;
14    let device = nvml.device(GPU_INDEX)?;
15    let name = device.name()?;
16    let fans = device.num_fans()?;
17    let fan_limits = device.min_max_fan_speed()?;
18
19    println!("controlling GPU {GPU_INDEX}: {name}");
20    println!("fan speed range: {}%-{}%", fan_limits.min, fan_limits.max);
21    println!("curve: {CURVE:?}");
22    if !APPLY_CHANGES {
23        println!("dry run: set APPLY_CHANGES to true to write fan speeds");
24    }
25
26    for _ in 0..POLLS {
27        // Read the GPU temperature and choose a speed from the curve.
28        let temperature = device.temperature_reading(TemperatureSensor::Gpu)?;
29        let target_speed =
30            fan_speed_for_temperature(temperature).clamp(fan_limits.min, fan_limits.max);
31
32        // Apply the same target to every fan controller on the selected GPU.
33        for fan in 0..fans {
34            let current_speed = device.fan_speed(fan)?;
35            println!("fan {fan}: {temperature} C -> {target_speed}% (currently {current_speed}%)");
36
37            if APPLY_CHANGES && current_speed != target_speed {
38                device.set_fan_speed(fan, target_speed)?;
39            }
40        }
41
42        thread::sleep(POLL_INTERVAL);
43    }
44
45    Ok(())
46}
Source

pub fn fan_speed_rpm(self, fan: u32) -> Result<FanSpeedInfo>

Returns the intended operating speed in rotations per minute (RPM) of the device’s specified fan.

For Maxwell or newer fully supported devices.

For all discrete products with dedicated fans.

The reported speed is the intended fan speed. If the fan is physically blocked and unable to spin, the output does not match the actual fan speed.

§Errors

Returns an error if the installed NVML version does not support the request layout, if NVML rejects the handle, fan index, or output, if the device does not support fan RPM reporting, or if NVML has not been initialized.

Source

pub fn fan_control_policy(self, fan: u32) -> Result<FanPolicy>

Returns current fan control policy.

For Maxwell or newer fully supported devices.

For all cuda-capable discrete products with fans.

§Errors

Returns an error if NVML rejects the handle, fan index, or output, if the device does not support fan policies, if NVML has not been initialized, or if NVML reports an unexpected failure.

Source

pub fn set_default_fan_speed(self, fan: u32) -> Result<()>

Sets the speed of the fan control policy to default.

For all cuda-capable discrete products with fans.

§Errors

Returns an error if NVML rejects the handle or fan index, if the device does not support fan-speed control, if NVML has not been initialized, or if NVML reports an unexpected failure.

Source

pub fn set_fan_control_policy(self, fan: u32, policy: FanPolicy) -> Result<()>

Sets current fan control policy.

For Maxwell or newer fully supported devices.

Requires privileged access.

For all cuda-capable discrete products with fans.

§Errors

Returns an error if NVML rejects the handle, fan index, or policy, if the device does not support fan policies, if NVML has not been initialized, or if NVML reports an unexpected failure.

Source

pub fn set_fan_speed(self, fan: u32, speed: u32) -> Result<()>

Sets the speed of a specified fan.

Warning: this changes the fan control policy to manual. You must monitor the temperature and adjust the fan speed accordingly. Setting the fan speed too low can damage the GPU. Use Device::set_default_fan_speed to restore default control policy.

For all cuda-capable discrete products with fans that are Maxwell or Newer.

§Errors

Returns an error if NVML has not been initialized, if NVML rejects the handle, fan index, or speed, if the device does not support manual fan speed control, or if NVML reports an unexpected failure.

Examples found in repository?
examples/fan_curve.rs (line 38)
12fn main() -> Result<(), Box<dyn Error>> {
13    let nvml = Library::create()?;
14    let device = nvml.device(GPU_INDEX)?;
15    let name = device.name()?;
16    let fans = device.num_fans()?;
17    let fan_limits = device.min_max_fan_speed()?;
18
19    println!("controlling GPU {GPU_INDEX}: {name}");
20    println!("fan speed range: {}%-{}%", fan_limits.min, fan_limits.max);
21    println!("curve: {CURVE:?}");
22    if !APPLY_CHANGES {
23        println!("dry run: set APPLY_CHANGES to true to write fan speeds");
24    }
25
26    for _ in 0..POLLS {
27        // Read the GPU temperature and choose a speed from the curve.
28        let temperature = device.temperature_reading(TemperatureSensor::Gpu)?;
29        let target_speed =
30            fan_speed_for_temperature(temperature).clamp(fan_limits.min, fan_limits.max);
31
32        // Apply the same target to every fan controller on the selected GPU.
33        for fan in 0..fans {
34            let current_speed = device.fan_speed(fan)?;
35            println!("fan {fan}: {temperature} C -> {target_speed}% (currently {current_speed}%)");
36
37            if APPLY_CHANGES && current_speed != target_speed {
38                device.set_fan_speed(fan, target_speed)?;
39            }
40        }
41
42        thread::sleep(POLL_INTERVAL);
43    }
44
45    Ok(())
46}
Source

pub fn target_fan_speed(self, fan: u32) -> Result<u32>

Returns the intended target speed of the device’s specified fan.

Normally, the driver dynamically adjusts the fan based on the needs of the GPU. When the caller sets fan speed with Device::set_fan_speed, the driver attempts to make the fan achieve that setting. The actual current speed of the fan is reported in Device::fan_speed.

For all discrete products with dedicated fans.

The fan speed is expressed as a percentage of the product’s maximum noise tolerance fan speed. This value may exceed 100% in certain cases.

§Errors

Returns an error if the device is inaccessible, if NVML rejects the handle, fan index, or output, if the device does not have a supported fan interface, if NVML has not been initialized, or if NVML reports an unexpected failure.

Source

pub fn min_max_fan_speed(self) -> Result<MinMaxFanSpeed>

Returns the min and max fan speed that can be set for the GPU fan.

For all cuda-capable discrete products with fans.

§Errors

Returns an error if NVML rejects the handle or output, if the device does not support fan-speed range reporting, if NVML has not been initialized, or if NVML reports an unexpected failure.

Examples found in repository?
examples/fan_curve.rs (line 17)
12fn main() -> Result<(), Box<dyn Error>> {
13    let nvml = Library::create()?;
14    let device = nvml.device(GPU_INDEX)?;
15    let name = device.name()?;
16    let fans = device.num_fans()?;
17    let fan_limits = device.min_max_fan_speed()?;
18
19    println!("controlling GPU {GPU_INDEX}: {name}");
20    println!("fan speed range: {}%-{}%", fan_limits.min, fan_limits.max);
21    println!("curve: {CURVE:?}");
22    if !APPLY_CHANGES {
23        println!("dry run: set APPLY_CHANGES to true to write fan speeds");
24    }
25
26    for _ in 0..POLLS {
27        // Read the GPU temperature and choose a speed from the curve.
28        let temperature = device.temperature_reading(TemperatureSensor::Gpu)?;
29        let target_speed =
30            fan_speed_for_temperature(temperature).clamp(fan_limits.min, fan_limits.max);
31
32        // Apply the same target to every fan controller on the selected GPU.
33        for fan in 0..fans {
34            let current_speed = device.fan_speed(fan)?;
35            println!("fan {fan}: {temperature} C -> {target_speed}% (currently {current_speed}%)");
36
37            if APPLY_CHANGES && current_speed != target_speed {
38                device.set_fan_speed(fan, target_speed)?;
39            }
40        }
41
42        thread::sleep(POLL_INTERVAL);
43    }
44
45    Ok(())
46}
Source

pub fn cooler_info(self, index: u32) -> Result<CoolerInfo>

Returns the cooler’s information. Returns a cooler’s control signal characteristics. The possible types are restricted, Variable and Toggle. See CoolerControl for details on available signal types. Returns objects that cooler cools. Targets may be GPU, Memory, Power Supply or All of these. See CoolerTarget for details on available targets.

For Maxwell or newer fully supported devices.

For all discrete products with dedicated fans.

§Errors

Returns an error if the installed NVML version does not support the request layout, if NVML rejects the handle or cooler index, if the device does not support cooler reporting, or if NVML has not been initialized.

Source

pub fn temperature(self, sensor: TemperatureSensor) -> Result<TemperatureInfo>

Returns the current temperature readings (in degrees C) for the given device.

For all products.

§Errors

Returns an error if the device is inaccessible, if NVML rejects the handle, sensor type, or output, if the device does not have the requested sensor, if NVML has not been initialized, or if NVML reports an unexpected failure.

Source

pub fn minor_number(self) -> Result<u32>

Returns minor number for the device. The minor number is the suffix in the Linux device node path /dev/nvidia[minor_number].

For all products. Supported only for Linux.

§Errors

Returns an error if the device is inaccessible, if NVML rejects the handle or output, if the device does not support Linux minor-number reporting, if NVML has not been initialized, or if NVML reports an unexpected failure.

Source

pub fn compute_mode(self) -> Result<ComputeMode>

Returns the current compute mode for the device.

For all products.

See ComputeMode for details on allowed compute modes.

§Errors

Returns an error if the device is inaccessible, if NVML rejects the handle or output, if the device does not support compute-mode reporting, if NVML has not been initialized, or if NVML reports an unexpected failure.

Source

pub fn persistence_mode(self) -> Result<EnableState>

Returns the persistence mode associated with this device.

For all products. For Linux only.

When driver persistence mode is enabled the driver software state is not torn down when the last client disconnects. By default this feature is disabled.

See EnableState for details on allowed modes.

§Errors

Returns an error if the device is inaccessible, if NVML rejects the handle or output, if the device does not support persistence mode, if NVML has not been initialized, or if NVML reports an unexpected failure.

Source

pub fn set_compute_mode(self, mode: ComputeMode) -> Result<()>

Sets the compute mode for the device.

For all products. Requires root/admin permissions.

The compute mode determines whether a GPU can be used for compute operations and whether it can be shared across contexts.

This operation takes effect immediately. Under Linux it is not persistent across reboots and always resets to “Default”. Under Windows it is persistent.

Under Windows, compute mode may only be set to default when running in WDDM.

On MIG-enabled GPUs, compute mode is set to default and changing it is not supported.

See ComputeMode for details on available compute modes.

§Errors

Returns an error if the device is inaccessible, if NVML rejects the handle or mode, if the device does not support compute-mode changes, if the current process lacks permission, if NVML has not been initialized, or if NVML reports an unexpected failure.

Source

pub fn set_persistence_mode(self, mode: EnableState) -> Result<()>

Sets the persistence mode for the device.

For all products. For Linux only. Requires root/admin permissions.

The persistence mode determines whether the GPU driver software is torn down after the last client exits.

This operation takes effect immediately. It is not persistent across reboots. After each reboot the persistence mode is reset to “Disabled”.

See EnableState for available modes.

After disabling persistence mode on a device that has its own NUMA memory, the current device handle is no longer valid. Acquire a fresh handle from the library before continuing to interact with the device. This limitation is currently only applicable to devices that have a coherent NVLink connection to system memory.

§Errors

Returns an error if the device is inaccessible, if NVML rejects the handle or mode, if the device does not support persistence mode, if the current process lacks permission, if NVML has not been initialized, or if NVML reports an unexpected failure.

Source

pub fn set_ecc_mode(self, mode: EnableState) -> Result<()>

Sets the ECC mode for the device.

For Kepler or newer fully supported devices. Only applicable to devices with ECC. Requires InforomObject::Ecc version 1.0 or higher. Requires root/admin permissions.

The ECC mode determines whether the GPU enables its ECC support.

This operation takes effect after the next reboot.

See EnableState for details on available modes.

§Errors

Returns an error if the device is inaccessible, if NVML rejects the handle or mode, if the device does not support ECC mode changes, if the current process lacks permission, if NVML has not been initialized, or if NVML reports an unexpected failure.

Source

pub fn clear_ecc_error_counts(self, counter_type: EccCounterType) -> Result<()>

Clear the ECC error and other memory error counts for the device.

For Kepler or newer fully supported devices. Only applicable to devices with ECC. Requires InforomObject::Ecc version 2.0 or higher to clear aggregate location-based ECC counts. Requires InforomObject::Ecc version 1.0 or higher to clear all other ECC counts. Requires root/admin permissions. Requires ECC Mode to be enabled.

Sets all of the specified ECC counters to 0, including both detailed and total counts.

This operation takes effect immediately.

See MemoryErrorType for details on available counter types.

§Errors

Returns an error if the device is inaccessible, if NVML rejects the handle or counter type, if the device does not support clearing ECC counters, if the current process lacks permission, if NVML has not been initialized, or if NVML reports an unexpected failure.

Source

pub fn mig_mode(self) -> Result<CurrentPending<MigMode>>

Returns MIG mode for the device.

For Ampere or newer fully supported devices.

Changing MIG modes may require device unbind or reset. The “pending” MIG mode refers to the target mode following the next activation trigger.

§Errors

Returns an error if NVML rejects the handle or outputs, if the device does not support MIG mode, if NVML has not been initialized, or if NVML reports an unexpected failure.

Source

pub fn set_mig_mode(self, mode: MigMode) -> Result<MigModeActivation>

Sets MIG mode for the device.

For Ampere or newer fully supported devices. Requires root privileges.

This mode determines whether a GPU instance can be created.

This may unbind or reset the device to activate the requested mode. Thus, the attributes associated with the device, such as minor number, might change. Query such attributes again after changing the mode.

On certain platforms, such as pass-through virtualization, reset may not be exposed directly and a VM reboot is required. In those cases, the returned activation status is Status::ResetRequired.

The returned activation status contains the appropriate error code when activation is unsuccessful. For example, if device unbind fails because the device is not idle, the status is Status::InUse. Idle the device and retry setting the mode in that case.

On Windows, only disabling MIG mode is supported. activation_status returns Status::NotSupported because GPU reset is not supported on Windows through this operation.

§Errors

Returns an error if NVML rejects the handle, requested mode, or activation-status output, if the device does not support MIG mode, if the current process lacks permission, or if NVML has not been initialized.

Source

pub fn max_mig_device_count(self) -> Result<u32>

Returns the maximum number of MIG devices that can exist under a parent NVML device.

Returns zero if MIG is not supported or enabled.

For Ampere or newer fully supported devices. Supported on Linux only.

§Errors

Returns an error if NVML rejects the handle or output, if NVML has not been initialized, or if NVML reports an unexpected failure.

Source

pub fn is_mig_device_handle(self) -> Result<bool>

Tests if this handle refers to a MIG device.

A MIG device handle is an NVML abstraction which maps to a MIG compute instance. These overloaded references can be used (with some restrictions) interchangeably with a GPU device handle to execute queries at a per-compute instance granularity.

For Ampere or newer fully supported devices. Supported on Linux only.

§Errors

Returns an error if NVML rejects the handle or output, if the device does not support this check, if NVML has not been initialized, or if NVML reports an unexpected failure.

Source

pub fn parent_device_from_mig_handle(self) -> Result<Self>

Returns parent device handle from a MIG device handle.

For Ampere or newer fully supported devices. Supported on Linux only.

§Errors

Returns an error if NVML rejects the MIG device handle or parent output, if the device does not support this query, if NVML has not been initialized, or if NVML reports an unexpected failure.

Source

pub fn mig_device(self, index: u32) -> Result<Self>

Returns MIG device handle for the given index under its parent NVML device.

If the compute instance is destroyed, either explicitly or by destroying, resetting, or unbinding the parent GPU instance or GPU device, the MIG device handle remains invalid and must be requested again. Handles may be reused and their properties can change in the process.

For Ampere or newer fully supported devices. Supported on Linux only.

§Errors

Returns an error if NVML rejects the handle, index, or output, if no MIG device exists at index, if the device does not support this query, if NVML has not been initialized, or if NVML reports an unexpected failure.

Source

pub fn mig_devices(self) -> Result<Vec<Self>>

Source

pub fn gpu_instance_profile_info( self, profile: u32, ) -> Result<GpuInstanceProfileInfo>

Versioned wrapper that requests GPU-instance profile information using the latest supported NVML output layout.

This wrapper sets the version field on the output structure before calling NVML.

For Ampere or newer fully supported devices. Supported on Linux only.

§Errors

Returns an error if NVML rejects the handle, profile, or request layout, if MIG mode is disabled or the profile is unsupported, if the current process lacks permission, or if NVML has not been initialized.

Source

pub fn gpu_instance_profile_info_by_id( self, profile_id: u32, ) -> Result<GpuInstanceProfileInfo>

GPU instance profile query function that accepts profile ID, instead of profile name. It requests the result using the latest supported NVML output layout.

This wrapper sets the version field on the output structure before calling NVML.

For Ampere or newer fully supported devices. Supported on Linux only.

§Errors

Returns an error if NVML rejects the handle, profile ID, or request layout, if MIG mode is disabled or the profile is unsupported, if the current process lacks permission, or if NVML has not been initialized.

Source

pub fn gpu_instance_remaining_capacity(self, profile_id: u32) -> Result<u32>

Returns GPU instance profile capacity.

For Ampere or newer fully supported devices. Supported on Linux only. Requires privileged access.

§Errors

Returns an error if NVML rejects the query, if MIG mode is disabled or profile_id is unsupported, if the current process lacks permission, or if NVML has not been initialized.

Source

pub fn gpu_instance_possible_placements( self, profile_id: u32, ) -> Result<Vec<GpuInstancePlacement>>

Returns GPU instance placements.

A placement represents the location of a GPU instance within a device. Returns all possible placements for the given profile, regardless of whether MIG is enabled. A created GPU instance occupies memory slices described by its placement. Creating a GPU instance fails if its placement overlaps already occupied memory slices.

For Ampere or newer fully supported devices. Supported on Linux only. Requires privileged access.

§Errors

Returns an error if NVML rejects the query, if the device does not support MIG or profile_id is unsupported, if the current process lacks permission, or if NVML has not been initialized.

Source

pub fn gpu_instance_by_id(self, id: u32) -> Result<GpuInstance>

Returns GPU instances for the given instance ID.

For Ampere or newer fully supported devices. Supported on Linux only. Requires privileged access.

§Errors

Returns an error if NVML rejects the query, if no GPU instance has the requested ID, if MIG mode is disabled, if the current process lacks permission, or if NVML has not been initialized.

Source

pub fn create_gpu_instance(self, profile_id: u32) -> Result<OwnedGpuInstance>

Creates a GPU instance.

For Ampere or newer fully supported devices. Supported on Linux only. Requires privileged access.

If the parent device is unbound or reset, or if the GPU instance is destroyed, the GPU instance handle becomes invalid. The GPU instance must be recreated to acquire a valid handle.

§Errors

Returns an error if NVML cannot allocate the requested GPU instance, if NVML rejects the query, if MIG mode is disabled or the device is a vGPU guest, if the current process lacks permission, or if NVML has not been initialized.

Source

pub fn create_gpu_instance_with_placement( self, profile_id: u32, placement: GpuInstancePlacement, ) -> Result<OwnedGpuInstance>

Creates a GPU instance with the specified placement.

For Ampere or newer fully supported devices. Supported on Linux only. Requires privileged access.

If the parent device is unbound or reset, or if the GPU instance is destroyed, the GPU instance handle becomes invalid. The GPU instance must be recreated to acquire a valid handle.

§Errors

Returns an error if NVML cannot allocate the requested GPU instance, if NVML rejects the query or placement, if MIG mode is disabled or the device is a vGPU guest, if the current process lacks permission, or if NVML has not been initialized.

Source

pub fn gpu_instances(self, profile_id: u32) -> Result<Vec<GpuInstance>>

Returns GPU instances for the given profile ID.

For Ampere or newer fully supported devices. Supported on Linux only. Requires privileged access.

§Errors

Returns an error if NVML rejects the query, if MIG mode is disabled, if the current process lacks permission, or if NVML has not been initialized.

Source

pub fn gpu_instance_id(self) -> Result<u32>

Returns the GPU instance ID for this MIG device handle.

GPU instance IDs are unique per device and remain valid until the GPU instance is destroyed.

For Ampere or newer fully supported devices. Supported on Linux only.

§Errors

Returns an error if NVML rejects the handle or output, if the device does not support this query, if NVML has not been initialized, or if NVML reports an unexpected failure.

Source

pub fn compute_instance_id(self) -> Result<u32>

Returns the compute instance ID for this MIG device handle.

Compute instance IDs are unique per GPU instance and remain valid until the compute instance is destroyed.

For Ampere or newer fully supported devices. Supported on Linux only.

§Errors

Returns an error if NVML rejects the handle or output, if the device does not support this query, if NVML has not been initialized, or if NVML reports an unexpected failure.

Source

pub fn virtualization_mode(self) -> Result<VirtualizationMode>

Returns the virtualization mode corresponding to the GPU.

For Kepler or newer fully supported devices.

§Errors

Returns an error if the device is inaccessible, if NVML rejects the query, if NVML has not been initialized, or if NVML reports an unexpected failure.

Source

pub fn host_vgpu_mode(self) -> Result<HostVgpuMode>

Queries if SR-IOV host operation is supported on a vGPU supported device.

Checks whether SR-IOV host capability is supported by the device and the driver, and indicates device is in SR-IOV mode if both of these conditions are true.

§Errors

Returns an error if NVML rejects the query, if the device does not support host vGPU mode reporting, or if NVML reports an unexpected failure.

Source

pub fn supported_vgpus(self) -> Result<Vec<VgpuTypeId>>

Returns the supported vGPU types on a physical GPU (device).

This wrapper performs the NVML size query internally and returns the supported vGPU types as a Vec.

§Errors

Returns an error if the vGPU type list changes while the wrapper is fetching it, if NVML rejects the query, if vGPU is unsupported by the device, or if NVML reports an unexpected failure.

Source

pub fn creatable_vgpus(self) -> Result<Vec<VgpuTypeId>>

Returns the currently creatable vGPU types on a physical GPU.

The creatable vGPU types for a device may differ over time because restrictions can limit which vGPU types may run concurrently. For example, if only one vGPU type is allowed at a time on a device, the creatable list is restricted to the currently running vGPU type. This wrapper performs the NVML size query internally and returns the creatable vGPU types as a Vec.

§Errors

Returns an error if the vGPU type list changes while the wrapper is fetching it, if NVML rejects the query, if vGPU is unsupported by the device, or if NVML reports an unexpected failure.

Source

pub fn vgpu_type_supported_placements( self, vgpu_type_id: VgpuTypeId, mode: VgpuPlacementMode, ) -> Result<Vec<VgpuPlacementId>>

Source

pub fn vgpu_type_creatable_placements( self, vgpu_type_id: VgpuTypeId, mode: VgpuPlacementMode, ) -> Result<Vec<VgpuPlacementId>>

Source

pub fn active_vgpus(self) -> Result<Vec<VgpuInstance>>

Returns the active vGPU instances on a device.

This wrapper performs the NVML size query internally and returns the active vGPU instances as a Vec.

For Kepler or newer fully supported devices.

§Errors

Returns an error if the active vGPU list changes while the wrapper is fetching it, if NVML rejects the query, if vGPU is unsupported by the device, if NVML has not been initialized, or if NVML reports an unexpected failure.

Source

pub fn vgpu_heterogeneous_mode(self) -> Result<EnableState>

Returns the vGPU heterogeneous mode for the device.

When in heterogeneous mode, a vGPU can concurrently host timesliced vGPUs with differing framebuffer sizes.

On success, returns the current vGPU heterogeneous mode as EnableState::Enabled or EnableState::Disabled.

§Errors

Returns an error if the installed NVML version does not support the request layout, if NVML rejects the query, if MIG is enabled or the device does not support vGPU heterogeneous mode, if NVML has not been initialized, or if NVML reports an unexpected failure.

Source

pub fn vgpu_metadata(self) -> Result<PgpuMetadata>

Returns a vGPU metadata structure for this physical GPU. The structure contains information about the GPU and the currently installed NVIDIA host driver version that’s controlling it, together with an opaque data section containing internal state.

This wrapper allocates the metadata buffer internally and retries if NVML reports it is too small.

§Errors

Returns an error if the metadata buffer changes while the wrapper is fetching it, if NVML rejects the metadata request, if vGPU is unsupported by the system, or if NVML reports an unexpected failure.

Source

pub fn pgpu_metadata_string(self) -> Result<String>

Returns this physical GPU’s properties as an ASCII-encoded string.

This wrapper allocates the metadata buffer internally and retries if NVML reports it is too small.

§Errors

Returns an error if the metadata buffer changes while the wrapper is fetching it, if NVML rejects the metadata request, if vGPU is unsupported by the system, or if NVML reports an unexpected failure.

Source

pub fn vgpu_capability(self, capability: DeviceVgpuCapability) -> Result<u32>

Returns the requested vGPU capability for GPU.

See DeviceVgpuCapability for the supported capabilities. Returns whether the capability is supported and any associated capability data.

For Maxwell or newer fully supported devices.

§Errors

Returns an error if NVML rejects the device, capability, or output, if the current state does not support this vGPU capability query, if NVML has not been initialized, or if NVML reports an unexpected failure.

Source

pub fn cpu_affinity(self) -> Result<Vec<u64>>

Returns bitmasks with the ideal CPU affinity for the device. For example, if processors 0, 1, 32, and 33 are ideal for the device and two mask words are requested, then result[0] = 0x3 and result[1] = 0x3. This is equivalent to calling Device::cpu_affinity_within_scope with NVML_AFFINITY_SCOPE_NODE.

For Kepler or newer fully supported devices. Supported on Linux only.

§Errors

Returns an error if the device is inaccessible, if NVML rejects the handle or output buffer, if the device does not support CPU affinity reporting, if NVML has not been initialized, or if NVML reports an unexpected failure.

Source

pub fn cpu_affinity_within_scope(self, scope: AffinityScope) -> Result<Vec<u64>>

Returns bitmasks with the ideal CPU affinity within a node or socket for the device. For example, if processors 0, 1, 32, and 33 are ideal for the device and two mask words are requested, then result[0] = 0x3 and result[1] = 0x3.

If the requested scope is not applicable to the target topology, NVML falls back to reporting CPU affinity for the device’s immediate non-I/O ancestor.

For Kepler or newer fully supported devices. Supported on Linux only.

§Errors

Returns an error if the device is inaccessible, if NVML rejects the handle, scope, or output buffer, if the device does not support scoped CPU affinity reporting, if NVML has not been initialized, or if NVML reports an unexpected failure.

Source

pub fn set_cpu_affinity(self) -> Result<()>

Sets the ideal affinity for the calling thread and device using the guidelines given in Device::cpu_affinity. Note, this is a change as of version 8.0. Older versions set the affinity for a calling process and all children. Currently supports up to 1024 processors.

For Kepler or newer fully supported devices. Supported on Linux only.

§Errors

Returns an error if the device is inaccessible, if NVML rejects the handle, if the device does not support CPU affinity binding, if NVML has not been initialized, or if NVML reports an unexpected failure.

Source

pub fn clear_cpu_affinity(self) -> Result<()>

Clear all affinity bindings for the calling thread. Note, this is a change as of version 8.0 as older versions cleared the affinity for a calling process and all children.

For Kepler or newer fully supported devices. Supported on Linux only.

§Errors

Returns an error if NVML rejects the handle, if NVML has not been initialized, or if NVML reports an unexpected failure.

Source

pub fn memory_affinity(self, scope: AffinityScope) -> Result<Vec<u64>>

Returns bitmasks with the ideal memory affinity within a node or socket for this device. For example, if NUMA nodes 0 and 1 are ideal within the socket and one mask word is requested, result[0] = 0x3.

If the requested scope is not applicable to the target topology, NVML falls back to reporting memory affinity for the device’s immediate non-I/O ancestor.

For Kepler or newer fully supported devices. Supported on Linux only.

§Errors

Returns an error if the device is inaccessible, if NVML rejects the handle, scope, or output buffer, if the device does not support memory affinity reporting, if NVML has not been initialized, or if NVML reports an unexpected failure.

Source

pub fn addressing_mode(self) -> Result<DeviceAddressingMode>

Returns the addressing mode for the given GPU.

DeviceAddressingMode::Hmm makes system-allocated memory (malloc, mmap) addressable from the GPU through software-based mirroring of the CPU page tables. DeviceAddressingMode::Ats makes system-allocated memory addressable from the GPU through Address Translation Services, which means there is effectively a single set of page tables used by both CPU and GPU. DeviceAddressingMode::None means neither HMM nor ATS is active.

For Turing or newer fully supported devices. Supported on Linux only.

§Errors

Returns an error if the installed NVML version does not support the request layout, if NVML rejects the handle, or if the current platform does not support addressing-mode reporting.

Source

pub fn repair_status(self) -> Result<RepairStatus>

Returns the repair status for TPC/channel repair.

For Ampere or newer fully supported devices.

§Errors

Returns an error if the installed NVML version does not support the request layout, if NVML rejects the handle or output, if the device does not support repair-status reporting, if NVML has not been initialized, or if NVML reports an unexpected failure.

Source

pub fn numa_node_id(self) -> Result<u32>

Returns the NUMA node of the given GPU device. This only applies to platforms where the GPUs are NUMA nodes.

§Errors

Returns an error if NVML rejects the handle or output, or if the current platform does not support GPU NUMA-node reporting.

Source

pub fn capabilities(self) -> Result<DeviceCapabilities>

Source

pub fn dynamic_pstates_info(self) -> Result<DynamicPstatesInfo>

Returns performance monitor samples from the associated subdevice.

§Errors

Returns an error if the device is inaccessible, if NVML rejects the query, if the device does not support dynamic P-state samples, if NVML has not been initialized, or if NVML reports an unexpected failure.

Source

pub fn gpu_fabric_info(self) -> Result<GpuFabricInfo>

Versioned wrapper that requests GPU fabric information using the latest supported NVML output layout.

This wrapper sets the version field on the output structure before calling NVML.

For Hopper or newer fully supported devices.

§Errors

Returns an error if the device does not support GPU fabric reporting.

Source

pub fn workload_power_profiles_info(self) -> Result<WorkloadPowerProfilesInfo>

Returns performance profiles information.

For Blackwell or newer fully supported devices. Returns the workload power profile information reported by NVML. The perf_profiles_mask field is a bitmask of all supported mode indices where the mode is supported if the index is 1. Each supported mode has a corresponding entry in the profile array containing the profile ID, the priority of this mode, and a conflicting mask. Lower priority values indicate higher priority, and each bit set in the conflicting mask corresponds to a different profile that cannot be used with the given profile.

§Errors

Returns an error if the installed NVML version does not support the request layout, if the device is inaccessible, if NVML reports that the output layout is too small, if NVML rejects the query, if the device does not support workload power profiles, if NVML has not been initialized, or if NVML reports an unexpected failure.

Source

pub fn workload_power_current_profiles( self, ) -> Result<WorkloadPowerCurrentProfiles>

Returns current performance profiles.

For Blackwell or newer fully supported devices. Returns the current workload power profile state reported by NVML. Returns the current, requested, and enforced performance profile masks. Each bit set in each bitmask indicates whether the profile is supported, currently requested, or currently engaged, respectively.

§Errors

Returns an error if the installed NVML version does not support the request layout, if the device is inaccessible, if NVML rejects the query, if the device does not support workload power profiles, if NVML has not been initialized, or if NVML reports an unexpected failure.

Source

pub fn dram_encryption_mode(self) -> Result<CurrentPending<DramEncryptionInfo>>

Returns the current and pending DRAM Encryption modes for the device.

For Blackwell or newer fully supported devices. Only applicable to devices that support DRAM Encryption. Requires InforomObject::Den version 1.0 or higher.

Changing DRAM Encryption modes requires a reboot. The “pending” DRAM Encryption mode refers to the target mode following the next reboot.

See EnableState for details on allowed modes.

§Errors

Returns an error if the installed NVML version does not support the request layout, if the device is inaccessible, if NVML rejects the handle or outputs, if the device does not support DRAM encryption, if NVML has not been initialized, or if NVML reports an unexpected failure.

Source

pub fn set_dram_encryption_mode( self, dram_encryption: DramEncryptionInfo, ) -> Result<()>

Sets the DRAM encryption mode for the device.

For Kepler or newer fully supported devices. Only applicable to devices that support DRAM Encryption. Requires InforomObject::Den version 1.0 or higher. Requires root/admin permissions.

The DRAM Encryption mode determines whether the GPU enables its DRAM Encryption support.

This operation takes effect after the next reboot.

See EnableState for details on available modes.

§Errors

Returns an error if the installed NVML version does not support the request layout, if the device is inaccessible, if NVML rejects the handle or requested mode, if the device does not support DRAM encryption, if the current process lacks permission, if NVML has not been initialized, or if NVML reports an unexpected failure.

Source

pub fn conf_compute_mem_size_info(self) -> Result<ConfComputeMemSizeInfo>

Returns Confidential Computing protected and unprotected memory sizes.

For Ampere or newer fully supported devices. Supported on Linux, Windows TCC.

§Errors

Returns an error if NVML rejects the query, if the device does not support Confidential Computing memory-size reporting, or if NVML has not been initialized.

Source

pub fn conf_compute_protected_memory_usage(self) -> Result<MemoryInfo>

Returns Confidential Computing protected memory usage.

For Ampere or newer fully supported devices. Supported on Linux, Windows TCC.

§Errors

Returns an error if NVML rejects the query, if the device does not support Confidential Computing protected-memory reporting, if NVML has not been initialized, or if NVML reports an unexpected failure.

Source

pub fn conf_compute_gpu_certificate(self) -> Result<ConfComputeGpuCertificate>

Returns Confidential Computing GPU certificate details.

For Ampere or newer fully supported devices. Supported on Linux, Windows TCC.

§Errors

Returns an error if NVML rejects the query, if the device does not support Confidential Computing certificate reporting, if NVML has not been initialized, or if NVML reports an unexpected failure.

Source

pub fn conf_compute_gpu_attestation_report( self, ) -> Result<ConfComputeGpuAttestationReport>

Returns Confidential Computing GPU attestation report.

For Ampere or newer fully supported devices. Supported on Linux, Windows TCC.

§Errors

Returns an error if NVML rejects the query, if the device does not support Confidential Computing attestation reports, if NVML has not been initialized, or if NVML reports an unexpected failure.

Returns the state of the device’s NVLink for the specified link.

For Pascal or newer fully supported devices.

§Errors

Returns an error if NVML rejects the handle, link index, or output, if the device does not support NVLink state reporting, if NVML has not been initialized, or if NVML reports an unexpected failure.

Returns the version of the device’s NVLink for the specified link.

For Pascal or newer fully supported devices.

§Errors

Returns an error if NVML rejects the handle, link index, or output, if the device does not support NVLink version reporting, if NVML has not been initialized, or if NVML reports an unexpected failure.

Returns the requested capability from the device’s NVLink for the specified link.

See NvLinkCapability for the supported capabilities.

For Pascal or newer fully supported devices.

§Errors

Returns an error if NVML rejects the handle, link index, capability, or output, if the device does not support NVLink capability reporting, if NVML has not been initialized, or if NVML reports an unexpected failure.

Returns the PCI information for the remote node on an NVLink link.

pci_subsystem_id is not filled by this query and is indeterminate.

For Pascal or newer fully supported devices.

§Errors

Returns an error if NVML rejects the handle, link index, or output, if the device does not support remote PCI reporting for NVLink, if NVML has not been initialized, or if NVML reports an unexpected failure.

Returns the NVLink device type of the remote device connected over the given link.

§Errors

Returns an error if the device is inaccessible, if NVML rejects the handle, link index, or output, if NVLink is unsupported, if NVML has not been initialized, or if NVML reports an unexpected failure.

Returns the specified error counter value.

See NvLinkErrorCounter for available counters.

For Pascal or newer fully supported devices.

§Errors

Returns an error if NVML rejects the handle, link index, counter, or output, if the device does not support NVLink error counters, if NVML has not been initialized, or if NVML reports an unexpected failure.

Returns the supported NVLink reduced bandwidth modes of the device.

For Blackwell or newer fully supported devices.

§Errors

Returns an error if the installed NVML version does not support the request layout, if NVML rejects the handle or output, or if the device does not support NVLink bandwidth modes.

Returns the NVLink reduced bandwidth mode for the device.

For Blackwell or newer fully supported devices.

§Errors

Returns an error if the installed NVML version does not support the request layout, if NVML rejects the handle or output, or if the device does not support NVLink bandwidth mode reporting.

Query NVLINK information associated with this device.

§Errors

Returns an error if the installed NVML version does not support the request layout, if the device is inaccessible, if NVML rejects the handle or output, if the device does not support NVLink info reporting, if NVML has not been initialized, or if NVML reports an unexpected failure.

Source

pub fn fbc_stats(self) -> Result<FbcStats>

Returns the active frame buffer capture sessions statistics for the given device.

For Maxwell or newer fully supported devices.

§Errors

Returns an error if the device is inaccessible, if NVML rejects the stats output, if NVML has not been initialized, or if NVML reports an unexpected failure.

Source

pub fn fbc_sessions(self) -> Result<Vec<FbcSessionInfo>>

Returns information about active frame buffer capture sessions on a target device.

This wrapper queries the required session count first, then returns the active FBC sessions as a Vec.

For Maxwell or newer fully supported devices.

h_resolution, v_resolution, average_fps, and average_latency may be zero if no new frames were captured since the session started.

§Errors

Returns an error if the device is inaccessible, if the FBC session list changes while the wrapper is fetching it, if NVML reports an invalid session count, if NVML has not been initialized, or if NVML reports an unexpected failure.

Source

pub fn topology_common_ancestor(self, other: Self) -> Result<TopologyLevel>

Returns the common ancestor for two devices.

For all products. Supported on Linux only.

§Errors

Returns an error if NVML rejects either handle or the output, if topology discovery is not supported on this device or OS, or if NVML fails during topology discovery.

Source

pub fn topology_nearest_gpus(self, level: TopologyLevel) -> Result<Vec<Device>>

Returns the set of GPUs nearest to this device at a specific interconnectivity level. Supported on Linux only.

§Errors

Returns an error if NVML rejects the handle, topology level, count, or output buffer, if topology discovery is not supported on this device or OS, or if NVML fails during topology discovery.

Source

pub fn p2p_status( self, other: Self, capability: P2pCapabilityIndex, ) -> Result<P2pStatus>

Returns the status for a P2P capability between this device and other.

§Errors

Returns an error if NVML rejects either device handle, the capability, or output, or if NVML reports an unexpected failure.

Source

pub fn on_same_board(self, other: Self) -> Result<bool>

Check if the GPU devices are on the same physical board.

For all fully supported products.

§Errors

Returns an error if either device is inaccessible, if NVML rejects either handle or output, if the check is unsupported, if NVML has not been initialized, or if NVML reports an unexpected failure.

Source

pub fn compute_running_processes(self) -> Result<Vec<ProcessInfo>>

Source

pub fn running_process_details( self, mode: ProcessMode, ) -> Result<Vec<ProcessDetail>>

Returns information about running processes on a device for the input context.

For Hopper or newer fully supported devices.

Returns information only about running processes, such as CUDA applications with active contexts.

This wrapper performs the NVML size query internally and returns the matching process details as a Vec.

The used_gpu_memory field is all of the memory used by the application. The used_gpu_cc_protected_memory field is all of the protected memory used by the application.

Keep in mind that information returned by this call is dynamic and the number of elements might change in time. The wrapper retries internally if NVML reports that more space is needed because new processes were spawned.

In MIG mode, a physical device handle reports aggregate information only if the caller has appropriate privileges. Per-instance information can be queried by using specific MIG device handles. Querying per-instance information using MIG device handles is not supported if the device is in vGPU Host virtualization mode. Protected memory usage is currently not available in MIG mode or on Windows.

§Errors

Returns an error if the device is inaccessible, if the process list changes while the wrapper is fetching it, if NVML rejects the device, process mode, or output, if the query is unsupported, if the current process lacks permission, if NVML has not been initialized, or if NVML reports an unexpected failure.

Source

pub fn graphics_running_processes(self) -> Result<Vec<ProcessInfo>>

Source

pub fn mps_compute_running_processes(self) -> Result<Vec<ProcessInfo>>

Source

pub fn process_utilization( self, last_seen_timestamp: u64, ) -> Result<Vec<ProcessUtilizationSample>>

Returns the current utilization and process ID.

For Maxwell or newer fully supported devices.

Reads recent utilization of GPU SM (3D/Compute), framebuffer, video encoder, and video decoder for processes running. This wrapper returns utilization values as a Vec of process samples. One utilization sample structure is returned per running process that had non-zero utilization during the last sample period. It includes the CPU timestamp at which the samples were recorded. Individual utilization values are returned as unsigned integer values. If no valid sample entries are found since last_seen_timestamp, Status::NotFound is returned.

This wrapper performs the NVML size query internally and retries with the required capacity.

On success, NVML reports the number of process utilization sample structures that were actually written. This may differ from a previously read value as instances are created or destroyed.

last_seen_timestamp represents the CPU timestamp in microseconds at which utilization samples were last read. Use 0 to read utilization based on all samples maintained by the driver’s internal sample buffer. Use a timestamp returned by a previous query to read utilization since that query.

On MIG-enabled GPUs, querying process utilization is not currently supported.

§Errors

Returns an error if the device is inaccessible, if NVML rejects the handle, utilization buffer, or sampling timestamp, if the device does not support process utilization sampling, if NVML has not been initialized, or if NVML reports an unexpected failure. Missing sample entries are returned as an empty list.

Source

pub fn processes_utilization( self, last_seen_timestamp: u64, ) -> Result<Vec<ProcessUtilizationInfo>>

Returns the recent utilization and process ID for all running processes.

For Maxwell or newer fully supported devices.

Reads recent utilization of GPU SM (3D/Compute), framebuffer, video encoder, and video decoder, jpeg decoder, OFA (Optical Flow Accelerator) for all running processes. This wrapper returns utilization values as a Vec of process utilization records. One utilization sample structure is returned per running process that had non-zero utilization during the last sample period. It includes the CPU timestamp at which the samples were recorded. Individual utilization values are returned as unsigned integer values.

This wrapper performs the NVML size query internally and retries with the required capacity.

On success, NVML reports the number of process utilization info structures that were actually written. This may differ from a previously read value as instances are created or destroyed.

last_seen_timestamp represents the CPU timestamp in microseconds at which utilization samples were last read. Use 0 to read utilization based on all samples maintained by the driver’s internal sample buffer. Use a timestamp returned by a previous query to read utilization since that query.

On MIG-enabled GPUs, querying process utilization is not currently supported.

§Errors

Returns an error if the installed NVML version does not support the request layout, if the device is inaccessible, if the process list changes while the wrapper is fetching it, if NVML rejects the query, if the device does not support process utilization sampling, if NVML has not been initialized, or if NVML reports an unexpected failure. Missing sample entries are returned as an empty list.

Source

pub fn accounting_mode(self) -> Result<EnableState>

Queries the state of per process accounting mode.

For Kepler or newer fully supported devices.

See Device::accounting_stats for the reported accounting metrics. See sys::nvmlDeviceSetAccountingMode.

§Errors

Returns an error if NVML rejects the handle or output, if the device does not support accounting mode, if NVML has not been initialized, or if NVML reports an unexpected failure.

Source

pub fn accounting_stats(self, pid: Pid) -> Result<AccountingStats>

Queries process’s accounting stats.

For Kepler or newer fully supported devices.

Accounting stats capture GPU utilization and other statistics across the lifetime of a process. Accounting stats can be queried during the lifetime of the process and after its termination. The reported running time remains 0 while the process is still running and is updated to the actual duration after termination. Accounting stats are kept in a circular buffer, newly created processes overwrite information about old processes.

The returned value includes the per-process accounting metrics exposed by NVML. Use Device::accounting_pids to list processes with available stats.

  • Accounting mode must be enabled. See Device::accounting_mode.
  • Only compute and graphics application stats can be queried. Monitoring application stats cannot be queried because they do not contribute to GPU utilization.
  • With a PID collision, only stats for the latest process to terminate are reported.
§Errors

Returns an error if NVML rejects the handle, process ID, or output, if no accounting stats exist for the process, if accounting is unsupported or disabled, if NVML has not been initialized, or if NVML reports an unexpected failure.

Source

pub fn accounting_pids(self) -> Result<Vec<Pid>>

Returns processes that have accounting stats. Returned processes can be running or terminated.

For Kepler or newer fully supported devices.

This wrapper queries the process count internally. It returns an empty list when no accounting processes are available.

See Device::accounting_stats for the per-process metrics.

With a PID collision, some processes may not be accessible before the circular buffer is full.

§Errors

Returns an error if the accounting PID list changes while the wrapper is fetching it, if NVML rejects the handle or count output, if accounting is unsupported or disabled, if NVML has not been initialized, or if NVML reports an unexpected failure.

Source

pub fn accounting_buffer_size(self) -> Result<u32>

Returns the number of processes that the circular buffer with accounting pids can hold.

For Kepler or newer fully supported devices.

This is the maximum number of processes with stored accounting information before information about the oldest processes is overwritten by newer process information.

§Errors

Returns an error if NVML rejects the handle or output, if accounting is unsupported or disabled, if NVML has not been initialized, or if NVML reports an unexpected failure.

Trait Implementations§

Source§

impl Clone for Device

Source§

fn clone(&self) -> Device

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Device

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Hash for Device

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for Device

Source§

fn eq(&self, other: &Device) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Copy for Device

Source§

impl Eq for Device

Source§

impl StructuralPartialEq for Device

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.