mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-05-04 04:27:42 +03:00
Wrap gpu stats functions in Optional[]
These can return `None`, so they need to be `Type | None`, which is what `Optional` expresses very nicely.
This commit is contained in:
parent
64b3d77073
commit
20791c6b0f
@ -230,7 +230,7 @@ def is_vaapi_amd_driver() -> bool:
|
|||||||
return any("AMD Radeon Graphics" in line for line in output)
|
return any("AMD Radeon Graphics" in line for line in output)
|
||||||
|
|
||||||
|
|
||||||
def get_amd_gpu_stats() -> dict[str, str]:
|
def get_amd_gpu_stats() -> Optional[dict[str, str]]:
|
||||||
"""Get stats using radeontop."""
|
"""Get stats using radeontop."""
|
||||||
radeontop_command = ["radeontop", "-d", "-", "-l", "1"]
|
radeontop_command = ["radeontop", "-d", "-", "-l", "1"]
|
||||||
|
|
||||||
@ -256,7 +256,7 @@ def get_amd_gpu_stats() -> dict[str, str]:
|
|||||||
return results
|
return results
|
||||||
|
|
||||||
|
|
||||||
def get_intel_gpu_stats(sriov: bool) -> dict[str, str]:
|
def get_intel_gpu_stats(sriov: bool) -> Optional[dict[str, str]]:
|
||||||
"""Get stats using intel_gpu_top."""
|
"""Get stats using intel_gpu_top."""
|
||||||
|
|
||||||
def get_stats_manually(output: str) -> dict[str, str]:
|
def get_stats_manually(output: str) -> dict[str, str]:
|
||||||
@ -382,7 +382,7 @@ def get_intel_gpu_stats(sriov: bool) -> dict[str, str]:
|
|||||||
return results
|
return results
|
||||||
|
|
||||||
|
|
||||||
def get_rockchip_gpu_stats() -> dict[str, str]:
|
def get_rockchip_gpu_stats() -> Optional[dict[str, str]]:
|
||||||
"""Get GPU stats using rk."""
|
"""Get GPU stats using rk."""
|
||||||
try:
|
try:
|
||||||
with open("/sys/kernel/debug/rkrga/load", "r") as f:
|
with open("/sys/kernel/debug/rkrga/load", "r") as f:
|
||||||
@ -403,7 +403,7 @@ def get_rockchip_gpu_stats() -> dict[str, str]:
|
|||||||
return {"gpu": average_load, "mem": "-"}
|
return {"gpu": average_load, "mem": "-"}
|
||||||
|
|
||||||
|
|
||||||
def get_rockchip_npu_stats() -> dict[str, str]:
|
def get_rockchip_npu_stats() -> Optional[dict[str, float | str]]:
|
||||||
"""Get NPU stats using rk."""
|
"""Get NPU stats using rk."""
|
||||||
try:
|
try:
|
||||||
with open("/sys/kernel/debug/rknpu/load", "r") as f:
|
with open("/sys/kernel/debug/rknpu/load", "r") as f:
|
||||||
@ -494,7 +494,7 @@ def get_nvidia_gpu_stats() -> dict[int, dict]:
|
|||||||
return results
|
return results
|
||||||
|
|
||||||
|
|
||||||
def get_jetson_stats() -> dict[int, dict]:
|
def get_jetson_stats() -> Optional[dict[int, dict]]:
|
||||||
results = {}
|
results = {}
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user