mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-05 02:35:22 +03:00
black...black...black...
This commit is contained in:
parent
a338f74ecd
commit
4eb7b31759
@ -916,7 +916,7 @@ def get_intel_gpu_stats() -> dict[str, str]:
|
|||||||
return results
|
return results
|
||||||
|
|
||||||
|
|
||||||
def try_get_info(f, h, default='N/A'):
|
def try_get_info(f, h, default="N/A"):
|
||||||
try:
|
try:
|
||||||
v = f(h)
|
v = f(h)
|
||||||
except nvml.NVMLError_NotSupported:
|
except nvml.NVMLError_NotSupported:
|
||||||
@ -924,7 +924,6 @@ def try_get_info(f, h, default='N/A'):
|
|||||||
return v
|
return v
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def get_nvidia_gpu_stats() -> dict[str, str]:
|
def get_nvidia_gpu_stats() -> dict[str, str]:
|
||||||
nvml.nvmlInit()
|
nvml.nvmlInit()
|
||||||
deviceCount = nvml.nvmlDeviceGetCount()
|
deviceCount = nvml.nvmlDeviceGetCount()
|
||||||
@ -933,20 +932,19 @@ def get_nvidia_gpu_stats() -> dict[str, str]:
|
|||||||
handle = nvml.nvmlDeviceGetHandleByIndex(i)
|
handle = nvml.nvmlDeviceGetHandleByIndex(i)
|
||||||
meminfo = nvml.nvmlDeviceGetMemoryInfo(handle)
|
meminfo = nvml.nvmlDeviceGetMemoryInfo(handle)
|
||||||
util = try_get_info(nvml.nvmlDeviceGetUtilizationRates, handle)
|
util = try_get_info(nvml.nvmlDeviceGetUtilizationRates, handle)
|
||||||
if util != 'N/A':
|
if util != "N/A":
|
||||||
gpu_util = util.gpu
|
gpu_util = util.gpu
|
||||||
else:
|
else:
|
||||||
gpu_util = 0
|
gpu_util = 0
|
||||||
results[i] = {
|
results[i] = {
|
||||||
"name": nvml.nvmlDeviceGetName(handle),
|
"name": nvml.nvmlDeviceGetName(handle),
|
||||||
"gpu": gpu_util,
|
"gpu": gpu_util,
|
||||||
"mem": meminfo.used / meminfo.total * 100
|
"mem": meminfo.used / meminfo.total * 100,
|
||||||
}
|
}
|
||||||
|
|
||||||
return results
|
return results
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def ffprobe_stream(path: str) -> sp.CompletedProcess:
|
def ffprobe_stream(path: str) -> sp.CompletedProcess:
|
||||||
"""Run ffprobe on stream."""
|
"""Run ffprobe on stream."""
|
||||||
clean_path = escape_special_characters(path)
|
clean_path = escape_special_characters(path)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user