From b60ca39e22a06af72f52c59849d80e7c48da02d5 Mon Sep 17 00:00:00 2001 From: Josh Hawkins <32435876+hawkeye217@users.noreply.github.com> Date: Sat, 7 Mar 2026 06:24:11 -0600 Subject: [PATCH] Add avx check print logs on startup and bail if CPU is x86 and doesn't support avx and avx2 instructions --- frigate/__main__.py | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/frigate/__main__.py b/frigate/__main__.py index f3181e494..af33e1517 100644 --- a/frigate/__main__.py +++ b/frigate/__main__.py @@ -1,6 +1,7 @@ import argparse import faulthandler import multiprocessing as mp +import platform import signal import sys import threading @@ -15,7 +16,44 @@ from frigate.log import setup_logging from frigate.util.config import find_config_file +def check_cpu_flags() -> None: + """Check that the CPU supports required instruction sets on x86_64.""" + if platform.machine() not in ("x86_64", "AMD64"): + return + + try: + with open("/proc/cpuinfo", "r") as f: + cpuinfo = f.read() + except OSError: + return + + flags = set() + for line in cpuinfo.splitlines(): + if line.startswith("flags"): + flags = set(line.split(":")[1].split()) + break + + if "avx" in flags and "avx2" not in flags: + print( + "Your CPU supports AVX but not AVX2. " + "Frigate requires AVX2 when running on x86_64 systems. " + "Detected CPU flags include 'avx' but not 'avx2'." + ) + sys.exit(1) + + if "avx" not in flags: + print( + "Your CPU does not support AVX instructions. " + "Frigate requires AVX when running on x86_64 systems. " + "Detected CPU flags do not include 'avx'." + ) + sys.exit(1) + + def main() -> None: + # Check CPU compatibility before importing any compiled dependencies + check_cpu_flags() + manager = mp.Manager() faulthandler.enable()