Skip to content

NVR with realtime local object detection for IP cameras

simplify hailort (#14734)

Blake Blackshear27ef661fec25
diff --git a/docker/hailo8l/Dockerfile b/docker/hailo8l/Dockerfile
index 701c81d0f6..959e7692ed 100644
--- a/docker/hailo8l/Dockerfile
+++ b/docker/hailo8l/Dockerfile
@@ -2,9 +2,6 @@
ARG DEBIAN_FRONTEND=noninteractive
-# NOTE: also update user_installation.sh
-ARG HAILO_VERSION=4.19.0
-
# Build Python wheels
FROM wheels AS h8l-wheels
@@ -19,63 +16,18 @@ RUN mkdir /h8l-wheels
# Build the wheels
RUN pip3 wheel --wheel-dir=/h8l-wheels -c /requirements-wheels.txt -r /requirements-wheels-h8l.txt
-# Build HailoRT and create wheel
-FROM wheels AS build-hailort
+FROM wget AS hailort
ARG TARGETARCH
-ARG HAILO_VERSION
-
-SHELL ["/bin/bash", "-c"]
-
-# Install necessary APT packages
-RUN apt-get -qq update \
- && apt-get -qq install -y \
- apt-transport-https \
- gnupg \
- wget \
- # the key fingerprint can be obtained from https://ftp-master.debian.org/keys.html
- && wget -qO- "https://keyserver.ubuntu.com/pks/lookup?op=get&search=0xA4285295FC7B1A81600062A9605C66F00D6C9793" | \
- gpg --dearmor > /usr/share/keyrings/debian-archive-bullseye-stable.gpg \
- && echo "deb [signed-by=/usr/share/keyrings/debian-archive-bullseye-stable.gpg] http://deb.debian.org/debian bullseye main contrib non-free" | \
- tee /etc/apt/sources.list.d/debian-bullseye-nonfree.list \
- && apt-get -qq update \
- && apt-get -qq install -y \
- python3.9 \
- python3.9-dev \
- build-essential cmake git \
- && rm -rf /var/lib/apt/lists/*
-
-# Extract Python version and set environment variables
-RUN PYTHON_VERSION=$(python3 --version 2>&1 | awk '{print $2}' | cut -d. -f1,2) && \
- PYTHON_VERSION_NO_DOT=$(echo $PYTHON_VERSION | sed 's/\.//') && \
- echo "PYTHON_VERSION=$PYTHON_VERSION" > /etc/environment && \
- echo "PYTHON_VERSION_NO_DOT=$PYTHON_VERSION_NO_DOT" >> /etc/environment
-
-# Clone and build HailoRT
-RUN . /etc/environment && \
- git clone https://github.com/hailo-ai/hailort.git /opt/hailort && \
- cd /opt/hailort && \
- git checkout v${HAILO_VERSION} && \
- cmake -H. -Bbuild -DCMAKE_BUILD_TYPE=Release && \
- cmake --build build --config release --target libhailort && \
- cmake --build build --config release --target hailortcli && \
- cmake --build build --config release --target install
-
-# Create a wheel file using pip3 wheel
-RUN cd /opt/hailort/hailort/libhailort/bindings/python/platform && \
- python3 setup.py bdist_wheel --dist-dir /hailo-wheels
-
-RUN mkdir -p /rootfs/usr/local/lib /rootfs/usr/local/bin && \
- cp /usr/local/lib/libhailort.so* /rootfs/usr/local/lib && \
- cp /usr/local/bin/hailortcli /rootfs/usr/local/bin
+RUN --mount=type=bind,source=docker/hailo8l/install_hailort.sh,target=/deps/install_hailort.sh \
+ /deps/install_hailort.sh
# Use deps as the base image
FROM deps AS h8l-frigate
-ARG HAILO_VERSION
# Copy the wheels from the wheels stage
COPY --from=h8l-wheels /h8l-wheels /deps/h8l-wheels
-COPY --from=build-hailort /hailo-wheels /deps/hailo-wheels
-COPY --from=build-hailort /rootfs/ /
+COPY --from=hailort /hailo-wheels /deps/hailo-wheels
+COPY --from=hailort /rootfs/ /
# Install the wheels
RUN pip3 install -U /deps/h8l-wheels/*.whl
diff --git a/docker/hailo8l/h8l.hcl b/docker/hailo8l/h8l.hcl
index a1eb82fb5e..91f6d13c6e 100644
--- a/docker/hailo8l/h8l.hcl
+++ b/docker/hailo8l/h8l.hcl
@@ -1,3 +1,9 @@
+target wget {
+ dockerfile = "docker/main/Dockerfile"
+ platforms = ["linux/arm64","linux/amd64"]
+ target = "wget"
+}
+
target wheels {
dockerfile = "docker/main/Dockerfile"
platforms = ["linux/arm64","linux/amd64"]
@@ -19,6 +25,7 @@ target rootfs {
target h8l {
dockerfile = "docker/hailo8l/Dockerfile"
contexts = {
+ wget = "target:wget"
wheels = "target:wheels"
deps = "target:deps"
rootfs = "target:rootfs"
diff --git a/docker/hailo8l/install_hailort.sh b/docker/hailo8l/install_hailort.sh
new file mode 100755
index 0000000000..004db86c93
--- /dev/null
+++ b/docker/hailo8l/install_hailort.sh
@@ -0,0 +1,21 @@
+#!/bin/bash
+
+set -euxo pipefail
+
+hailo_version="4.19.0"
+
+if [[ "${TARGETARCH}" == "amd64" ]]; then
+ arch="x86_64"
+elif [[ "${TARGETARCH}" == "arm64" ]]; then
+ arch="aarch64"
+fi
+
+mkdir -p /rootfs
+
+wget -qO- "https://github.com/frigate-nvr/hailort/releases/download/v${hailo_version}/hailort-${TARGETARCH}.tar.gz" |
+ tar -C /rootfs/ -xzf -
+
+mkdir -p /hailo-wheels
+
+wget -P /hailo-wheels/ "https://github.com/frigate-nvr/hailort/releases/download/v${hailo_version}/hailort-${hailo_version}-cp39-cp39-linux_${arch}.whl"
+