From 759f61da0ce74c1930c503d3636874c92a2cb6d0 Mon Sep 17 00:00:00 2001 From: JYX Date: Thu, 13 Oct 2022 10:54:20 +0800 Subject: [PATCH] Fix running_compute_processes count handling Consistent with running_graphics_processes --- nvml-wrapper/src/device.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/nvml-wrapper/src/device.rs b/nvml-wrapper/src/device.rs index 71c4e25..9fe9958 100644 --- a/nvml-wrapper/src/device.rs +++ b/nvml-wrapper/src/device.rs @@ -565,7 +565,7 @@ impl<'nvml> Device<'nvml> { unsafe { let mut count: c_uint = match self.running_compute_processes_count()? { 0 => return Ok(vec![]), - value => value + 5, + value => value, }; // Add a bit of headroom in case more processes are launched in // between the above call to get the expected count and the time we @@ -575,6 +575,7 @@ impl<'nvml> Device<'nvml> { nvml_try(sym(self.device, &mut count, processes.as_mut_ptr()))?; + processes.truncate(count as usize); Ok(processes.into_iter().map(ProcessInfo::from).collect()) } }