Use ffmpeg from deb-multimedia.org for trixie (and generally update container to use trixie base image).

This change migrates the frigate container build to use Debian trixie as the base image.
This permits us to use newer upstream packages (and, for example, stop needing to use a custom ffmpeg
build). The main hitch was the need for Python 3.9 for Pycoral from the Google apt repository, for
Coral Edge TPU support. Fortunately, the open source community has stepped up, and there are now
TFLite and Pycoral wheels available for Python 3.10-3.12 as well.
This commit is contained in:
Amit Gurdasani 2024-09-06 16:09:38 +01:00
parent 764cca5a70
commit d360c4f808
5 changed files with 217 additions and 154 deletions

View File

@ -18,19 +18,19 @@ version:
echo 'VERSION = "$(VERSION)-$(COMMIT_HASH)"' > frigate/version.py echo 'VERSION = "$(VERSION)-$(COMMIT_HASH)"' > frigate/version.py
local: version local: version
docker buildx build --target=frigate --tag frigate:latest --load --file docker/main/Dockerfile . docker buildx build --progress plain --target=frigate --tag frigate:latest --load --file docker/main/Dockerfile .
amd64: amd64:
docker buildx build --platform linux/amd64 --target=frigate --tag $(IMAGE_REPO):$(VERSION)-$(COMMIT_HASH) --file docker/main/Dockerfile . docker buildx build --progress plain --platform linux/amd64 --target=frigate --tag $(IMAGE_REPO):$(VERSION)-$(COMMIT_HASH) --file docker/main/Dockerfile .
arm64: arm64:
docker buildx build --platform linux/arm64 --target=frigate --tag $(IMAGE_REPO):$(VERSION)-$(COMMIT_HASH) --file docker/main/Dockerfile . docker buildx build --progress plain --platform linux/arm64 --target=frigate --tag $(IMAGE_REPO):$(VERSION)-$(COMMIT_HASH) --file docker/main/Dockerfile .
build: version amd64 arm64 build: version amd64 arm64
docker buildx build --platform linux/arm64/v8,linux/amd64 --target=frigate --tag $(IMAGE_REPO):$(VERSION)-$(COMMIT_HASH) --file docker/main/Dockerfile . docker buildx build --progress plain --platform linux/arm64/v8,linux/amd64 --target=frigate --tag $(IMAGE_REPO):$(VERSION)-$(COMMIT_HASH) --file docker/main/Dockerfile .
push: push-boards push: push-boards
docker buildx build --push --platform linux/arm64/v8,linux/amd64 --target=frigate --tag $(IMAGE_REPO):${GITHUB_REF_NAME}-$(COMMIT_HASH) --file docker/main/Dockerfile . docker buildx build --progress plain --push --platform linux/arm64/v8,linux/amd64 --target=frigate --tag $(IMAGE_REPO):${GITHUB_REF_NAME}-$(COMMIT_HASH) --file docker/main/Dockerfile .
run: local run: local
docker run --rm --publish=5000:5000 --volume=${PWD}/config:/config frigate:latest docker run --rm --publish=5000:5000 --volume=${PWD}/config:/config frigate:latest

View File

@ -1,22 +1,21 @@
# syntax=docker/dockerfile:1.6 # syntax=docker/dockerfile:1.6
# https://askubuntu.com/questions/972516/debian-frontend-environment-variable ARG BASE_IMAGE=debian:testing
ARG DEBIAN_FRONTEND=noninteractive ARG SLIM_BASE=debian:testing-slim
ARG BASE_IMAGE=debian:11
ARG SLIM_BASE=debian:11-slim
FROM ${BASE_IMAGE} AS base FROM ${BASE_IMAGE} AS base
FROM --platform=${BUILDPLATFORM} debian:11 AS base_host FROM --platform=${BUILDPLATFORM} ${BASE_IMAGE} AS base_host
FROM ${SLIM_BASE} AS slim-base FROM ${SLIM_BASE} AS slim-base
FROM slim-base AS wget FROM slim-base AS wget
ARG DEBIAN_FRONTEND RUN set -eux; \
RUN apt-get update \ DEBIAN_FRONTEND=noninteractive; \
&& apt-get install -y wget xz-utils \ export DEBIAN_FRONTEND; \
&& rm -rf /var/lib/apt/lists/* apt -y update; \
apt -y install wget xz-utils; \
rm -rf /var/lib/apt/lists/* /var/cache/apt/archives/*
WORKDIR /rootfs WORKDIR /rootfs
FROM base AS nginx FROM base AS nginx
@ -28,6 +27,7 @@ ENV CCACHE_MAXSIZE 2G
RUN --mount=type=tmpfs,target=/tmp --mount=type=tmpfs,target=/var/cache/apt \ RUN --mount=type=tmpfs,target=/tmp --mount=type=tmpfs,target=/var/cache/apt \
--mount=type=bind,source=docker/main/build_nginx.sh,target=/deps/build_nginx.sh \ --mount=type=bind,source=docker/main/build_nginx.sh,target=/deps/build_nginx.sh \
--mount=type=cache,target=/root/.ccache \ --mount=type=cache,target=/root/.ccache \
set -eux; \
/deps/build_nginx.sh /deps/build_nginx.sh
FROM scratch AS go2rtc FROM scratch AS go2rtc
@ -38,6 +38,7 @@ ADD --link --chmod=755 "https://github.com/AlexxIT/go2rtc/releases/download/v1.9
FROM wget AS tempio FROM wget AS tempio
ARG TARGETARCH ARG TARGETARCH
RUN --mount=type=bind,source=docker/main/install_tempio.sh,target=/deps/install_tempio.sh \ RUN --mount=type=bind,source=docker/main/install_tempio.sh,target=/deps/install_tempio.sh \
set -eux; \
/deps/install_tempio.sh /deps/install_tempio.sh
#### ####
@ -49,22 +50,27 @@ RUN --mount=type=bind,source=docker/main/install_tempio.sh,target=/deps/install_
#### ####
# Download and Convert OpenVino model # Download and Convert OpenVino model
FROM base_host AS ov-converter FROM base_host AS ov-converter
ARG DEBIAN_FRONTEND
# Install OpenVino Runtime and Dev library # Install OpenVino Runtime and Dev library
COPY docker/main/requirements-ov.txt /requirements-ov.txt COPY docker/main/requirements-ov.txt /requirements-ov.txt
RUN apt-get -qq update \ RUN set -eux; \
&& apt-get -qq install -y wget python3 python3-dev python3-distutils gcc pkg-config libhdf5-dev \ DEBIAN_FRONTEND=noninteractive; \
&& wget -q https://bootstrap.pypa.io/get-pip.py -O get-pip.py \ export DEBIAN_FRONTEND; \
&& python3 get-pip.py "pip" \ apt -qq update; \
&& pip install -r /requirements-ov.txt apt -qq -y install wget python3 python3-dev python3-setuptools python3-pip gcc pkg-config libhdf5-dev; \
pip install --break-system-packages -r /requirements-ov.txt; \
rm -rf /var/lib/apt/lists/* /var/cache/apt/archives/* ~/.cache/pip
# Get OpenVino Model # Get OpenVino Model
RUN --mount=type=bind,source=docker/main/build_ov_model.py,target=/build_ov_model.py \ RUN --mount=type=bind,source=docker/main/build_ov_model.py,target=/build_ov_model.py \
mkdir /models && cd /models \ set -eux; \
&& wget http://download.tensorflow.org/models/object_detection/ssdlite_mobilenet_v2_coco_2018_05_09.tar.gz \ mkdir -p /models; \
&& tar -xvf ssdlite_mobilenet_v2_coco_2018_05_09.tar.gz \ cd /models; \
&& python3 /build_ov_model.py weights_tarball=ssdlite_mobilenet_v2_coco_2018_05_09.tar.gz; \
wget http://download.tensorflow.org/models/object_detection/$weights_tarball; \
tar xzf $weights_tarball; \
python3 /build_ov_model.py; \
rm -f $weights_tarball
#### ####
# #
@ -81,95 +87,111 @@ ENV CCACHE_MAXSIZE 2G
# Build libUSB without udev. Needed for Openvino NCS2 support # Build libUSB without udev. Needed for Openvino NCS2 support
WORKDIR /opt WORKDIR /opt
RUN apt-get update && apt-get install -y unzip build-essential automake libtool ccache pkg-config RUN --mount=type=cache,target=/root/.ccache \
RUN --mount=type=cache,target=/root/.ccache wget -q https://github.com/libusb/libusb/archive/v1.0.26.zip -O v1.0.26.zip && \ set -eux; \
unzip v1.0.26.zip && cd libusb-1.0.26 && \ DEBIAN_FRONTEND=noninteractive; \
./bootstrap.sh && \ export DEBIAN_FRONTEND; \
./configure CC='ccache gcc' CCX='ccache g++' --disable-udev --enable-shared && \ apt -y update; \
make -j $(nproc --all) apt -y install unzip build-essential automake libtool ccache pkg-config; \
RUN apt-get update && \ apt -y install --no-install-recommends libusb-1.0-0-dev; \
apt-get install -y --no-install-recommends libusb-1.0-0-dev && \ libusb_version=1.0.27; \
rm -rf /var/lib/apt/lists/* wget -q https://github.com/libusb/libusb/archive/v${libusb_version}.zip -O v${libusb_version}.zip; \
WORKDIR /opt/libusb-1.0.26/libusb unzip v${libusb_version}.zip; \
RUN /bin/mkdir -p '/usr/local/lib' && \ cd libusb-${libusb_version}; \
/bin/bash ../libtool --mode=install /usr/bin/install -c libusb-1.0.la '/usr/local/lib' && \ ./bootstrap.sh; \
/bin/mkdir -p '/usr/local/include/libusb-1.0' && \ ./configure CC='ccache gcc' CCX='ccache g++' --disable-udev --enable-shared; \
/usr/bin/install -c -m 644 libusb.h '/usr/local/include/libusb-1.0' && \ make -j $(nproc --all); \
/bin/mkdir -p '/usr/local/lib/pkgconfig' && \ rm -rf /var/lib/apt/lists/* /var/cache/apt/archives/*
cd /opt/libusb-1.0.26/ && \ WORKDIR /opt/libusb-1.0.27/libusb
/usr/bin/install -c -m 644 libusb-1.0.pc '/usr/local/lib/pkgconfig' && \ RUN set -eux; \
/bin/mkdir -p '/usr/local/lib'; \
/bin/bash ../libtool --mode=install /usr/bin/install -c libusb-1.0.la '/usr/local/lib'; \
/bin/mkdir -p '/usr/local/include/libusb-1.0'; \
/usr/bin/install -c -m 644 libusb.h '/usr/local/include/libusb-1.0'; \
/bin/mkdir -p '/usr/local/lib/pkgconfig'; \
cd /opt/libusb-1.0.27/; \
/usr/bin/install -c -m 644 libusb-1.0.pc '/usr/local/lib/pkgconfig'; \
ldconfig ldconfig
FROM wget AS models FROM wget AS models
# Get model and labels # Get model and labels
RUN wget -qO edgetpu_model.tflite https://github.com/google-coral/test_data/raw/release-frogfish/ssdlite_mobiledet_coco_qat_postprocess_edgetpu.tflite RUN set -eux; \
RUN wget -qO cpu_model.tflite https://github.com/google-coral/test_data/raw/release-frogfish/ssdlite_mobiledet_coco_qat_postprocess.tflite wget -qO edgetpu_model.tflite https://github.com/google-coral/test_data/raw/release-frogfish/ssdlite_mobiledet_coco_qat_postprocess_edgetpu.tflite; \
wget -qO cpu_model.tflite https://github.com/google-coral/test_data/raw/release-frogfish/ssdlite_mobiledet_coco_qat_postprocess.tflite
COPY labelmap.txt . COPY labelmap.txt .
# Copy OpenVino model # Copy OpenVino model
COPY --from=ov-converter /models/ssdlite_mobilenet_v2.xml openvino-model/ COPY --from=ov-converter /models/ssdlite_mobilenet_v2.xml openvino-model/
COPY --from=ov-converter /models/ssdlite_mobilenet_v2.bin openvino-model/ COPY --from=ov-converter /models/ssdlite_mobilenet_v2.bin openvino-model/
RUN wget -q https://github.com/openvinotoolkit/open_model_zoo/raw/master/data/dataset_classes/coco_91cl_bkgr.txt -O openvino-model/coco_91cl_bkgr.txt && \ RUN set -eux; \
sed -i 's/truck/car/g' openvino-model/coco_91cl_bkgr.txt wget -q https://github.com/openvinotoolkit/open_model_zoo/raw/master/data/dataset_classes/coco_91cl_bkgr.txt -O openvino-model/coco_91cl_bkgr.txt; \
# Get Audio Model and labels sed -i 's/truck/car/g' openvino-model/coco_91cl_bkgr.txt; \
RUN wget -qO - https://www.kaggle.com/api/v1/models/google/yamnet/tfLite/classification-tflite/1/download | tar xvz && mv 1.tflite cpu_audio_model.tflite wget -qO - https://www.kaggle.com/api/v1/models/google/yamnet/tfLite/classification-tflite/1/download | \
tar xzf -; \
mv 1.tflite cpu_audio_model.tflite # Get Audio Model and labels
COPY audio-labelmap.txt . COPY audio-labelmap.txt .
FROM wget AS s6-overlay FROM wget AS s6-overlay
ARG TARGETARCH ARG TARGETARCH
RUN --mount=type=bind,source=docker/main/install_s6_overlay.sh,target=/deps/install_s6_overlay.sh \ RUN --mount=type=bind,source=docker/main/install_s6_overlay.sh,target=/deps/install_s6_overlay.sh \
set -eux; \
/deps/install_s6_overlay.sh /deps/install_s6_overlay.sh
FROM base AS wheels FROM base AS wheels
ARG DEBIAN_FRONTEND
ARG TARGETARCH ARG TARGETARCH
# Use a separate container to build wheels to prevent build dependencies in final image # Use a separate container to build wheels to prevent build dependencies in final image
RUN apt-get -qq update \ RUN set -eux; \
&& apt-get -qq install -y \ DEBIAN_FRONTEND=noninteractive; \
apt-transport-https \ export DEBIAN_FRONTEND; \
gnupg \ apt -qq -y update; \
wget \ apt -qq -y install apt-transport-https gnupg wget ca-certificates; \
# the key fingerprint can be obtained from https://ftp-master.debian.org/keys.html (echo "deb https://cdn-aws.deb.debian.org/debian testing main contrib non-free non-free-firmware"; \
&& wget -qO- "https://keyserver.ubuntu.com/pks/lookup?op=get&search=0xA4285295FC7B1A81600062A9605C66F00D6C9793" | \ echo "deb https://cdn-aws.deb.debian.org/debian stable main contrib non-free non-free-firmware"; \
gpg --dearmor > /usr/share/keyrings/debian-archive-bullseye-stable.gpg \ echo "deb https://cdn-aws.deb.debian.org/debian stable-updates main contrib non-free non-free-firmware"; \
&& echo "deb [signed-by=/usr/share/keyrings/debian-archive-bullseye-stable.gpg] http://deb.debian.org/debian bullseye main contrib non-free" | \ echo "deb https://cdn-aws.deb.debian.org/debian-security/ stable-security main contrib non-free non-free-firmware") | \
tee /etc/apt/sources.list.d/debian-bullseye-nonfree.list \ tee /etc/apt/sources.list.d/debian-testing-nonfree.list; \
&& apt-get -qq update \
&& apt-get -qq install -y \ apt -y -qq update; \
python3.9 \ apt -y -qq install python3 python3-dev python3-pip python3-setuptools \
python3.9-dev \
# opencv dependencies # opencv dependencies
build-essential cmake git pkg-config libgtk-3-dev \ build-essential cmake git pkg-config libgtk-3-dev \
libavcodec-dev libavformat-dev libswscale-dev libv4l-dev \ libavcodec-dev libavformat-dev libswscale-dev libv4l-dev \
libxvidcore-dev libx264-dev libjpeg-dev libpng-dev libtiff-dev \ libxvidcore-dev libx264-dev libjpeg-dev libpng-dev libtiff-dev \
gfortran openexr libatlas-base-dev libssl-dev\ gfortran openexr libatlas-base-dev libssl-dev\
libtbb2 libtbb-dev libdc1394-22-dev libopenexr-dev \ libtbbmalloc2 libtbb-dev libdc1394-dev libopenexr-dev \
libgstreamer-plugins-base1.0-dev libgstreamer1.0-dev \ libgstreamer-plugins-base1.0-dev libgstreamer1.0-dev \
# sqlite3 dependencies # sqlite3 dependencies
tclsh \ tclsh \
# scipy dependencies # scipy dependencies
gcc gfortran libopenblas-dev liblapack-dev && \ gcc gfortran libopenblas-dev liblapack-dev; \
rm -rf /var/lib/apt/lists/* rm -rf /var/lib/apt/lists/* /var/cache/apt/archives/*
# Ensure python3 defaults to python3.9
RUN update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.9 1
RUN wget -q https://bootstrap.pypa.io/get-pip.py -O get-pip.py \
&& python3 get-pip.py "pip"
COPY docker/main/requirements.txt /requirements.txt COPY docker/main/requirements.txt /requirements.txt
RUN pip3 install -r /requirements.txt RUN set -eux; \
mkdir -p /root/wheel-build; \
cd /root/wheel-build; \
pip3 download nvidia-pyindex==1.0.9; \
tar xzf nvidia-pyindex-1.0.9.tar.gz; \
cd nvidia-pyindex-1.0.9; \
pip3 wheel .; \
pip3 install --break-system-packages nvidia_pyindex*whl; \
mkdir -p /wheels; \
mv *.whl /wheels; \
cd; \
pip3 install --break-system-packages -r /requirements.txt; \
rm -rf /root/.cache/pip /root/wheel-build
# Build pysqlite3 from source to support ChromaDB # Build pysqlite3 from source to support ChromaDB
COPY docker/main/build_pysqlite3.sh /build_pysqlite3.sh COPY docker/main/build_pysqlite3.sh /build_pysqlite3.sh
RUN /build_pysqlite3.sh RUN set -eux; \
/build_pysqlite3.sh
COPY docker/main/requirements-wheels.txt /requirements-wheels.txt COPY docker/main/requirements-wheels.txt /requirements-wheels.txt
RUN pip3 wheel --wheel-dir=/wheels -r /requirements-wheels.txt RUN set -eux; \
pip3 wheel --wheel-dir=/wheels -r /requirements-wheels.txt
# Collect deps in a single layer # Collect deps in a single layer
FROM scratch AS deps-rootfs FROM scratch AS deps-rootfs
@ -186,7 +208,6 @@ COPY docker/main/rootfs/ /
FROM slim-base AS deps FROM slim-base AS deps
ARG TARGETARCH ARG TARGETARCH
ARG DEBIAN_FRONTEND
# http://stackoverflow.com/questions/48162574/ddg#49462622 # http://stackoverflow.com/questions/48162574/ddg#49462622
ARG APT_KEY_DONT_WARN_ON_DANGEROUS_USAGE=DontWarn ARG APT_KEY_DONT_WARN_ON_DANGEROUS_USAGE=DontWarn
@ -201,19 +222,37 @@ ENV ALLOW_RESET=True
# Disable tokenizer parallelism warning # Disable tokenizer parallelism warning
ENV TOKENIZERS_PARALLELISM=true ENV TOKENIZERS_PARALLELISM=true
ENV PATH="/usr/lib/btbn-ffmpeg/bin:/usr/local/go2rtc/bin:/usr/local/tempio/bin:/usr/local/nginx/sbin:${PATH}" ENV PATH="/usr/local/go2rtc/bin:/usr/local/tempio/bin:/usr/local/nginx/sbin:${PATH}"
# Install dependencies # Install dependencies
RUN --mount=type=bind,source=docker/main/install_deps.sh,target=/deps/install_deps.sh \ RUN --mount=type=bind,source=docker/main/install_deps.sh,target=/deps/install_deps.sh \
set -eux; \
DEBIAN_FRONTEND=noninteractive; \
export DEBIAN_FRONTEND; \
keyring_pkg=deb-multimedia-keyring_2016.8.1_all.deb; \
apt -y update; \
apt -y install wget; \
wget -O /root/$keyring_pkg https://www.deb-multimedia.org/pool/main/d/deb-multimedia-keyring/$keyring_pkg; \
dpkg -i /root/$keyring_pkg; \
rm -f /root/$keyring_pkg; \
echo 'deb https://debian-mirrors.sdinet.de/deb-multimedia testing main non-free' > /etc/apt/sources.list.d/deb-multimedia.list; \
apt -y update; \
apt -y install ffmpeg; \
/deps/install_deps.sh /deps/install_deps.sh
RUN --mount=type=bind,from=wheels,source=/wheels,target=/deps/wheels \ RUN --mount=type=bind,from=wheels,source=/wheels,target=/deps/wheels \
python3 -m pip install --upgrade pip && \ set -eux; \
pip3 install -U /deps/wheels/*.whl DEBIAN_FRONTEND=noninteractive; \
export DEBIAN_FRONTEND; \
apt -y update; \
apt -y install python3-pip; \
rm -rf /var/lib/apt/lists/* /var/cache/apt/archives/*; \
pip3 install --break-system-packages -U /deps/wheels/*.whl
COPY --from=deps-rootfs / / COPY --from=deps-rootfs / /
RUN ldconfig RUN set -eux; \
ldconfig
EXPOSE 5000 EXPOSE 5000
EXPOSE 8554 EXPOSE 8554
@ -238,24 +277,23 @@ FROM deps AS devcontainer
COPY docker/main/fake_frigate_run /etc/s6-overlay/s6-rc.d/frigate/run COPY docker/main/fake_frigate_run /etc/s6-overlay/s6-rc.d/frigate/run
# Create symbolic link to the frigate source code, as go2rtc's create_config.sh uses it # Create symbolic link to the frigate source code, as go2rtc's create_config.sh uses it
RUN mkdir -p /opt/frigate \ RUN set -eux; \
&& ln -svf /workspace/frigate/frigate /opt/frigate/frigate mkdir -p /opt/frigate; \
ln -sf /workspace/frigate/frigate /opt/frigate/frigate
# Install Node 20 # Install Node 20
RUN curl -SLO https://deb.nodesource.com/nsolid_setup_deb.sh && \ RUN set -eux; \
chmod 500 nsolid_setup_deb.sh && \ DEBIAN_FRONTEND=noninteractive; \
./nsolid_setup_deb.sh 20 && \ export DEBIAN_FRONTEND; \
apt-get install nodejs -y \ apt -y update; \
&& rm -rf /var/lib/apt/lists/* \ apt -y install nodejs make; \
&& npm install -g npm@10 rm -rf /var/lib/apt/lists/* /var/cache/apt/archives/*; \
npm install -g npm@10
WORKDIR /workspace/frigate WORKDIR /workspace/frigate
RUN apt-get update \
&& apt-get install make -y \
&& rm -rf /var/lib/apt/lists/*
RUN --mount=type=bind,source=./docker/main/requirements-dev.txt,target=/workspace/frigate/requirements-dev.txt \ RUN --mount=type=bind,source=./docker/main/requirements-dev.txt,target=/workspace/frigate/requirements-dev.txt \
set -eux; \
pip3 install -r requirements-dev.txt pip3 install -r requirements-dev.txt
HEALTHCHECK NONE HEALTHCHECK NONE
@ -269,12 +307,14 @@ FROM --platform=$BUILDPLATFORM node:20 AS web-build
WORKDIR /work WORKDIR /work
COPY web/package.json web/package-lock.json ./ COPY web/package.json web/package-lock.json ./
RUN npm install RUN set -eux; \
npm install
COPY web/ ./ COPY web/ ./
RUN npm run build \ RUN set -eux; \
&& mv dist/BASE_PATH/monacoeditorwork/* dist/assets/ \ npm run build; \
&& rm -rf dist/BASE_PATH mv dist/BASE_PATH/monacoeditorwork/* dist/assets/; \
rm -rf dist/BASE_PATH
# Collect final files in a single layer # Collect final files in a single layer
FROM scratch AS rootfs FROM scratch AS rootfs

View File

@ -8,15 +8,22 @@ SECURE_TOKEN_MODULE_VERSION="1.5"
SET_MISC_MODULE_VERSION="v0.33" SET_MISC_MODULE_VERSION="v0.33"
NGX_DEVEL_KIT_VERSION="v0.3.3" NGX_DEVEL_KIT_VERSION="v0.3.3"
cp /etc/apt/sources.list /etc/apt/sources.list.d/sources-src.list DEBIAN_FRONTEND=noninteractive
sed -i 's|deb http|deb-src http|g' /etc/apt/sources.list.d/sources-src.list export DEBIAN_FRONTEND
apt-get update
apt-get -yqq build-dep nginx cat <<EOF > /etc/apt/sources.list.d/debian-src.list
deb-src http://cdn-aws.deb.debian.org/debian testing main contrib non-free non-free-firmware
apt-get -yqq install --no-install-recommends ca-certificates wget EOF
apt -y update
apt -y install --no-install-recommends ca-certificates wget
cat <<EOF > /etc/apt/sources.list.d/debian-src.list
deb-src https://cdn-aws.deb.debian.org/debian testing main contrib non-free non-free-firmware
EOF
update-ca-certificates -f update-ca-certificates -f
apt install -y ccache
apt -y update
apt -yqq build-dep nginx
apt -y install ccache
export PATH="/usr/lib/ccache:$PATH" export PATH="/usr/lib/ccache:$PATH"

View File

@ -1,10 +1,18 @@
import openvino as ov import openvino as ov
from openvino.tools import mo from openvino.tools import mo
from pathlib import Path
from site import getsitepackages
def transformations_config_location(path: Path):
return path / 'openvino' / 'tools' / 'mo' / 'front' / 'tf' / 'ssd_v2_support.json'
configs = [transformations_config_location(Path(path)) for path in getsitepackages()]
assert len(configs) > 0, 'Expected at least one transformations config to exist but none existed.'
ov_model = mo.convert_model( ov_model = mo.convert_model(
"/models/ssdlite_mobilenet_v2_coco_2018_05_09/frozen_inference_graph.pb", "/models/ssdlite_mobilenet_v2_coco_2018_05_09/frozen_inference_graph.pb",
compress_to_fp16=True, compress_to_fp16=True,
transformations_config="/usr/local/lib/python3.9/dist-packages/openvino/tools/mo/front/tf/ssd_v2_support.json", transformations_config=configs[0],
tensorflow_object_detection_api_pipeline_config="/models/ssdlite_mobilenet_v2_coco_2018_05_09/pipeline.config", tensorflow_object_detection_api_pipeline_config="/models/ssdlite_mobilenet_v2_coco_2018_05_09/pipeline.config",
reverse_input_channels=True, reverse_input_channels=True,
) )

View File

@ -2,6 +2,9 @@
set -euxo pipefail set -euxo pipefail
DEBIAN_FRONTEND=noninteractive
export DEBIAN_FRONTEND
apt-get -qq update apt-get -qq update
apt-get -qq install --no-install-recommends -y \ apt-get -qq install --no-install-recommends -y \
@ -10,76 +13,81 @@ apt-get -qq install --no-install-recommends -y \
wget \ wget \
procps vainfo \ procps vainfo \
unzip locales tzdata libxml2 xz-utils \ unzip locales tzdata libxml2 xz-utils \
python3.9 \ python3 \
python3-pip \ python3-pip \
curl \ curl \
jq \ jq \
nethogs nethogs
# ensure python3 defaults to python3.9
update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.9 1
mkdir -p -m 600 /root/.gnupg mkdir -p -m 600 /root/.gnupg
# add coral repo # add coral repo
curl -fsSLo - https://packages.cloud.google.com/apt/doc/apt-key.gpg | \ curl -fsSLo - https://packages.cloud.google.com/apt/doc/apt-key.gpg | \
gpg --dearmor -o /etc/apt/trusted.gpg.d/google-cloud-packages-archive-keyring.gpg gpg --dearmor -o /etc/apt/trusted.gpg.d/google-cloud-packages-archive-keyring.gpg
echo "deb https://packages.cloud.google.com/apt coral-edgetpu-stable main" | tee /etc/apt/sources.list.d/coral-edgetpu.list echo "deb https://packages.cloud.google.com/apt coral-edgetpu-stable main" > /etc/apt/sources.list.d/coral-edgetpu.list
echo "libedgetpu1-max libedgetpu/accepted-eula select true" | debconf-set-selections echo "libedgetpu1-max libedgetpu/accepted-eula select true" | debconf-set-selections
# enable non-free repo in Debian # enable non-free repo in Debian
if grep -q "Debian" /etc/issue; then if grep -q "Debian" /etc/issue; then
sed -i -e's/ main/ main contrib non-free/g' /etc/apt/sources.list sed -i -e's/ main/ main contrib non-free non-free-firmware/g' /etc/apt/sources.list.d/debian.sources
echo "deb https://cdn-aws.deb.debian.org/debian unstable main contrib non-free non-free-firmware" > /etc/apt/sources.list.d/debian-unstable.list
{
echo 'Package: *'
echo 'Pin: release a=unstable'
echo 'Pin-Priority: 300'
} > /etc/apt/preferences.d/unstable
fi fi
# coral drivers # coral drivers
apt-get -qq update apt-get -qq update
apt-get -qq install --no-install-recommends --no-install-suggests -y \ apt-get -y install --no-install-recommends --no-install-suggests libedgetpu1-max python3-numpy
libedgetpu1-max python3-tflite-runtime python3-pycoral
# btbn-ffmpeg -> amd64 # Google have abandoned the Coral Edge TPU and the version of pycoral in their repo only works with Python 3.9.
if [[ "${TARGETARCH}" == "amd64" ]]; then # The open source community have stepped up and have updated pycoral to work with newer versions of TFLite and Python.
mkdir -p /usr/lib/btbn-ffmpeg # See: https://github.com/google-coral/pycoral/issues/85#issuecomment-2282233714
wget -qO btbn-ffmpeg.tar.xz "https://github.com/BtbN/FFmpeg-Builds/releases/download/autobuild-2024-09-04-18-56/ffmpeg-n7.0.2-15-g0458a86656-linux64-gpl-7.0.tar.xz"
tar -xf btbn-ffmpeg.tar.xz -C /usr/lib/btbn-ffmpeg --strip-components 1
rm -rf btbn-ffmpeg.tar.xz /usr/lib/btbn-ffmpeg/doc /usr/lib/btbn-ffmpeg/bin/ffplay
fi
# ffmpeg -> arm64 case "${TARGETARCH}" in
if [[ "${TARGETARCH}" == "arm64" ]]; then amd64)
mkdir -p /usr/lib/btbn-ffmpeg tflite_wheel=https://github.com/feranick/TFlite-builds/releases/download/v2.17.0/tflite_runtime-2.17.0-cp312-cp312-linux_x86_64.whl
wget -qO btbn-ffmpeg.tar.xz "https://github.com/BtbN/FFmpeg-Builds/releases/download/autobuild-2024-09-04-18-56/ffmpeg-n7.0.2-15-g0458a86656-linuxarm64-gpl-7.0.tar.xz" pycoral_wheel=https://github.com/feranick/pycoral/releases/download/2.0.2TF2.17.0/pycoral-2.0.2-cp312-cp312-linux_x86_64.whl
tar -xf btbn-ffmpeg.tar.xz -C /usr/lib/btbn-ffmpeg --strip-components 1 ;;
rm -rf btbn-ffmpeg.tar.xz /usr/lib/btbn-ffmpeg/doc /usr/lib/btbn-ffmpeg/bin/ffplay arm64)
fi tflite_wheel=https://github.com/feranick/TFlite-builds/releases/download/v2.17.0/tflite_runtime-2.17.0-cp312-cp312-linux_aarch64.whl
pycoral_wheel=https://github.com/feranick/pycoral/releases/download/2.0.2TF2.17.0/pycoral-2.0.2-cp312-cp312-linux_aarch64.whl
;;
*)
echo Pycoral is not supported on target architecture "${TARGETARCH}". 1>&2
exit 1
;;
esac
pip install --break-system-packages "${tflite_wheel}"
pip install --break-system-packages "${pycoral_wheel}"
# arch specific packages # arch specific packages
if [[ "${TARGETARCH}" == "amd64" ]]; then case "${TARGETARCH}" in
# use debian bookworm for hwaccel packages amd64)
echo 'deb https://deb.debian.org/debian bookworm main contrib non-free' >/etc/apt/sources.list.d/debian-bookworm.list apt -y -qq install --no-install-recommends --no-install-suggests \
apt-get -qq update
apt-get -qq install --no-install-recommends --no-install-suggests -y \
intel-opencl-icd \ intel-opencl-icd \
mesa-va-drivers radeontop libva-drm2 intel-media-va-driver-non-free i965-va-driver libmfx1 intel-gpu-tools mesa-va-drivers radeontop libva-drm2 intel-media-va-driver-non-free i965-va-driver libmfx1 intel-gpu-tools
# something about this dependency requires it to be installed in a separate call rather than in the line above # something about this dependency requires it to be installed in a separate call rather than in the line above
apt-get -qq install --no-install-recommends --no-install-suggests -y \ apt -y -qq install --no-install-recommends --no-install-suggests \
i965-va-driver-shaders i965-va-driver-shaders
rm -f /etc/apt/sources.list.d/debian-bookworm.list ;;
fi arm64)
apt -y -qq install --no-install-recommends --no-install-suggests \
if [[ "${TARGETARCH}" == "arm64" ]]; then
apt-get -qq install --no-install-recommends --no-install-suggests -y \
libva-drm2 mesa-va-drivers libva-drm2 mesa-va-drivers
fi ;;
esac
# install vulkan # install vulkan
apt-get -qq install --no-install-recommends --no-install-suggests -y \ apt-get -qq install --no-install-recommends --no-install-suggests -y \
libvulkan1 mesa-vulkan-drivers libvulkan1 mesa-vulkan-drivers
apt-get purge gnupg apt-transport-https xz-utils -y apt-get -y purge gnupg apt-transport-https xz-utils
apt-get clean autoclean -y apt-get -y clean autoclean
apt-get autoremove --purge -y apt-get -y autoremove --purge
rm -rf /var/lib/apt/lists/* rm -rf /var/lib/apt/lists/* /var/cache/apt/archives/*
# Install yq, for frigate-prepare and go2rtc echo source # Install yq, for frigate-prepare and go2rtc echo source
curl -fsSL \ curl -fsSL \