Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
143 changes: 143 additions & 0 deletions .github/workflows/ax.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
name: AXERA

on:
workflow_dispatch:

concurrency:
group: ${{ github.ref }}
cancel-in-progress: true

env:
PYTHON_VERSION: 3.9

jobs:
x86_axcl_builds:
runs-on: ubuntu-22.04
name: x86_AXCL Build
steps:
- name: Check out code
uses: actions/checkout@v4
with:
persist-credentials: false

- name: Set x86_AXCL_TAG
run: echo "x86_AXCL_TAG=x86-axcl-${GITHUB_SHA:0:7}" >> $GITHUB_ENV

- name: Set Version
run: make version

- name: Build
uses: docker/bake-action@v6
with:
source: .
push: false
targets: x86-axcl
files: docker/axcl/x86-axcl.hcl
no-cache: true
set: |
x86-axcl.tags=frigate:${{ env.x86_AXCL_TAG }}

- name: Clean up disk space
run: |
docker system prune -f

- name: Save Docker image as tar file
run: |
docker save frigate:${{ env.x86_AXCL_TAG }} -o frigate-${{ env.x86_AXCL_TAG }}.tar
ls -lh frigate-${{ env.x86_AXCL_TAG }}.tar

- name: Upload Docker image artifact
uses: actions/upload-artifact@v4
with:
name: x86-axcl-docker-image
path: frigate-${{ env.x86_AXCL_TAG }}.tar
retention-days: 7

rk_axcl_builds:
runs-on: ubuntu-22.04-arm
name: rk_AXCL Build
steps:
- name: Check out code
uses: actions/checkout@v4
with:
persist-credentials: false

- name: Set RK_AXCL_TAG
run: echo "RK_AXCL_TAG=rk-axcl-${GITHUB_SHA:0:7}" >> $GITHUB_ENV

- name: Set Version
run: make version

- name: Build
uses: docker/bake-action@v6
with:
source: .
push: false
targets: rk-axcl
files: |
docker/rockchip/rk.hcl
docker/axcl/rk-axcl.hcl
no-cache: true
set: |
rk-axcl.tags=frigate:${{ env.RK_AXCL_TAG }}

- name: Clean up disk space
run: |
docker system prune -f

- name: Save Docker image as tar file
run: |
docker save frigate:${{ env.RK_AXCL_TAG }} -o frigate-${{ env.RK_AXCL_TAG }}.tar
ls -lh frigate-${{ env.RK_AXCL_TAG }}.tar

- name: Upload Docker image artifact
uses: actions/upload-artifact@v4
with:
name: rk-axcl-docker-image
path: frigate-${{ env.RK_AXCL_TAG }}.tar
retention-days: 7


rpi_axcl_builds:
runs-on: ubuntu-22.04-arm
name: RPi_AXCL Build
steps:
- name: Check out code
uses: actions/checkout@v4
with:
persist-credentials: false

- name: Set RPi_AXCL_TAG
run: echo "RPi_AXCL_TAG=rpi-axcl-${GITHUB_SHA:0:7}" >> $GITHUB_ENV

- name: Set Version
run: make version

- name: Build
uses: docker/bake-action@v6
with:
source: .
push: false
targets: rpi-axcl
files: |
docker/rpi/rpi.hcl
docker/axcl/rpi-axcl.hcl
no-cache: true
set: |
rpi-axcl.tags=frigate:${{ env.RPi_AXCL_TAG }}

- name: Clean up disk space
run: |
docker system prune -f

- name: Save Docker image as tar file
run: |
docker save frigate:${{ env.RPi_AXCL_TAG }} -o frigate-${{ env.RPi_AXCL_TAG }}.tar
ls -lh frigate-${{ env.RPi_AXCL_TAG }}.tar

- name: Upload Docker image artifact
uses: actions/upload-artifact@v4
with:
name: rpi-axcl-docker-image
path: frigate-${{ env.RPi_AXCL_TAG }}.tar
retention-days: 7
26 changes: 26 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -242,3 +242,29 @@ jobs:
sources: |
ghcr.io/${{ steps.lowercaseRepo.outputs.lowercase }}:${{ env.SHORT_SHA }}-amd64
ghcr.io/${{ steps.lowercaseRepo.outputs.lowercase }}:${{ env.SHORT_SHA }}-rpi
axera_build:
runs-on: ubuntu-22.04
name: AXERA Build
needs:
- amd64_build
- arm64_build
steps:
- name: Check out code
uses: actions/checkout@v5
with:
persist-credentials: false
- name: Set up QEMU and Buildx
id: setup
uses: ./.github/actions/setup
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Axera build
uses: docker/bake-action@v6
with:
source: .
push: true
targets: axcl
files: docker/axcl/axcl.hcl
set: |
axcl.tags=${{ steps.setup.outputs.image-name }}-axcl
*.cache-from=type=gha
25 changes: 25 additions & 0 deletions docker/axcl/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# syntax=docker/dockerfile:1.6

# https://askubuntu.com/questions/972516/debian-frontend-environment-variable
ARG DEBIAN_FRONTEND=noninteractive

# Globally set pip break-system-packages option to avoid having to specify it every time
ARG PIP_BREAK_SYSTEM_PACKAGES=1

FROM frigate AS frigate-axcl
ARG TARGETARCH
ARG PIP_BREAK_SYSTEM_PACKAGES

# Install axpyengine
RUN wget https://github.com/AXERA-TECH/pyaxengine/releases/download/0.1.3.rc1/axengine-0.1.3-py3-none-any.whl -O /axengine-0.1.3-py3-none-any.whl
RUN pip3 install -i https://mirrors.aliyun.com/pypi/simple/ /axengine-0.1.3-py3-none-any.whl \
&& rm /axengine-0.1.3-py3-none-any.whl

# Set ldconfig path
RUN echo "/usr/lib/axcl" > /etc/ld.so.conf.d/ax.conf

# Set env
ENV PATH="$PATH:/usr/bin/axcl"
ENV LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/lib/axcl"

ENTRYPOINT ["sh", "-c", "ldconfig && exec /init"]
13 changes: 13 additions & 0 deletions docker/axcl/axcl.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
target frigate {
dockerfile = "docker/main/Dockerfile"
platforms = ["linux/amd64", "linux/arm64"]
target = "frigate"
}

target axcl {
dockerfile = "docker/axcl/Dockerfile"
contexts = {
frigate = "target:frigate",
}
platforms = ["linux/amd64", "linux/arm64"]
}
15 changes: 15 additions & 0 deletions docker/axcl/axcl.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
BOARDS += axcl

local-axcl: version
docker buildx bake --file=docker/axcl/axcl.hcl axcl \
--set axcl.tags=frigate:latest-axcl \
--load

build-axcl: version
docker buildx bake --file=docker/axcl/axcl.hcl axcl \
--set axcl.tags=$(IMAGE_REPO):${GITHUB_REF_NAME}-$(COMMIT_HASH)-axcl

push-axcl: build-axcl
docker buildx bake --file=docker/axcl/axcl.hcl axcl \
--set axcl.tags=$(IMAGE_REPO):${GITHUB_REF_NAME}-$(COMMIT_HASH)-axcl \
--push
7 changes: 7 additions & 0 deletions docker/axcl/rk-axcl.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
target rk-axcl {
dockerfile = "docker/axcl/Dockerfile"
contexts = {
frigate = "target:rk",
}
platforms = ["linux/arm64"]
}
7 changes: 7 additions & 0 deletions docker/axcl/rpi-axcl.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
target rpi-axcl {
dockerfile = "docker/axcl/Dockerfile"
contexts = {
frigate = "target:rpi",
}
platforms = ["linux/arm64"]
}
110 changes: 110 additions & 0 deletions docker/axcl/user_installation.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
#!/bin/bash

set -e

# Function to clean up on error
cleanup() {
echo "Cleaning up temporary files..."
rm -f "$deb_file"
}

trap cleanup ERR
trap 'echo "Script interrupted by user (Ctrl+C)"; cleanup; exit 130' INT

# Update package list and install dependencies
echo "Updating package list and installing dependencies..."
sudo apt-get update
sudo apt-get install -y build-essential cmake git wget pciutils kmod udev

# Check if gcc-12 is needed
echo "Checking GCC version..."
current_gcc_version=$(gcc --version | head -n1 | awk '{print $NF}')
if ! dpkg --compare-versions "$current_gcc_version" ge "12" 2>/dev/null; then
echo "Current GCC version ($current_gcc_version) is lower than 12, installing gcc-12..."
sudo apt-get install -y gcc-12
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-12 12
echo "GCC-12 installed and set as default"
else
echo "Current GCC version ($current_gcc_version) is sufficient, skipping GCC installation"
fi

# Determine architecture
echo "Determining system architecture..."
arch=$(uname -m)
download_url=""

if [[ $arch == "x86_64" ]]; then
download_url="https://github.com/ivanshi1108/assets/releases/download/v0.17/axcl_host_x86_64_V3.10.2_20251111020143_NO5046.deb"
deb_file="axcl.deb"
elif [[ $arch == "aarch64" ]]; then
download_url="https://github.com/ivanshi1108/assets/releases/download/v0.17/axcl_host_aarch64_V3.10.2_20251111020143_NO5046.deb"
deb_file="axcl.deb"
else
echo "Unsupported architecture: $arch"
exit 1
fi

# Check for required Linux headers before downloading
echo "Checking for required Linux headers..."
kernel_version=$(uname -r)
if dpkg -l | grep -q "linux-headers-${kernel_version}" || [ -d "/lib/modules/${kernel_version}/build" ]; then
echo "Linux headers or kernel modules directory found for kernel ${kernel_version}/build."
else
echo "Linux headers for kernel ${kernel_version} not found. Please install them first: sudo apt-get install linux-headers-${kernel_version}"
exit 1
fi

# Download AXCL driver
echo "Downloading AXCL driver for $arch..."
wget --timeout=30 --tries=3 "$download_url" -O "$deb_file"

if [ $? -ne 0 ]; then
echo "Failed to download AXCL driver after retries"
exit 1
fi

# Install AXCL driver
echo "Installing AXCL driver..."
sudo dpkg -i "$deb_file"

if [ $? -ne 0 ]; then
echo "Failed to install AXCL driver, attempting to fix dependencies..."
sudo apt-get install -f -y
sudo dpkg -i "$deb_file"

if [ $? -ne 0 ]; then
echo "AXCL driver installation failed after dependency fix"
exit 1
fi
fi

# Update environment
echo "Updating environment..."
source /etc/profile

# Verify installation
echo "Verifying AXCL installation..."
if command -v axcl-smi &> /dev/null; then
echo "AXCL driver detected, checking AI accelerator status..."

axcl_output=$(axcl-smi 2>&1)
axcl_exit_code=$?

echo "$axcl_output"

if [ $axcl_exit_code -eq 0 ]; then
echo "AXCL driver installation completed successfully!"
else
echo "AXCL driver installed but no AI accelerator detected or communication failed."
echo "Please check if the AI accelerator is properly connected and powered on."
exit 1
fi
else
echo "axcl-smi command not found. AXCL driver installation may have failed."
exit 1
fi

# Clean up
echo "Cleaning up temporary files..."
rm -f "$deb_file"
echo "Installation script completed."
13 changes: 13 additions & 0 deletions docker/axcl/x86-axcl.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
target frigate {
dockerfile = "docker/main/Dockerfile"
platforms = ["linux/amd64"]
target = "frigate"
}

target x86-axcl {
dockerfile = "docker/axcl/Dockerfile"
contexts = {
frigate = "target:frigate",
}
platforms = ["linux/amd64"]
}
2 changes: 1 addition & 1 deletion docs/docs/frigate/hardware.md
Original file line number Diff line number Diff line change
Expand Up @@ -321,4 +321,4 @@ Basically - When you increase the resolution and/or the frame rate of the stream

YES! The Coral does not help with decoding video streams.

Decompressing video streams takes a significant amount of CPU power. Video compression uses key frames (also known as I-frames) to send a full frame in the video stream. The following frames only include the difference from the key frame, and the CPU has to compile each frame by merging the differences with the key frame. [More detailed explanation](https://support.video.ibm.com/hc/en-us/articles/18106203580316-Keyframes-InterFrame-Video-Compression). Higher resolutions and frame rates mean more processing power is needed to decode the video stream, so try and set them on the camera to avoid unnecessary decoding work.
Decompressing video streams takes a significant amount of CPU power. Video compression uses key frames (also known as I-frames) to send a full frame in the video stream. The following frames only include the difference from the key frame, and the CPU has to compile each frame by merging the differences with the key frame. [More detailed explanation](https://support.video.ibm.com/hc/en-us/articles/18106203580316-Keyframes-InterFrame-Video-Compression). Higher resolutions and frame rates mean more processing power is needed to decode the video stream, so try and set them on the camera to avoid unnecessary decoding work.
1 change: 1 addition & 0 deletions frigate/config/classification.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
class SemanticSearchModelEnum(str, Enum):
jinav1 = "jinav1"
jinav2 = "jinav2"
ax_jinav2 = "ax_jinav2"


class EnrichmentsDeviceEnum(str, Enum):
Expand Down
Loading
Loading