From 96c05330aee29d8a189ff4694f45238f96ee9736 Mon Sep 17 00:00:00 2001 From: Martin Weinelt Date: Mon, 23 Feb 2026 01:05:04 +0100 Subject: [PATCH 1/2] frigate: disable failing onnxruntime optimization Recent onnxruntime versions have a failing optimization with FP16 embedding models used in Frigate. --- .../fr/frigate/onnxruntime-compat.patch | 19 +++++++++++++++++++ pkgs/by-name/fr/frigate/package.nix | 3 +++ 2 files changed, 22 insertions(+) create mode 100644 pkgs/by-name/fr/frigate/onnxruntime-compat.patch diff --git a/pkgs/by-name/fr/frigate/onnxruntime-compat.patch b/pkgs/by-name/fr/frigate/onnxruntime-compat.patch new file mode 100644 index 000000000000..145c6e6722dc --- /dev/null +++ b/pkgs/by-name/fr/frigate/onnxruntime-compat.patch @@ -0,0 +1,19 @@ +Disable the SimplifedLayerNormFusion optimization for onnxruntime embedding +models to prevent a crash when using FP16 models (like jinna-clip-v1) with newer +onnxruntime versions. + +https://github.com/microsoft/onnxruntime/issues/26717#issuecomment-3800462654 + + +diff --git a/frigate/embeddings/onnx/runner.py b/frigate/embeddings/onnx/runner.py +index c34c97a8d..dca91daae 100644 +--- a/frigate/embeddings/onnx/runner.py ++++ b/frigate/embeddings/onnx/runner.py +@@ -52,6 +52,7 @@ class ONNXModelRunner: + model_path, + providers=providers, + provider_options=options, ++ disabled_optimizers=["SimplifiedLayerNormFusion"], + ) + + def get_input_names(self) -> list[str]: diff --git a/pkgs/by-name/fr/frigate/package.nix b/pkgs/by-name/fr/frigate/package.nix index 7036ecdde0b2..c159bef2ad1f 100644 --- a/pkgs/by-name/fr/frigate/package.nix +++ b/pkgs/by-name/fr/frigate/package.nix @@ -84,6 +84,7 @@ python3Packages.buildPythonApplication rec { hash = "sha256-1+n0n0yCtjfAHkXzsZdIF0iCVdPGmsG7l8/VTqBVEjU="; }) ./ffmpeg.patch + # https://github.com/blakeblackshear/frigate/pull/21876 ./ai-edge-litert.patch (fetchpatch { # peewee-migrate 0.14.x compat @@ -95,6 +96,8 @@ python3Packages.buildPythonApplication rec { ]; hash = "sha256-RrmwjE4SHJIUOYfqcCtMy9Pht7UXhHcoAZlFQv9aQFw="; }) + # https://github.com/microsoft/onnxruntime/issues/26717 + ./onnxruntime-compat.patch ]; postPatch = '' From be8a4752d3d14f8881d9fdd8a713ab535b5e1313 Mon Sep 17 00:00:00 2001 From: Martin Weinelt Date: Mon, 23 Feb 2026 01:06:06 +0100 Subject: [PATCH 2/2] frigate: clean up process cmdlines in cpu stats The process cmdline gets read from /proc/pid/cmdline which is a memory allocation with a rounded up size. The psutil library looks for a Null-terminated string, but apparently not all cmdlines have that. --- pkgs/by-name/fr/frigate/package.nix | 2 ++ .../fr/frigate/proc-cmdline-strip.patch | 27 +++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 pkgs/by-name/fr/frigate/proc-cmdline-strip.patch diff --git a/pkgs/by-name/fr/frigate/package.nix b/pkgs/by-name/fr/frigate/package.nix index c159bef2ad1f..ca26f3f83c8b 100644 --- a/pkgs/by-name/fr/frigate/package.nix +++ b/pkgs/by-name/fr/frigate/package.nix @@ -98,6 +98,8 @@ python3Packages.buildPythonApplication rec { }) # https://github.com/microsoft/onnxruntime/issues/26717 ./onnxruntime-compat.patch + # https://github.com/blakeblackshear/frigate/pull/22089 + ./proc-cmdline-strip.patch ]; postPatch = '' diff --git a/pkgs/by-name/fr/frigate/proc-cmdline-strip.patch b/pkgs/by-name/fr/frigate/proc-cmdline-strip.patch new file mode 100644 index 000000000000..426dd20ae266 --- /dev/null +++ b/pkgs/by-name/fr/frigate/proc-cmdline-strip.patch @@ -0,0 +1,27 @@ +Strip trailing whitespace from process commandlines. This is annoying for exact +process matches against Prometheus labels. + +https://github.com/blakeblackshear/frigate/pull/22089 + +diff --git a/frigate/util/services.py b/frigate/util/services.py +index b31a7eea3..f1e8f0f5f 100644 +--- a/frigate/util/services.py ++++ b/frigate/util/services.py +@@ -118,7 +118,7 @@ def get_cpu_stats() -> dict[str, dict]: + pid = str(process.info["pid"]) + try: + cpu_percent = process.info["cpu_percent"] +- cmdline = process.info["cmdline"] ++ cmdline = " ".join(process.info["cmdline"]).rstrip() + + with open(f"/proc/{pid}/stat", "r") as f: + stats = f.readline().split() +@@ -152,7 +152,7 @@ def get_cpu_stats() -> dict[str, dict]: + "cpu": str(cpu_percent), + "cpu_average": str(round(cpu_average_usage, 2)), + "mem": f"{mem_pct}", +- "cmdline": clean_camera_user_pass(" ".join(cmdline)), ++ "cmdline": clean_camera_user_pass(cmdline), + } + except Exception: + continue