diff --git a/nvitop/api/device.py b/nvitop/api/device.py index def080c..5d3b92a 100644 --- a/nvitop/api/device.py +++ b/nvitop/api/device.py @@ -1700,7 +1700,10 @@ class Device: # pylint: disable=too-many-instance-attributes,too-many-public-me samples = libnvml.nvmlQuery( 'nvmlDeviceGetProcessUtilization', self.handle, - time.time_ns() // 1000, + # Only utilization samples that were recorded after this timestamp will be returned. + # The CPU timestamp, i.e. absolute Unix epoch timestamp (in microseconds), is used. + # Here we use the timestamp 1/4 second ago to ensure the record buffer is not empty. + time.time_ns() // 1000 - 250_000, default=(), ) for s in sorted(samples, key=lambda s: s.timeStamp):