@@ -5793,12 +5793,47 @@ impl<'nvml> Device<'nvml> {
5793
5793
}
5794
5794
}
5795
5795
5796
+ /**
5797
+ Gets the active vGPU instances for `Device`
5798
+
5799
+ A list as Vec of vGPU handles is returned to be used with nvmlVgpuInstance* calls.
5800
+
5801
+ # Errors
5802
+
5803
+ * `Uninitialized`, if the library has not been successfully initialized
5804
+ * `GpuLost`, if this `Device` has fallen off the bus or is otherwise inaccessible
5805
+ * `Unknown`, on any unexpected error
5806
+ * `NotSupported`, if the platform does not support this feature
5807
+
5808
+ # Platform Support
5809
+
5810
+ Only supports Linux.
5811
+ */
5812
+ // Checked against local
5813
+ // Tested
5814
+ #[ cfg( target_os = "linux" ) ]
5815
+ #[ doc( alias = "nvmlDeviceGetActiveVgpus" ) ]
5816
+ pub fn active_vgpus ( & self ) -> Result < Vec < nvmlVgpuInstance_t > , NvmlError > {
5817
+ let sym = nvml_sym ( self . nvml . lib . nvmlDeviceGetActiveVgpus . as_ref ( ) ) ?;
5818
+
5819
+ unsafe {
5820
+ let mut count: u32 = mem:: zeroed ( ) ;
5821
+
5822
+ nvml_try ( sym ( self . device , std:: ptr:: null_mut ( ) , & mut count) ) ?;
5823
+ let mut arr: Vec < nvmlVgpuInstance_t > = vec ! [ 0 ; count as usize ] ;
5824
+ nvml_try ( sym ( self . device , arr. as_mut_ptr ( ) , & mut count) ) ?;
5825
+
5826
+ Ok ( arr)
5827
+ }
5828
+ }
5829
+
5796
5830
/**
5797
5831
Gets the virtualization mode of `Device`
5798
5832
5799
5833
# Errors
5800
5834
5801
5835
* `Uninitialized`, if the library has not been successfully initialized
5836
+
5802
5837
* `InvalidArg`, if this `Device` is invalid or `clock_type` is invalid (shouldn't occur?)
5803
5838
* `NotSupported`, if this `Device` does not support this feature
5804
5839
* `GpuLost`, if this `Device` has fallen off the bus or is otherwise inaccessible
@@ -5807,6 +5842,7 @@ impl<'nvml> Device<'nvml> {
5807
5842
# Device support
5808
5843
5809
5844
Supports Kepler and newer fully supported devices.
5845
+
5810
5846
*/
5811
5847
// Checked against local
5812
5848
// Tested
@@ -7076,6 +7112,13 @@ mod test {
7076
7112
test_with_device ( 3 , & nvml, |device| device. is_drain_enabled ( None ) )
7077
7113
}
7078
7114
7115
+ #[ cfg( target_os = "linux" ) ]
7116
+ #[ test]
7117
+ fn active_vgpus ( ) {
7118
+ let nvml = nvml ( ) ;
7119
+ test_with_device ( 3 , & nvml, |device| device. active_vgpus ( ) )
7120
+ }
7121
+
7079
7122
#[ cfg( target_os = "linux" ) ]
7080
7123
#[ test]
7081
7124
fn virtualization_mode ( ) {
0 commit comments