Skip to content

Commit e481e06

Browse files
committed
MERGE
2 parents 56af28c + c17524b commit e481e06

File tree

194 files changed

+11705
-2045
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

194 files changed

+11705
-2045
lines changed

.devcontainer/post_create.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ sudo chown -R "$(id -u):$(id -g)" /media/frigate
1717
# When started as a service, LIBAVFORMAT_VERSION_MAJOR is defined in the
1818
# s6 service file. For dev, where frigate is started from an interactive
1919
# shell, we define it in .bashrc instead.
20-
echo 'export LIBAVFORMAT_VERSION_MAJOR=$(ffmpeg -version | grep -Po "libavformat\W+\K\d+")' >> $HOME/.bashrc
20+
echo 'export LIBAVFORMAT_VERSION_MAJOR=$(/usr/lib/ffmpeg/7.0/bin/ffmpeg -version | grep -Po "libavformat\W+\K\d+")' >> $HOME/.bashrc
2121

2222
make version
2323

.github/workflows/ci.yml

+71-47
Original file line numberDiff line numberDiff line change
@@ -155,57 +155,81 @@ jobs:
155155
tensorrt.tags=${{ steps.setup.outputs.image-name }}-tensorrt
156156
*.cache-from=type=registry,ref=${{ steps.setup.outputs.cache-name }}-amd64
157157
*.cache-to=type=registry,ref=${{ steps.setup.outputs.cache-name }}-amd64,mode=max
158-
- name: AMD/ROCm general build
159-
env:
160-
AMDGPU: gfx
161-
HSA_OVERRIDE: 0
162-
uses: docker/bake-action@v3
163-
with:
164-
push: true
165-
targets: rocm
166-
files: docker/rocm/rocm.hcl
167-
set: |
168-
rocm.tags=${{ steps.setup.outputs.image-name }}-rocm
169-
*.cache-from=type=gha
170-
- name: AMD/ROCm gfx900
171-
env:
172-
AMDGPU: gfx900
173-
HSA_OVERRIDE: 1
174-
HSA_OVERRIDE_GFX_VERSION: 9.0.0
175-
uses: docker/bake-action@v3
176-
with:
177-
push: true
178-
targets: rocm
179-
files: docker/rocm/rocm.hcl
180-
set: |
181-
rocm.tags=${{ steps.setup.outputs.image-name }}-rocm-gfx900
182-
*.cache-from=type=gha
183-
- name: AMD/ROCm gfx1030
184-
env:
185-
AMDGPU: gfx1030
186-
HSA_OVERRIDE: 1
187-
HSA_OVERRIDE_GFX_VERSION: 10.3.0
188-
uses: docker/bake-action@v3
158+
combined_extra_builds:
159+
runs-on: ubuntu-latest
160+
name: Combined Extra Builds
161+
needs:
162+
- amd64_build
163+
- arm64_build
164+
steps:
165+
- name: Check out code
166+
uses: actions/checkout@v4
167+
- name: Set up QEMU and Buildx
168+
id: setup
169+
uses: ./.github/actions/setup
189170
with:
190-
push: true
191-
targets: rocm
192-
files: docker/rocm/rocm.hcl
193-
set: |
194-
rocm.tags=${{ steps.setup.outputs.image-name }}-rocm-gfx1030
195-
*.cache-from=type=gha
196-
- name: AMD/ROCm gfx1100
197-
env:
198-
AMDGPU: gfx1100
199-
HSA_OVERRIDE: 1
200-
HSA_OVERRIDE_GFX_VERSION: 11.0.0
201-
uses: docker/bake-action@v3
171+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
172+
- name: Build and push Hailo-8l build
173+
uses: docker/bake-action@v4
202174
with:
203175
push: true
204-
targets: rocm
205-
files: docker/rocm/rocm.hcl
176+
targets: h8l
177+
files: docker/hailo8l/h8l.hcl
206178
set: |
207-
rocm.tags=${{ steps.setup.outputs.image-name }}-rocm-gfx1100
208-
*.cache-from=type=gha
179+
h8l.tags=${{ steps.setup.outputs.image-name }}-h8l
180+
*.cache-from=type=registry,ref=${{ steps.setup.outputs.cache-name }}-h8l
181+
*.cache-to=type=registry,ref=${{ steps.setup.outputs.cache-name }}-h8l,mode=max
182+
#- name: AMD/ROCm general build
183+
# env:
184+
# AMDGPU: gfx
185+
# HSA_OVERRIDE: 0
186+
# uses: docker/bake-action@v3
187+
# with:
188+
# push: true
189+
# targets: rocm
190+
# files: docker/rocm/rocm.hcl
191+
# set: |
192+
# rocm.tags=${{ steps.setup.outputs.image-name }}-rocm
193+
# *.cache-from=type=gha
194+
#- name: AMD/ROCm gfx900
195+
# env:
196+
# AMDGPU: gfx900
197+
# HSA_OVERRIDE: 1
198+
# HSA_OVERRIDE_GFX_VERSION: 9.0.0
199+
# uses: docker/bake-action@v3
200+
# with:
201+
# push: true
202+
# targets: rocm
203+
# files: docker/rocm/rocm.hcl
204+
# set: |
205+
# rocm.tags=${{ steps.setup.outputs.image-name }}-rocm-gfx900
206+
# *.cache-from=type=gha
207+
#- name: AMD/ROCm gfx1030
208+
# env:
209+
# AMDGPU: gfx1030
210+
# HSA_OVERRIDE: 1
211+
# HSA_OVERRIDE_GFX_VERSION: 10.3.0
212+
# uses: docker/bake-action@v3
213+
# with:
214+
# push: true
215+
# targets: rocm
216+
# files: docker/rocm/rocm.hcl
217+
# set: |
218+
# rocm.tags=${{ steps.setup.outputs.image-name }}-rocm-gfx1030
219+
# *.cache-from=type=gha
220+
#- name: AMD/ROCm gfx1100
221+
# env:
222+
# AMDGPU: gfx1100
223+
# HSA_OVERRIDE: 1
224+
# HSA_OVERRIDE_GFX_VERSION: 11.0.0
225+
# uses: docker/bake-action@v3
226+
# with:
227+
# push: true
228+
# targets: rocm
229+
# files: docker/rocm/rocm.hcl
230+
# set: |
231+
# rocm.tags=${{ steps.setup.outputs.image-name }}-rocm-gfx1100
232+
# *.cache-from=type=gha
209233
# The majority of users running arm64 are rpi users, so the rpi
210234
# build should be the primary arm64 image
211235
assemble_default_build:

CODEOWNERS

+1
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@
44
/docker/tensorrt/*jetson* @madsciencetist
55
/docker/rockchip/ @MarcA711
66
/docker/rocm/ @harakas
7+
/docker/hailo8l/ @spanner3003

Makefile

+5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
default_target: local
22

33
COMMIT_HASH := $(shell git log -1 --pretty=format:"%h"|tail -1)
4+
<<<<<<< HEAD
45
VERSION = 0.14.1
56
IMAGE_REPO ?= ghcr.io/a2nt/frigate
7+
=======
8+
VERSION = 0.15.0
9+
IMAGE_REPO ?= ghcr.io/blakeblackshear/frigate
10+
>>>>>>> upstream/dev
611
GITHUB_REF_NAME ?= $(shell git rev-parse --abbrev-ref HEAD)
712
CURRENT_UID := $(shell id -u)
813
CURRENT_GID := $(shell id -g)

docker/hailo8l/Dockerfile

+104
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
# syntax=docker/dockerfile:1.6
2+
3+
ARG DEBIAN_FRONTEND=noninteractive
4+
5+
# Build Python wheels
6+
FROM wheels AS h8l-wheels
7+
8+
COPY docker/main/requirements-wheels.txt /requirements-wheels.txt
9+
COPY docker/hailo8l/requirements-wheels-h8l.txt /requirements-wheels-h8l.txt
10+
11+
RUN sed -i "/https:\/\//d" /requirements-wheels.txt
12+
13+
# Create a directory to store the built wheels
14+
RUN mkdir /h8l-wheels
15+
16+
# Build the wheels
17+
RUN pip3 wheel --wheel-dir=/h8l-wheels -c /requirements-wheels.txt -r /requirements-wheels-h8l.txt
18+
19+
# Build HailoRT and create wheel
20+
FROM wheels AS build-hailort
21+
ARG TARGETARCH
22+
23+
SHELL ["/bin/bash", "-c"]
24+
25+
# Install necessary APT packages
26+
RUN apt-get -qq update \
27+
&& apt-get -qq install -y \
28+
apt-transport-https \
29+
gnupg \
30+
wget \
31+
# the key fingerprint can be obtained from https://ftp-master.debian.org/keys.html
32+
&& wget -qO- "https://keyserver.ubuntu.com/pks/lookup?op=get&search=0xA4285295FC7B1A81600062A9605C66F00D6C9793" | \
33+
gpg --dearmor > /usr/share/keyrings/debian-archive-bullseye-stable.gpg \
34+
&& echo "deb [signed-by=/usr/share/keyrings/debian-archive-bullseye-stable.gpg] http://deb.debian.org/debian bullseye main contrib non-free" | \
35+
tee /etc/apt/sources.list.d/debian-bullseye-nonfree.list \
36+
&& apt-get -qq update \
37+
&& apt-get -qq install -y \
38+
python3.9 \
39+
python3.9-dev \
40+
build-essential cmake git \
41+
&& rm -rf /var/lib/apt/lists/*
42+
43+
# Extract Python version and set environment variables
44+
RUN PYTHON_VERSION=$(python3 --version 2>&1 | awk '{print $2}' | cut -d. -f1,2) && \
45+
PYTHON_VERSION_NO_DOT=$(echo $PYTHON_VERSION | sed 's/\.//') && \
46+
echo "PYTHON_VERSION=$PYTHON_VERSION" > /etc/environment && \
47+
echo "PYTHON_VERSION_NO_DOT=$PYTHON_VERSION_NO_DOT" >> /etc/environment
48+
49+
# Clone and build HailoRT
50+
RUN . /etc/environment && \
51+
git clone https://github.com/hailo-ai/hailort.git /opt/hailort && \
52+
cd /opt/hailort && \
53+
git checkout v4.17.0 && \
54+
cmake -H. -Bbuild -DCMAKE_BUILD_TYPE=Release -DHAILO_BUILD_PYBIND=1 -DPYBIND11_PYTHON_VERSION=${PYTHON_VERSION} && \
55+
cmake --build build --config release --target libhailort && \
56+
cmake --build build --config release --target _pyhailort && \
57+
cp build/hailort/libhailort/bindings/python/src/_pyhailort.cpython-${PYTHON_VERSION_NO_DOT}-$(if [ $TARGETARCH == "amd64" ]; then echo 'x86_64'; else echo 'aarch64'; fi )-linux-gnu.so hailort/libhailort/bindings/python/platform/hailo_platform/pyhailort/ && \
58+
cp build/hailort/libhailort/src/libhailort.so hailort/libhailort/bindings/python/platform/hailo_platform/pyhailort/
59+
60+
RUN ls -ahl /opt/hailort/build/hailort/libhailort/src/
61+
RUN ls -ahl /opt/hailort/hailort/libhailort/bindings/python/platform/hailo_platform/pyhailort/
62+
63+
# Remove the existing setup.py if it exists in the target directory
64+
RUN rm -f /opt/hailort/hailort/libhailort/bindings/python/platform/setup.py
65+
66+
# Copy generate_wheel_conf.py and setup.py
67+
COPY docker/hailo8l/pyhailort_build_scripts/generate_wheel_conf.py /opt/hailort/hailort/libhailort/bindings/python/platform/generate_wheel_conf.py
68+
COPY docker/hailo8l/pyhailort_build_scripts/setup.py /opt/hailort/hailort/libhailort/bindings/python/platform/setup.py
69+
70+
# Run the generate_wheel_conf.py script
71+
RUN python3 /opt/hailort/hailort/libhailort/bindings/python/platform/generate_wheel_conf.py
72+
73+
# Create a wheel file using pip3 wheel
74+
RUN cd /opt/hailort/hailort/libhailort/bindings/python/platform && \
75+
python3 setup.py bdist_wheel --dist-dir /hailo-wheels
76+
77+
# Use deps as the base image
78+
FROM deps AS h8l-frigate
79+
80+
# Copy the wheels from the wheels stage
81+
COPY --from=h8l-wheels /h8l-wheels /deps/h8l-wheels
82+
COPY --from=build-hailort /hailo-wheels /deps/hailo-wheels
83+
COPY --from=build-hailort /etc/environment /etc/environment
84+
RUN CC=$(python3 -c "import sysconfig; import shlex; cc = sysconfig.get_config_var('CC'); cc_cmd = shlex.split(cc)[0]; print(cc_cmd[:-4] if cc_cmd.endswith('-gcc') else cc_cmd)") && \
85+
echo "CC=$CC" >> /etc/environment
86+
87+
# Install the wheels
88+
RUN pip3 install -U /deps/h8l-wheels/*.whl
89+
RUN pip3 install -U /deps/hailo-wheels/*.whl
90+
91+
RUN . /etc/environment && \
92+
mv /usr/local/lib/python${PYTHON_VERSION}/dist-packages/hailo_platform/pyhailort/libhailort.so /usr/lib/${CC} && \
93+
cd /usr/lib/${CC}/ && \
94+
ln -s libhailort.so libhailort.so.4.17.0
95+
96+
# Copy base files from the rootfs stage
97+
COPY --from=rootfs / /
98+
99+
# Set environment variables for Hailo SDK
100+
ENV PATH="/opt/hailort/bin:${PATH}"
101+
ENV LD_LIBRARY_PATH="/usr/lib/$(if [ $TARGETARCH == "amd64" ]; then echo 'x86_64'; else echo 'aarch64'; fi )-linux-gnu:${LD_LIBRARY_PATH}"
102+
103+
# Set workdir
104+
WORKDIR /opt/frigate/

docker/hailo8l/h8l.hcl

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
target wheels {
2+
dockerfile = "docker/main/Dockerfile"
3+
platforms = ["linux/arm64","linux/amd64"]
4+
target = "wheels"
5+
}
6+
7+
target deps {
8+
dockerfile = "docker/main/Dockerfile"
9+
platforms = ["linux/arm64","linux/amd64"]
10+
target = "deps"
11+
}
12+
13+
target rootfs {
14+
dockerfile = "docker/main/Dockerfile"
15+
platforms = ["linux/arm64","linux/amd64"]
16+
target = "rootfs"
17+
}
18+
19+
target h8l {
20+
dockerfile = "docker/hailo8l/Dockerfile"
21+
contexts = {
22+
wheels = "target:wheels"
23+
deps = "target:deps"
24+
rootfs = "target:rootfs"
25+
}
26+
platforms = ["linux/arm64","linux/amd64"]
27+
}

docker/hailo8l/h8l.mk

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
BOARDS += h8l
2+
3+
local-h8l: version
4+
docker buildx bake --load --file=docker/hailo8l/h8l.hcl --set h8l.tags=frigate:latest-h8l h8l
5+
6+
build-h8l: version
7+
docker buildx bake --file=docker/hailo8l/h8l.hcl --set h8l.tags=$(IMAGE_REPO):${GITHUB_REF_NAME}-$(COMMIT_HASH)-h8l h8l
8+
9+
push-h8l: build-h8l
10+
docker buildx bake --push --file=docker/hailo8l/h8l.hcl --set h8l.tags=$(IMAGE_REPO):${GITHUB_REF_NAME}-$(COMMIT_HASH)-h8l h8l
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
import json
2+
import os
3+
import platform
4+
import sys
5+
import sysconfig
6+
7+
8+
def extract_toolchain_info(compiler):
9+
# Remove the "-gcc" or "-g++" suffix if present
10+
if compiler.endswith("-gcc") or compiler.endswith("-g++"):
11+
compiler = compiler.rsplit("-", 1)[0]
12+
13+
# Extract the toolchain and ABI part (e.g., "gnu")
14+
toolchain_parts = compiler.split("-")
15+
abi_conventions = next(
16+
(part for part in toolchain_parts if part in ["gnu", "musl", "eabi", "uclibc"]),
17+
"",
18+
)
19+
20+
return abi_conventions
21+
22+
23+
def generate_wheel_conf():
24+
conf_file_path = os.path.join(
25+
os.path.abspath(os.path.dirname(__file__)), "wheel_conf.json"
26+
)
27+
28+
# Extract current system and Python version information
29+
py_version = f"cp{sys.version_info.major}{sys.version_info.minor}"
30+
arch = platform.machine()
31+
system = platform.system().lower()
32+
libc_version = platform.libc_ver()[1]
33+
34+
# Get the compiler information
35+
compiler = sysconfig.get_config_var("CC")
36+
abi_conventions = extract_toolchain_info(compiler)
37+
38+
# Create the new configuration data
39+
new_conf_data = {
40+
"py_version": py_version,
41+
"arch": arch,
42+
"system": system,
43+
"libc_version": libc_version,
44+
"abi": abi_conventions,
45+
"extension": {
46+
"posix": "so",
47+
"nt": "pyd", # Windows
48+
}[os.name],
49+
}
50+
51+
# If the file exists, load the existing data
52+
if os.path.isfile(conf_file_path):
53+
with open(conf_file_path, "r") as conf_file:
54+
conf_data = json.load(conf_file)
55+
# Update the existing data with the new data
56+
conf_data.update(new_conf_data)
57+
else:
58+
# If the file does not exist, use the new data
59+
conf_data = new_conf_data
60+
61+
# Write the updated data to the file
62+
with open(conf_file_path, "w") as conf_file:
63+
json.dump(conf_data, conf_file, indent=4)
64+
65+
66+
if __name__ == "__main__":
67+
generate_wheel_conf()

0 commit comments

Comments
 (0)