mirror of
https://github.com/XuehaiPan/nvitop.git
synced 2026-05-21 06:45:24 -06:00
fix(api/device): use current epoch timestamp for process utilization
This commit is contained in:
parent
e776dae3a3
commit
e41e0ea701
1 changed files with 2 additions and 4 deletions
|
|
@ -113,6 +113,7 @@ import subprocess
|
|||
import sys
|
||||
import textwrap
|
||||
import threading
|
||||
import time
|
||||
from collections import OrderedDict
|
||||
from typing import (
|
||||
TYPE_CHECKING,
|
||||
|
|
@ -683,7 +684,6 @@ class Device: # pylint: disable=too-many-instance-attributes,too-many-public-me
|
|||
self._nvml_index = libnvml.nvmlQuery('nvmlDeviceGetIndex', self._handle)
|
||||
|
||||
self._max_clock_infos: ClockInfos = ClockInfos(graphics=NA, sm=NA, memory=NA, video=NA)
|
||||
self._timestamp: int = 0
|
||||
self._lock: threading.RLock = threading.RLock()
|
||||
|
||||
self._ident: tuple[Hashable, str] = (self.index, self.uuid())
|
||||
|
|
@ -1700,10 +1700,9 @@ class Device: # pylint: disable=too-many-instance-attributes,too-many-public-me
|
|||
samples = libnvml.nvmlQuery(
|
||||
'nvmlDeviceGetProcessUtilization',
|
||||
self.handle,
|
||||
self._timestamp,
|
||||
time.time_ns() // 1000,
|
||||
default=(),
|
||||
)
|
||||
self._timestamp = min((s.timeStamp for s in samples), default=self._timestamp)
|
||||
for s in sorted(samples, key=lambda s: s.timeStamp):
|
||||
try:
|
||||
processes[s.pid].set_gpu_utilization(s.smUtil, s.memUtil, s.encUtil, s.decUtil)
|
||||
|
|
@ -2019,7 +2018,6 @@ class MigDevice(Device): # pylint: disable=too-many-instance-attributes
|
|||
raise libnvml.NVMLError_NotFound
|
||||
|
||||
self._max_clock_infos = ClockInfos(graphics=NA, sm=NA, memory=NA, video=NA)
|
||||
self._timestamp = 0
|
||||
self._lock = threading.RLock()
|
||||
|
||||
self._ident = (self.index, self.uuid())
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue