Skip to content

Commit

Permalink
Hailo amd64 support (#12820)
Browse files Browse the repository at this point in the history
* Support building docker image for amd64 and arm64

* Support installations on amd64 and arm64

* Run build in new job

* Update docs
  • Loading branch information
NickM-27 committed Aug 30, 2024
1 parent 347d54f commit c16450a
Show file tree
Hide file tree
Showing 5 changed files with 85 additions and 32 deletions.
34 changes: 24 additions & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,16 +78,6 @@ jobs:
set: |
rk.tags=${{ steps.setup.outputs.image-name }}-rk
*.cache-from=type=gha
- name: Build and push Hailo-8l build
uses: docker/bake-action@v4
with:
push: true
targets: h8l
files: docker/hailo8l/h8l.hcl
set: |
h8l.tags=${{ steps.setup.outputs.image-name }}-h8l
*.cache-from=type=registry,ref=${{ steps.setup.outputs.cache-name }}-h8l
*.cache-to=type=registry,ref=${{ steps.setup.outputs.cache-name }}-h8l,mode=max
jetson_jp4_build:
runs-on: ubuntu-latest
name: Jetson Jetpack 4
Expand Down Expand Up @@ -165,6 +155,30 @@ jobs:
tensorrt.tags=${{ steps.setup.outputs.image-name }}-tensorrt
*.cache-from=type=registry,ref=${{ steps.setup.outputs.cache-name }}-amd64
*.cache-to=type=registry,ref=${{ steps.setup.outputs.cache-name }}-amd64,mode=max
combined_extra_builds:
runs-on: ubuntu-latest
name: Combined Extra Builds
needs:
- amd64_build
- arm64_build
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Set up QEMU and Buildx
id: setup
uses: ./.github/actions/setup
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Hailo-8l build
uses: docker/bake-action@v4
with:
push: true
targets: h8l
files: docker/hailo8l/h8l.hcl
set: |
h8l.tags=${{ steps.setup.outputs.image-name }}-h8l
*.cache-from=type=registry,ref=${{ steps.setup.outputs.cache-name }}-h8l
*.cache-to=type=registry,ref=${{ steps.setup.outputs.cache-name }}-h8l,mode=max
#- name: AMD/ROCm general build
# env:
# AMDGPU: gfx
Expand Down
36 changes: 20 additions & 16 deletions docker/hailo8l/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,27 @@ RUN mkdir /h8l-wheels
RUN pip3 wheel --wheel-dir=/h8l-wheels -c /requirements-wheels.txt -r /requirements-wheels-h8l.txt

# Build HailoRT and create wheel
FROM deps AS build-hailort
FROM wheels AS build-hailort
ARG TARGETARCH

SHELL ["/bin/bash", "-c"]

# Install necessary APT packages
RUN apt-get update && apt-get install -y \
build-essential \
cmake \
git \
RUN apt-get -qq update \
&& apt-get -qq install -y \
apt-transport-https \
gnupg \
wget \
python3-dev \
gcc-9 \
g++-9 \
libzmq3-dev \
pciutils \
rsync \
# 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
Expand All @@ -39,9 +46,6 @@ RUN PYTHON_VERSION=$(python3 --version 2>&1 | awk '{print $2}' | cut -d. -f1,2)
echo "PYTHON_VERSION=$PYTHON_VERSION" > /etc/environment && \
echo "PYTHON_VERSION_NO_DOT=$PYTHON_VERSION_NO_DOT" >> /etc/environment

#ENV PYTHON_VER=$PYTHON_VERSION
#ENV PYTHON_VER_NO_DOT=$PYTHON_VERSION_NO_DOT

# Clone and build HailoRT
RUN . /etc/environment && \
git clone https://github.com/hailo-ai/hailort.git /opt/hailort && \
Expand All @@ -50,7 +54,7 @@ RUN . /etc/environment && \
cmake -H. -Bbuild -DCMAKE_BUILD_TYPE=Release -DHAILO_BUILD_PYBIND=1 -DPYBIND11_PYTHON_VERSION=${PYTHON_VERSION} && \
cmake --build build --config release --target libhailort && \
cmake --build build --config release --target _pyhailort && \
cp build/hailort/libhailort/bindings/python/src/_pyhailort.cpython-${PYTHON_VERSION_NO_DOT}-aarch64-linux-gnu.so hailort/libhailort/bindings/python/platform/hailo_platform/pyhailort/ && \
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/ && \
cp build/hailort/libhailort/src/libhailort.so hailort/libhailort/bindings/python/platform/hailo_platform/pyhailort/

RUN ls -ahl /opt/hailort/build/hailort/libhailort/src/
Expand Down Expand Up @@ -94,7 +98,7 @@ COPY --from=rootfs / /

# Set environment variables for Hailo SDK
ENV PATH="/opt/hailort/bin:${PATH}"
ENV LD_LIBRARY_PATH="/usr/lib/aarch64-linux-gnu:${LD_LIBRARY_PATH}"
ENV LD_LIBRARY_PATH="/usr/lib/$(if [ $TARGETARCH == "amd64" ]; then echo 'x86_64'; else echo 'aarch64'; fi )-linux-gnu:${LD_LIBRARY_PATH}"

# Set workdir
WORKDIR /opt/frigate/
8 changes: 4 additions & 4 deletions docker/hailo8l/h8l.hcl
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
target wheels {
dockerfile = "docker/main/Dockerfile"
platforms = ["linux/arm64"]
platforms = ["linux/arm64","linux/amd64"]
target = "wheels"
}

target deps {
dockerfile = "docker/main/Dockerfile"
platforms = ["linux/arm64"]
platforms = ["linux/arm64","linux/amd64"]
target = "deps"
}

target rootfs {
dockerfile = "docker/main/Dockerfile"
platforms = ["linux/arm64"]
platforms = ["linux/arm64","linux/amd64"]
target = "rootfs"
}

Expand All @@ -23,5 +23,5 @@ target h8l {
deps = "target:deps"
rootfs = "target:rootfs"
}
platforms = ["linux/arm64"]
platforms = ["linux/arm64","linux/amd64"]
}
35 changes: 35 additions & 0 deletions docker/hailo8l/user_installation.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/bin/bash

# Update package list and install dependencies
sudo apt-get update
sudo apt-get install -y build-essential cmake git wget linux-modules-extra-$(uname -r)

arch=$(uname -m)

if [[ $arch == "x86_64" ]]; then
sudo apt install -y linux-headers-$(uname -r);
else
sudo apt install -y linux-modules-extra-$(uname -r);
fi

# Clone the HailoRT driver repository
git clone --depth 1 --branch v4.17.0 https://github.com/hailo-ai/hailort-drivers.git

# Build and install the HailoRT driver
cd hailort-drivers/linux/pcie
sudo make all
sudo make install

# Load the Hailo PCI driver
sudo modprobe hailo_pci

# Download and install the firmware
cd ../../
./download_firmware.sh
sudo mv hailo8_fw.4.17.0.bin /lib/firmware/hailo/hailo8_fw.bin

# Install udev rules
sudo cp ./linux/pcie/51-hailo-udev.rules /etc/udev/rules.d/
sudo udevadm control --reload-rules && sudo udevadm trigger

echo "HailoRT driver installation complete."
4 changes: 2 additions & 2 deletions docs/docs/frigate/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,10 @@ The Hailo-8L is an M.2 card typically connected to a carrier board for PCIe, whi

For Raspberry Pi 5 users with the AI Kit, installation is straightforward. Simply follow this [guide](https://www.raspberrypi.com/documentation/accessories/ai-kit.html#ai-kit-installation) to install the driver and software.

For other boards, follow these steps for installation:
For other installations, follow these steps for installation:

1. Install the driver from the [Hailo GitHub repository](https://github.com/hailo-ai/hailort-drivers). A convenient script for Linux is available to clone the repository, build the driver, and install it.
2. Copy or download [this script](https://gist.github.com/spanner3003/4b85751d671d4ac55f926e564f1abc3e#file-install_hailo8l_driver-sh).
2. Copy or download [this script](https://github.com/blakeblackshear/frigate/blob/41c9b13d2fffce508b32dfc971fa529b49295fbd/docker/hailo8l/user_installation.sh).
3. Ensure it has execution permissions with `sudo chmod +x install_hailo8l_driver.sh`
4. Run the script with `./install_hailo8l_driver.sh`

Expand Down

0 comments on commit c16450a

Please sign in to comment.