Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions nvml-wrapper/src/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2378,6 +2378,32 @@
}
}

/**
Checks if the `Device`supports multi partitioned GPU feature and if enabled.
Not to confuse with `is_multi_gpu_board`, MIG is a single GPU
being able to be split into isolated instances, a sort of "NUMA" for GPU.
If the `Device` supports MIG, we can have its current mode (enabled/disabled)
and, if set, its pending mode for the next system reboot.
# Errors

* `Uninitialized`, if the library has not been successfully initialized
* `InvalidArg`, if this `Device` is invalid
* `NotSupported`, if this `Device` does not support this feature
* `GpuLost`, if this `Device` has fallen off the bus or is otherwise inaccessible
* `Unknown`, on any unexpected error
*/
#[doc(alias = "nvmlDeviceGetMigMode")]
pub fn mig_mode(&self) -> Result<MigMode, NvmlError> {
let sym = nvml_sym(self.nvml.lib.nvmlDeviceGetMigMode.as_ref())?;

unsafe {
let mut mode: MigMode = mem::zeroed();
nvml_try(sym(self.device, &mut mode.current, &mut mode.pending))?;

Ok(mode)
}
}

/**
The name of this `Device`, e.g. "Tesla C2070".

Expand Down Expand Up @@ -3242,7 +3268,7 @@

* `Uninitialized`, if the library has not been successfully initialized
* `IncorrectBits`, if NVML returns any bits that do not correspond to flags in
`ThrottleReasons`

Check warning on line 3271 in nvml-wrapper/src/device.rs

View workflow job for this annotation

GitHub Actions / Clippy

doc list item without indentation
* `GpuLost`, if this `Device` has fallen off the bus or is otherwise inaccessible
* `Unknown`, on any unexpected error

Expand Down Expand Up @@ -4289,7 +4315,7 @@
* `Uninitialized`, if the library has not been successfully initialized
* `InvalidArg`, if the `Device` is invalid
* `NotSupported`, if this `Device` does not support this feature or accounting mode
is disabled

Check warning on line 4318 in nvml-wrapper/src/device.rs

View workflow job for this annotation

GitHub Actions / Clippy

doc list item without indentation
* `Unknown`, on any unexpected error

# Device Support
Expand Down Expand Up @@ -4351,7 +4377,7 @@
* `Uninitialized`, if the library has not been successfully initialized
* `InvalidArg`, if the `Device` is invalid
* `NotSupported`, if this `Device` does not support this feature or accounting
mode is disabled

Check warning on line 4380 in nvml-wrapper/src/device.rs

View workflow job for this annotation

GitHub Actions / Clippy

doc list item without indentation
* `Unknown`, on any unexpected error
*/
// Checked against local
Expand Down Expand Up @@ -4408,9 +4434,9 @@
Note:
* Accounting mode needs to be on. See `.is_accounting_enabled()`.
* Only compute and graphics applications stats can be queried. Monitoring
applications can't be queried since they don't contribute to GPU utilization.

Check warning on line 4437 in nvml-wrapper/src/device.rs

View workflow job for this annotation

GitHub Actions / Clippy

doc list item without indentation
* If a PID collision occurs, the stats of the latest process (the one that
terminated last) will be reported.

Check warning on line 4439 in nvml-wrapper/src/device.rs

View workflow job for this annotation

GitHub Actions / Clippy

doc list item without indentation

# Errors

Expand All @@ -4418,7 +4444,7 @@
* `InvalidArg`, if the `Device` is invalid
* `NotFound`, if the process stats were not found
* `NotSupported`, if this `Device` does not support this feature or accounting
mode is disabled

Check warning on line 4447 in nvml-wrapper/src/device.rs

View workflow job for this annotation

GitHub Actions / Clippy

doc list item without indentation
* `Unknown`, on any unexpected error

# Device Support
Expand Down Expand Up @@ -4452,8 +4478,8 @@

Note:
* This setting is not persistent and will default to disabled after the driver
unloads. Enable persistence mode to be sure the setting doesn't switch off

Check warning on line 4481 in nvml-wrapper/src/device.rs

View workflow job for this annotation

GitHub Actions / Clippy

doc list item without indentation
to disabled.

Check warning on line 4482 in nvml-wrapper/src/device.rs

View workflow job for this annotation

GitHub Actions / Clippy

doc list item without indentation
* Enabling accounting mode has no negative impact on GPU performance.
* Disabling accounting clears accounting information for all PIDs

Expand Down Expand Up @@ -4526,8 +4552,8 @@
* `Uninitialized`, if the library has not been successfully initialized
* `InvalidArg`, if the `Device` is invalid or `api_type` is invalid (shouldn't occur?)
* `NotSupported`, if this `Device` does not support changing API restrictions or
this `Device` does not support the feature that API restrictions are being set for

Check warning on line 4555 in nvml-wrapper/src/device.rs

View workflow job for this annotation

GitHub Actions / Clippy

doc list item without indentation
(e.g. enabling/disabling auto boosted clocks is not supported by this `Device`).

Check warning on line 4556 in nvml-wrapper/src/device.rs

View workflow job for this annotation

GitHub Actions / Clippy

doc list item without indentation
* `NoPermission`, if the user doesn't have permission to perform this operation
* `GpuLost`, if this `Device` has fallen off the bus or is otherwise inaccessible
* `Unknown`, on any unexpected error
Expand Down Expand Up @@ -5882,6 +5908,12 @@
test_with_device(3, &nvml, |device| device.is_multi_gpu_board())
}

#[test]
fn mig_mode() {
let nvml = nvml();
test_with_device(3, &nvml, |device| device.mig_mode())
}

#[test]
fn name() {
let nvml = nvml();
Expand Down
10 changes: 10 additions & 0 deletions nvml-wrapper/src/structs/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,3 +135,13 @@ pub struct RetiredPage {
#[derive(Debug, Clone, Eq, PartialEq, Hash)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct FieldId(pub u32);

/// Returned from `Device.mig_mode()`
#[derive(Debug, Clone, Eq, PartialEq, Hash)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct MigMode {
/// Whether MIG mode is enabled/disabled.
pub current: u32,
/// Mode set after reboot.
pub pending: u32,
}
1 change: 1 addition & 0 deletions nvml-wrapper/src/test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ impl ShouldPrint for PowerSource {}
impl ShouldPrint for DeviceArchitecture {}
impl ShouldPrint for PcieLinkMaxSpeed {}
impl ShouldPrint for DeviceAttributes {}
impl ShouldPrint for MigMode {}

#[cfg(target_os = "windows")]
impl ShouldPrint for DriverModelState {}
Expand Down
2 changes: 0 additions & 2 deletions nvml-wrapper/unwrapped_functions.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,9 @@ nvmlDeviceGetCapabilities
nvmlDeviceGetClkMonStatus
nvmlDeviceGetClockOffsets
nvmlDeviceGetComputeInstanceId
nvmlDeviceGetConfComputeGpuCertificate
nvmlDeviceGetConfComputeMemSizeInfo
nvmlDeviceGetConfComputeProtectedMemoryUsage
nvmlDeviceGetCoolerInfo
nvmlDeviceGetCpuAffinityWithinScope
nvmlDeviceGetCreatableVgpus
nvmlDeviceGetCurrentClockFreqs
nvmlDeviceGetCurrentClocksEventReasons
Expand Down
Loading