mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-07-04 11:01:14 +03:00
Store hwaccel errors with timeout so it can retry
This commit is contained in:
parent
fc5fbad047
commit
26e25c159d
@ -32,7 +32,7 @@ class StatsEmitter(threading.Thread):
|
|||||||
self.config = config
|
self.config = config
|
||||||
self.stats_tracking = stats_tracking
|
self.stats_tracking = stats_tracking
|
||||||
self.stop_event = stop_event
|
self.stop_event = stop_event
|
||||||
self.hwaccel_errors: list[str] = []
|
self.hwaccel_errors: dict[str, float] = {}
|
||||||
self.stats_history: list[dict[str, Any]] = []
|
self.stats_history: list[dict[str, Any]] = []
|
||||||
|
|
||||||
# create communication for stats
|
# create communication for stats
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
"""Utilities for stats."""
|
"""Utilities for stats."""
|
||||||
|
|
||||||
import asyncio
|
import asyncio
|
||||||
|
import logging
|
||||||
import os
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
import time
|
import time
|
||||||
@ -34,6 +35,10 @@ from frigate.util.services import (
|
|||||||
)
|
)
|
||||||
from frigate.version import VERSION
|
from frigate.version import VERSION
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
HWACCEL_ERROR_COOLDOWN_SECONDS = 3600
|
||||||
|
|
||||||
|
|
||||||
def get_latest_version(config: FrigateConfig) -> str:
|
def get_latest_version(config: FrigateConfig) -> str:
|
||||||
if not config.telemetry.version_check:
|
if not config.telemetry.version_check:
|
||||||
@ -167,7 +172,9 @@ def get_detector_stats(
|
|||||||
|
|
||||||
|
|
||||||
def get_processing_stats(
|
def get_processing_stats(
|
||||||
config: FrigateConfig, stats: dict[str, str], hwaccel_errors: list[str]
|
config: FrigateConfig,
|
||||||
|
stats: dict[str, str],
|
||||||
|
hwaccel_errors: dict[str, float],
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Get stats for cpu / gpu."""
|
"""Get stats for cpu / gpu."""
|
||||||
|
|
||||||
@ -206,7 +213,9 @@ async def set_bandwidth_stats(config: FrigateConfig, all_stats: dict[str, Any])
|
|||||||
|
|
||||||
|
|
||||||
async def set_gpu_stats(
|
async def set_gpu_stats(
|
||||||
config: FrigateConfig, all_stats: dict[str, Any], hwaccel_errors: list[str]
|
config: FrigateConfig,
|
||||||
|
all_stats: dict[str, Any],
|
||||||
|
hwaccel_errors: dict[str, float],
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Parse GPUs from hwaccel args and use for stats."""
|
"""Parse GPUs from hwaccel args and use for stats."""
|
||||||
hwaccel_args = []
|
hwaccel_args = []
|
||||||
@ -231,12 +240,16 @@ async def set_gpu_stats(
|
|||||||
|
|
||||||
stats: dict[str, dict] = {}
|
stats: dict[str, dict] = {}
|
||||||
intel_gpu_collected = False
|
intel_gpu_collected = False
|
||||||
|
now = time.monotonic()
|
||||||
|
|
||||||
for args in hwaccel_args:
|
for args in hwaccel_args:
|
||||||
if args in hwaccel_errors:
|
last_error = hwaccel_errors.get(args)
|
||||||
# known erroring args should automatically return as error
|
if last_error is not None:
|
||||||
stats["error-gpu"] = {"gpu": "", "mem": ""}
|
if now - last_error < HWACCEL_ERROR_COOLDOWN_SECONDS:
|
||||||
elif "cuvid" in args or "nvidia" in args:
|
continue
|
||||||
|
hwaccel_errors.pop(args, None)
|
||||||
|
|
||||||
|
if "cuvid" in args or "nvidia" in args:
|
||||||
# nvidia GPU
|
# nvidia GPU
|
||||||
nvidia_usage = get_nvidia_gpu_stats()
|
nvidia_usage = get_nvidia_gpu_stats()
|
||||||
|
|
||||||
@ -253,7 +266,7 @@ async def set_gpu_stats(
|
|||||||
|
|
||||||
else:
|
else:
|
||||||
stats["nvidia-gpu"] = {"vendor": "nvidia", "gpu": "", "mem": ""}
|
stats["nvidia-gpu"] = {"vendor": "nvidia", "gpu": "", "mem": ""}
|
||||||
hwaccel_errors.append(args)
|
hwaccel_errors[args] = time.monotonic()
|
||||||
elif "nvmpi" in args or "jetson" in args:
|
elif "nvmpi" in args or "jetson" in args:
|
||||||
# nvidia Jetson
|
# nvidia Jetson
|
||||||
jetson_usage = get_jetson_stats()
|
jetson_usage = get_jetson_stats()
|
||||||
@ -262,7 +275,7 @@ async def set_gpu_stats(
|
|||||||
stats["jetson-gpu"] = {"vendor": "nvidia", **jetson_usage}
|
stats["jetson-gpu"] = {"vendor": "nvidia", **jetson_usage}
|
||||||
else:
|
else:
|
||||||
stats["jetson-gpu"] = {"vendor": "nvidia", "gpu": "", "mem": ""}
|
stats["jetson-gpu"] = {"vendor": "nvidia", "gpu": "", "mem": ""}
|
||||||
hwaccel_errors.append(args)
|
hwaccel_errors[args] = time.monotonic()
|
||||||
elif "qsv" in args or ("vaapi" in args and not is_vaapi_amd_driver()):
|
elif "qsv" in args or ("vaapi" in args and not is_vaapi_amd_driver()):
|
||||||
if not config.telemetry.stats.intel_gpu_stats:
|
if not config.telemetry.stats.intel_gpu_stats:
|
||||||
continue
|
continue
|
||||||
@ -280,7 +293,7 @@ async def set_gpu_stats(
|
|||||||
stats[name] = entry
|
stats[name] = entry
|
||||||
else:
|
else:
|
||||||
stats["intel-gpu"] = {"vendor": "intel", "gpu": "", "mem": ""}
|
stats["intel-gpu"] = {"vendor": "intel", "gpu": "", "mem": ""}
|
||||||
hwaccel_errors.append(args)
|
hwaccel_errors[args] = time.monotonic()
|
||||||
elif "vaapi" in args:
|
elif "vaapi" in args:
|
||||||
if not config.telemetry.stats.amd_gpu_stats:
|
if not config.telemetry.stats.amd_gpu_stats:
|
||||||
continue
|
continue
|
||||||
@ -292,7 +305,7 @@ async def set_gpu_stats(
|
|||||||
stats["amd-vaapi"] = {"vendor": "amd", **amd_usage}
|
stats["amd-vaapi"] = {"vendor": "amd", **amd_usage}
|
||||||
else:
|
else:
|
||||||
stats["amd-vaapi"] = {"vendor": "amd", "gpu": "", "mem": ""}
|
stats["amd-vaapi"] = {"vendor": "amd", "gpu": "", "mem": ""}
|
||||||
hwaccel_errors.append(args)
|
hwaccel_errors[args] = time.monotonic()
|
||||||
elif "preset-rk" in args:
|
elif "preset-rk" in args:
|
||||||
rga_usage = get_rockchip_gpu_stats()
|
rga_usage = get_rockchip_gpu_stats()
|
||||||
|
|
||||||
@ -328,7 +341,9 @@ async def set_npu_usages(config: FrigateConfig, all_stats: dict[str, Any]) -> No
|
|||||||
|
|
||||||
|
|
||||||
def stats_snapshot(
|
def stats_snapshot(
|
||||||
config: FrigateConfig, stats_tracking: StatsTrackingTypes, hwaccel_errors: list[str]
|
config: FrigateConfig,
|
||||||
|
stats_tracking: StatsTrackingTypes,
|
||||||
|
hwaccel_errors: dict[str, float],
|
||||||
) -> dict[str, Any]:
|
) -> dict[str, Any]:
|
||||||
"""Get a snapshot of the current stats that are being tracked."""
|
"""Get a snapshot of the current stats that are being tracked."""
|
||||||
camera_metrics = stats_tracking["camera_metrics"]
|
camera_metrics = stats_tracking["camera_metrics"]
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user