mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-11-06 21:53:02 +03:00
* Add analytics opt-in setting, prompt notice kind, and notice watermarks * Add the analytics report schema * Add the analytics state file * Add the install and hardware analytics collectors * Add the detection analytics collector * Add the cameras analytics collector * Add the features analytics collector * Add the health analytics collector * Build analytics reports from the section collectors * Add the analytics report transport * Send the daily analytics report from the main process * Add the analytics preview API * Generate the analytics schema and check it in CI * Record the image variant in each Dockerfile * Show the analytics preview in telemetry settings * Document anonymous analytics * change wording * fixes * update network requirements docs * adapt analytics to free-form model scenes, split notice counts, and peewee 4 * fixes * change log levels * docstrings * docstrings * honor file-only analytics opt-outs and skip pre-consent notices An opt-out saved through the YAML editor's "Save only" or a hand edit never reached the live config, so reports kept going out under the old install ID until a restart. The reporter now reads telemetry.analytics from the config file when a report is due, validated with TelemetryConfig so yes, on, and 1 still count as consent, and an opt-out there deletes the state file and skips the send. The first report under a new install ID also carried every notice since the counters started, including ones from before the opt-in, so a fresh state file now resets the notice watermarks before the report's snapshot. * take the notice baseline at opt-in instead of the first send The watermark reset ran at the first send attempt, so notices raised between the opt-in and that send, up to 45 minutes after a startup, were absorbed into the reset and never reported. The reporter now writes the new install ID and resets the watermarks as soon as it sees consent without a state file. * report notice counts cumulatively from a database baseline Moving watermarks after each accepted send kept the install ID and the notice baseline out of step: pre-consent notices went out, notices raised before the first send were dropped, and a send that finished after an off/on toggle overwrote the new identity's baseline. health.notices now carries cumulative counts since the install ID was created. Creating an ID copies the lifetime counts into the existing reported_* columns before the state file names it, and nothing is written after a send, so the backend diffs consecutive reports per install ID. * write held notice repeats before the analytics baseline reset Repeats of batched kinds like failed_login wait in memory until the stats emitter flushes them, so a baseline reset taken while some were held left them out, and the next flush counted those pre-opt-in repeats as post-consent. The reset now writes held repeats to the notice history under the same lock before copying the counts. * seed detector inference speed from the first inference The average started at 0 so idle detectors read 0, but that made every detector's speed climb from 0 for its first couple dozen inferences after a start. Detectors now use the same InferenceSpeed helper as enrichments, so the first inference seeds the average and idle detectors still read 0.
157 lines
6.1 KiB
Docker
157 lines
6.1 KiB
Docker
# syntax=docker/dockerfile:1.6
|
|
|
|
# https://askubuntu.com/questions/972516/debian-frontend-environment-variable
|
|
ARG DEBIAN_FRONTEND=noninteractive
|
|
ARG BASE_IMAGE
|
|
ARG TRT_BASE=nvcr.io/nvidia/tensorrt:23.12-py3
|
|
|
|
# Build TensorRT-specific library
|
|
FROM ${TRT_BASE} AS trt-deps
|
|
|
|
ARG TARGETARCH
|
|
ARG COMPUTE_LEVEL
|
|
|
|
RUN apt-get update \
|
|
&& apt-get install -y git build-essential cuda-nvcc-* cuda-nvtx-* libnvinfer-dev libnvinfer-plugin-dev libnvparsers-dev libnvonnxparsers-dev \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
RUN --mount=type=bind,source=docker/tensorrt/detector/tensorrt_libyolo.sh,target=/tensorrt_libyolo.sh \
|
|
/tensorrt_libyolo.sh
|
|
|
|
# COPY required individual CUDA deps
|
|
RUN mkdir -p /usr/local/cuda-deps
|
|
RUN if [ "$TARGETARCH" = "amd64" ]; then \
|
|
cp /usr/local/cuda-12.3/targets/x86_64-linux/lib/libcurand.so.* /usr/local/cuda-deps/ && \
|
|
cp /usr/local/cuda-12.3/targets/x86_64-linux/lib/libnvrtc.so.* /usr/local/cuda-deps/ && \
|
|
cd /usr/local/cuda-deps/ && \
|
|
for lib in libnvrtc.so.*; do \
|
|
if [[ "$lib" =~ libnvrtc.so\.([0-9]+\.[0-9]+\.[0-9]+) ]]; then \
|
|
version="${BASH_REMATCH[1]}"; \
|
|
ln -sf "libnvrtc.so.$version" libnvrtc.so; \
|
|
fi; \
|
|
done && \
|
|
for lib in libcurand.so.*; do \
|
|
if [[ "$lib" =~ libcurand.so\.([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+) ]]; then \
|
|
version="${BASH_REMATCH[1]}"; \
|
|
ln -sf "libcurand.so.$version" libcurand.so; \
|
|
fi; \
|
|
done; \
|
|
fi
|
|
|
|
# Frigate w/ TensorRT Support as separate image
|
|
FROM deps AS tensorrt-base
|
|
|
|
#Disable S6 Global timeout
|
|
ENV S6_CMD_WAIT_FOR_SERVICES_MAXTIME=0
|
|
|
|
# COPY TensorRT Model Generation Deps
|
|
COPY --from=trt-deps /usr/local/lib/libyolo_layer.so /usr/local/lib/libyolo_layer.so
|
|
COPY --from=trt-deps /usr/local/src/tensorrt_demos /usr/local/src/tensorrt_demos
|
|
|
|
# COPY Individual CUDA deps folder
|
|
COPY --from=trt-deps /usr/local/cuda-deps /usr/local/cuda
|
|
|
|
COPY docker/tensorrt/detector/rootfs/ /
|
|
ENV YOLO_MODELS=""
|
|
|
|
HEALTHCHECK --start-period=600s --start-interval=5s --interval=15s --timeout=5s --retries=3 \
|
|
CMD curl --fail --silent --show-error http://127.0.0.1:5000/api/version || exit 1
|
|
|
|
FROM ${BASE_IMAGE} AS build-wheels
|
|
ARG DEBIAN_FRONTEND
|
|
|
|
# Add deadsnakes PPA for python3.11
|
|
RUN apt-get -qq update && \
|
|
apt-get -qq install -y --no-install-recommends \
|
|
software-properties-common \
|
|
&& add-apt-repository ppa:deadsnakes/ppa
|
|
|
|
# Use a separate container to build wheels to prevent build dependencies in final image
|
|
RUN apt-get -qq update \
|
|
&& apt-get -qq install -y --no-install-recommends \
|
|
python3.11 python3.11-dev \
|
|
wget build-essential cmake git \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
# Ensure python3 defaults to python3.11
|
|
RUN update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.11 1
|
|
|
|
RUN wget -q https://bootstrap.pypa.io/get-pip.py -O get-pip.py \
|
|
&& sed -i 's/args.append("setuptools")/args.append("setuptools==77.0.3")/' get-pip.py \
|
|
&& python3 get-pip.py "pip"
|
|
|
|
FROM build-wheels AS trt-wheels
|
|
ARG DEBIAN_FRONTEND
|
|
ARG TARGETARCH
|
|
|
|
# python-tensorrt build deps are 3.4 GB!
|
|
RUN apt-get update \
|
|
&& apt-get install -y ccache cuda-cudart-dev-* cuda-nvcc-* libnvonnxparsers-dev libnvparsers-dev libnvinfer-plugin-dev \
|
|
&& ([ -e /usr/local/cuda ] || ln -s /usr/local/cuda-* /usr/local/cuda) \
|
|
&& rm -rf /var/lib/apt/lists/*;
|
|
|
|
# Determine version of tensorrt already installed in base image, e.g. "Version: 8.4.1-1+cuda11.4"
|
|
RUN NVINFER_VER=$(dpkg -s libnvinfer8 | grep -Po "Version: \K.*") \
|
|
&& echo $NVINFER_VER | grep -Po "^\d+\.\d+\.\d+" > /etc/TENSORRT_VER
|
|
|
|
RUN --mount=type=bind,source=docker/tensorrt/detector/build_python_tensorrt.sh,target=/deps/build_python_tensorrt.sh \
|
|
--mount=type=cache,target=/root/.ccache \
|
|
export PATH="/usr/lib/ccache:$PATH" CCACHE_DIR=/root/.ccache CCACHE_MAXSIZE=2G \
|
|
&& TENSORRT_VER=$(cat /etc/TENSORRT_VER) /deps/build_python_tensorrt.sh
|
|
|
|
COPY docker/tensorrt/requirements-arm64.txt /requirements-tensorrt.txt
|
|
|
|
RUN pip3 wheel --wheel-dir=/trt-wheels -r /requirements-tensorrt.txt
|
|
|
|
# See https://elinux.org/Jetson_Zoo#ONNX_Runtime
|
|
ADD https://nvidia.box.com/shared/static/9yvw05k6u343qfnkhdv2x6xhygze0aq1.whl /trt-wheels/onnxruntime_gpu-1.19.0-cp311-cp311-linux_aarch64.whl
|
|
|
|
FROM build-wheels AS trt-model-wheels
|
|
ARG DEBIAN_FRONTEND
|
|
|
|
RUN apt-get update \
|
|
&& apt-get install -y protobuf-compiler libprotobuf-dev \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
RUN --mount=type=bind,source=docker/tensorrt/requirements-models-arm64.txt,target=/requirements-tensorrt-models.txt \
|
|
pip3 wheel --wheel-dir=/trt-model-wheels --no-deps -r /requirements-tensorrt-models.txt
|
|
|
|
FROM wget AS jetson-ffmpeg
|
|
ARG DEBIAN_FRONTEND
|
|
ENV CCACHE_DIR /root/.ccache
|
|
ENV CCACHE_MAXSIZE 2G
|
|
RUN --mount=type=bind,source=docker/tensorrt/build_jetson_ffmpeg.sh,target=/deps/build_jetson_ffmpeg.sh \
|
|
--mount=type=cache,target=/root/.ccache \
|
|
/deps/build_jetson_ffmpeg.sh
|
|
|
|
# Frigate w/ TensorRT for NVIDIA Jetson platforms
|
|
FROM tensorrt-base AS frigate-tensorrt
|
|
RUN apt-get update \
|
|
&& apt-get install -y python-is-python3 libprotobuf23 \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
COPY --from=jetson-ffmpeg /rootfs /
|
|
ENV DEFAULT_FFMPEG_VERSION="jetson"
|
|
ENV INCLUDED_FFMPEG_VERSIONS="${DEFAULT_FFMPEG_VERSION}:${INCLUDED_FFMPEG_VERSIONS}"
|
|
|
|
# ffmpeg runtime dependencies
|
|
RUN apt-get -qq update \
|
|
&& apt-get -qq install -y --no-install-recommends \
|
|
libx264-163 libx265-199 libegl1 \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
# Fixes "Error loading shared libs"
|
|
RUN mkdir -p /etc/ld.so.conf.d && echo /usr/lib/ffmpeg/jetson/lib/ > /etc/ld.so.conf.d/ffmpeg.conf
|
|
|
|
COPY --from=trt-wheels /etc/TENSORRT_VER /etc/TENSORRT_VER
|
|
RUN --mount=type=bind,from=trt-wheels,source=/trt-wheels,target=/deps/trt-wheels \
|
|
--mount=type=bind,from=trt-model-wheels,source=/trt-model-wheels,target=/deps/trt-model-wheels \
|
|
pip3 uninstall -y onnxruntime \
|
|
&& pip3 install -U /deps/trt-wheels/*.whl \
|
|
&& pip3 install -U /deps/trt-model-wheels/*.whl \
|
|
&& ldconfig
|
|
|
|
WORKDIR /opt/frigate/
|
|
COPY --from=rootfs / /
|
|
ENV FRIGATE_IMAGE_VARIANT=tensorrt-jp6
|
|
|
|
# Fixes "Error importing detector runtime: /usr/lib/aarch64-linux-gnu/libstdc++.so.6: cannot allocate memory in static TLS block"
|
|
ENV LD_PRELOAD /usr/lib/aarch64-linux-gnu/libstdc++.so.6 |