mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-09 04:35:25 +03:00
Add autodetection logic
This commit is contained in:
parent
617c728a88
commit
f9b17d3f00
@ -14,7 +14,7 @@ from requests.exceptions import RequestException
|
|||||||
|
|
||||||
from frigate.comms.dispatcher import Dispatcher
|
from frigate.comms.dispatcher import Dispatcher
|
||||||
from frigate.config import FrigateConfig
|
from frigate.config import FrigateConfig
|
||||||
from frigate.const import CACHE_DIR, CLIPS_DIR, DRIVER_AMD, DRIVER_ENV_VAR, RECORD_DIR
|
from frigate.const import CACHE_DIR, CLIPS_DIR, RECORD_DIR
|
||||||
from frigate.object_detection import ObjectDetectProcess
|
from frigate.object_detection import ObjectDetectProcess
|
||||||
from frigate.types import CameraMetricsTypes, StatsTrackingTypes
|
from frigate.types import CameraMetricsTypes, StatsTrackingTypes
|
||||||
from frigate.util.services import (
|
from frigate.util.services import (
|
||||||
@ -24,6 +24,7 @@ from frigate.util.services import (
|
|||||||
get_intel_gpu_stats,
|
get_intel_gpu_stats,
|
||||||
get_jetson_stats,
|
get_jetson_stats,
|
||||||
get_nvidia_gpu_stats,
|
get_nvidia_gpu_stats,
|
||||||
|
is_vaapi_amd_driver,
|
||||||
)
|
)
|
||||||
from frigate.version import VERSION
|
from frigate.version import VERSION
|
||||||
|
|
||||||
@ -205,9 +206,7 @@ async def set_gpu_stats(
|
|||||||
stats["intel-qsv"] = {"gpu": -1, "mem": -1}
|
stats["intel-qsv"] = {"gpu": -1, "mem": -1}
|
||||||
hwaccel_errors.append(args)
|
hwaccel_errors.append(args)
|
||||||
elif "vaapi" in args:
|
elif "vaapi" in args:
|
||||||
driver = os.environ.get(DRIVER_ENV_VAR)
|
if is_vaapi_amd_driver():
|
||||||
|
|
||||||
if driver == DRIVER_AMD:
|
|
||||||
if not config.telemetry.stats.amd_gpu_stats:
|
if not config.telemetry.stats.amd_gpu_stats:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
|||||||
@ -15,7 +15,7 @@ import psutil
|
|||||||
import py3nvml.py3nvml as nvml
|
import py3nvml.py3nvml as nvml
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
from frigate.const import FFMPEG_HWACCEL_NVIDIA, FFMPEG_HWACCEL_VAAPI
|
from frigate.const import DRIVER_AMD, DRIVER_ENV_VAR, FFMPEG_HWACCEL_NVIDIA, FFMPEG_HWACCEL_VAAPI
|
||||||
from frigate.util.builtin import clean_camera_user_pass, escape_special_characters
|
from frigate.util.builtin import clean_camera_user_pass, escape_special_characters
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
@ -195,6 +195,20 @@ def get_bandwidth_stats(config) -> dict[str, dict]:
|
|||||||
|
|
||||||
return usages
|
return usages
|
||||||
|
|
||||||
|
def is_vaapi_amd_driver() -> bool:
|
||||||
|
driver = os.environ.get(DRIVER_ENV_VAR)
|
||||||
|
if driver:
|
||||||
|
return driver == DRIVER_AMD
|
||||||
|
|
||||||
|
p = vainfo_hwaccel()
|
||||||
|
|
||||||
|
if p.returncode != 0:
|
||||||
|
logger.error(f"Unable to poll vainfo: {p.stderr}")
|
||||||
|
return False
|
||||||
|
else:
|
||||||
|
output = p.stdout.decode('unicode_escape').split("\n")
|
||||||
|
# VA Info will print out the friendly name of the driver
|
||||||
|
return any("AMD Radeon Graphics" in line for line in output)
|
||||||
|
|
||||||
def get_amd_gpu_stats() -> dict[str, str]:
|
def get_amd_gpu_stats() -> dict[str, str]:
|
||||||
"""Get stats using radeontop."""
|
"""Get stats using radeontop."""
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user