black...black...black...

This commit is contained in:
Sergey Krashevich 2023-05-03 10:25:34 +03:00
parent a338f74ecd
commit 4eb7b31759
No known key found for this signature in database
GPG Key ID: 625171324E7D3856
2 changed files with 5 additions and 7 deletions

View File

@ -153,8 +153,8 @@ async def set_gpu_stats(
if nvidia_usage:
for i in nvidia_usage:
stats[nvidia_usage[i]["name"]] = {
"gpu": round(nvidia_usage[i]["gpu"],2),
"mem": round(nvidia_usage[i]["mem"],2),
"gpu": round(nvidia_usage[i]["gpu"], 2),
"mem": round(nvidia_usage[i]["mem"], 2),
}
else:
stats["nvidia-gpu"] = {"gpu": -1, "mem": -1}

View File

@ -916,7 +916,7 @@ def get_intel_gpu_stats() -> dict[str, str]:
return results
def try_get_info(f, h, default='N/A'):
def try_get_info(f, h, default="N/A"):
try:
v = f(h)
except nvml.NVMLError_NotSupported:
@ -924,7 +924,6 @@ def try_get_info(f, h, default='N/A'):
return v
def get_nvidia_gpu_stats() -> dict[str, str]:
nvml.nvmlInit()
deviceCount = nvml.nvmlDeviceGetCount()
@ -933,20 +932,19 @@ def get_nvidia_gpu_stats() -> dict[str, str]:
handle = nvml.nvmlDeviceGetHandleByIndex(i)
meminfo = nvml.nvmlDeviceGetMemoryInfo(handle)
util = try_get_info(nvml.nvmlDeviceGetUtilizationRates, handle)
if util != 'N/A':
if util != "N/A":
gpu_util = util.gpu
else:
gpu_util = 0
results[i] = {
"name": nvml.nvmlDeviceGetName(handle),
"gpu": gpu_util,
"mem": meminfo.used / meminfo.total * 100
"mem": meminfo.used / meminfo.total * 100,
}
return results
def ffprobe_stream(path: str) -> sp.CompletedProcess:
"""Run ffprobe on stream."""
clean_path = escape_special_characters(path)