mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-01-22 20:18:30 +03:00
Add support for Nvidia temperature
This commit is contained in:
parent
08f95e8274
commit
b436ef0649
@ -246,6 +246,7 @@ async def set_gpu_stats(
|
|||||||
"mem": str(round(float(nvidia_usage[i]["mem"]), 2)) + "%",
|
"mem": str(round(float(nvidia_usage[i]["mem"]), 2)) + "%",
|
||||||
"enc": str(round(float(nvidia_usage[i]["enc"]), 2)) + "%",
|
"enc": str(round(float(nvidia_usage[i]["enc"]), 2)) + "%",
|
||||||
"dec": str(round(float(nvidia_usage[i]["dec"]), 2)) + "%",
|
"dec": str(round(float(nvidia_usage[i]["dec"]), 2)) + "%",
|
||||||
|
"temp": str(nvidia_usage[i]["temp"]),
|
||||||
}
|
}
|
||||||
|
|
||||||
else:
|
else:
|
||||||
|
|||||||
@ -484,10 +484,13 @@ def get_rockchip_npu_stats() -> Optional[dict[str, float | str]]:
|
|||||||
return stats
|
return stats
|
||||||
|
|
||||||
|
|
||||||
def try_get_info(f, h, default="N/A"):
|
def try_get_info(f, h, default="N/A", sensor=None):
|
||||||
try:
|
try:
|
||||||
if h:
|
if h:
|
||||||
v = f(h)
|
if sensor is not None:
|
||||||
|
v = f(h, sensor)
|
||||||
|
else:
|
||||||
|
v = f(h)
|
||||||
else:
|
else:
|
||||||
v = f()
|
v = f()
|
||||||
except nvml.NVMLError_NotSupported:
|
except nvml.NVMLError_NotSupported:
|
||||||
@ -516,6 +519,9 @@ def get_nvidia_gpu_stats() -> dict[int, dict]:
|
|||||||
util = try_get_info(nvml.nvmlDeviceGetUtilizationRates, handle)
|
util = try_get_info(nvml.nvmlDeviceGetUtilizationRates, handle)
|
||||||
enc = try_get_info(nvml.nvmlDeviceGetEncoderUtilization, handle)
|
enc = try_get_info(nvml.nvmlDeviceGetEncoderUtilization, handle)
|
||||||
dec = try_get_info(nvml.nvmlDeviceGetDecoderUtilization, handle)
|
dec = try_get_info(nvml.nvmlDeviceGetDecoderUtilization, handle)
|
||||||
|
temp = try_get_info(
|
||||||
|
nvml.nvmlDeviceGetTemperature, handle, default=None, sensor=0
|
||||||
|
)
|
||||||
pstate = try_get_info(nvml.nvmlDeviceGetPowerState, handle, default=None)
|
pstate = try_get_info(nvml.nvmlDeviceGetPowerState, handle, default=None)
|
||||||
|
|
||||||
if util != "N/A":
|
if util != "N/A":
|
||||||
@ -528,6 +534,11 @@ def get_nvidia_gpu_stats() -> dict[int, dict]:
|
|||||||
else:
|
else:
|
||||||
gpu_mem_util = -1
|
gpu_mem_util = -1
|
||||||
|
|
||||||
|
if temp != "N/A" and temp is not None:
|
||||||
|
temp = float(temp)
|
||||||
|
else:
|
||||||
|
temp = None
|
||||||
|
|
||||||
if enc != "N/A":
|
if enc != "N/A":
|
||||||
enc_util = enc[0]
|
enc_util = enc[0]
|
||||||
else:
|
else:
|
||||||
@ -545,6 +556,7 @@ def get_nvidia_gpu_stats() -> dict[int, dict]:
|
|||||||
"enc": enc_util,
|
"enc": enc_util,
|
||||||
"dec": dec_util,
|
"dec": dec_util,
|
||||||
"pstate": pstate or "unknown",
|
"pstate": pstate or "unknown",
|
||||||
|
"temp": temp,
|
||||||
}
|
}
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|||||||
@ -737,8 +737,9 @@ export default function GeneralMetrics({
|
|||||||
<div
|
<div
|
||||||
className={cn(
|
className={cn(
|
||||||
"mt-4 grid grid-cols-1 gap-2 sm:grid-cols-2",
|
"mt-4 grid grid-cols-1 gap-2 sm:grid-cols-2",
|
||||||
gpuEncSeries?.length && "md:grid-cols-4",
|
|
||||||
gpuTempSeries?.length && "md:grid-cols-3",
|
gpuTempSeries?.length && "md:grid-cols-3",
|
||||||
|
gpuEncSeries?.length &&
|
||||||
|
(gpuTempSeries?.length ? "md:grid-cols-5" : "md:grid-cols-4"),
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
{statsHistory[0]?.gpu_usages && (
|
{statsHistory[0]?.gpu_usages && (
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user