Fix GPU monitoring on Windows machines

This commit is contained in:
allegroai 2020-08-08 14:43:25 +03:00
parent e4111c830b
commit ce6831368f

View File

@ -200,6 +200,9 @@ class GPUStatCollection(object):
GPUStatCollection.global_processes[nv_process.pid] = \ GPUStatCollection.global_processes[nv_process.pid] = \
psutil.Process(pid=nv_process.pid) psutil.Process(pid=nv_process.pid)
ps_process = GPUStatCollection.global_processes[nv_process.pid] ps_process = GPUStatCollection.global_processes[nv_process.pid]
process['pid'] = nv_process.pid
# noinspection PyBroadException
try:
process['username'] = ps_process.username() process['username'] = ps_process.username()
# cmdline returns full path; # cmdline returns full path;
# as in `ps -o comm`, get short cmdnames. # as in `ps -o comm`, get short cmdnames.
@ -217,7 +220,9 @@ class GPUStatCollection(object):
process['cpu_memory_usage'] = \ process['cpu_memory_usage'] = \
round((ps_process.memory_percent() / 100.0) * round((ps_process.memory_percent() / 100.0) *
psutil.virtual_memory().total) psutil.virtual_memory().total)
process['pid'] = nv_process.pid except Exception:
# insufficient permissions
pass
return process return process
if not GPUStatCollection._gpu_device_info.get(index): if not GPUStatCollection._gpu_device_info.get(index):