mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-07-14 16:01:13 +03:00
Adds a community-supported hardware detector for the Qualcomm Hexagon NPU on QCS6490 SoCs (e.g. Radxa Dragon Q6A) via QAIRT 2.37.1 / qai_appbuilder. Mirrors the existing community-board pattern (Rockchip / Synaptics): - frigate/detectors/plugins/qnn.py: detector plugin using yolo-generic model type, lazy SDK import, runs pre-compiled QNN context binaries from Qualcomm AI Hub. - docker/qcs6490/: Dockerfile (two-stage; rebuilds qai_appbuilder wheel inside Frigate's image to match libstdc++ ABI), bake target (qcs6490.hcl), make targets (qcs6490.mk), and a host-side user_installation.sh that installs fastrpc, the QCS6490 firmware (cDSP image + skel libs), and configures cdsprpcd. - .github/workflows/ci.yml: qcs6490_build job mirroring synaptics_build. - CODEOWNERS: /docker/qcs6490/ + qnn.py. - docs: new "Qualcomm Hexagon NPU" sections under Community Supported Detectors in object_detectors.md, plus matching entries in installation.md and hardware.md. Performance on Radxa Dragon Q6A (Hexagon v68, ~12 TOPS), YOLOv8n 640x640: ~10ms per inference under light load, ~24ms with 5 RTSP cameras live. Closes #18602.
90 lines
3.1 KiB
Bash
Executable File
90 lines
3.1 KiB
Bash
Executable File
#!/bin/bash
|
|
#
|
|
# Host-side setup for the Qualcomm Hexagon NPU detector on a Radxa Dragon Q6A
|
|
# (or other QCS6490 board). Installs:
|
|
# - fastrpc user-space (libcdsprpc.so, cdsprpcd, fastrpc_test)
|
|
# - Radxa firmware that ships the cDSP image + skel libs the QNN HTP
|
|
# backend dlopens at runtime
|
|
# - a transient cdsprpcd systemd service
|
|
# and disables hexagonrpcd, which holds the fastrpc devices and conflicts.
|
|
#
|
|
# Run with sudo. Logs out + back in are required for the fastrpc group to
|
|
# take effect for your user.
|
|
|
|
set -euo pipefail
|
|
|
|
if [ "$EUID" -ne 0 ]; then
|
|
echo "Please run as root (sudo $0)"
|
|
exit 1
|
|
fi
|
|
|
|
ARCH=$(dpkg --print-architecture)
|
|
if [ "$ARCH" != "arm64" ]; then
|
|
echo "This script targets arm64 (QCS6490). Detected: $ARCH"
|
|
exit 1
|
|
fi
|
|
|
|
apt-get update
|
|
apt-get install -y --no-install-recommends ca-certificates curl
|
|
|
|
WORKDIR=$(mktemp -d)
|
|
trap 'rm -rf "$WORKDIR"' EXIT
|
|
|
|
# fastrpc user-space (provides libcdsprpc.so + cdsprpcd). Not in apt.
|
|
FASTRPC_VER=1.0.4-1
|
|
echo "==> Installing fastrpc ${FASTRPC_VER}"
|
|
for pkg in fastrpc fastrpc-tools; do
|
|
curl -fsSL -o "${WORKDIR}/${pkg}.deb" \
|
|
"https://github.com/radxa-pkg/fastrpc/releases/download/${FASTRPC_VER}/${pkg}_${FASTRPC_VER}_arm64.deb"
|
|
done
|
|
apt-get install -y "${WORKDIR}/fastrpc.deb" "${WORKDIR}/fastrpc-tools.deb"
|
|
|
|
# Radxa QCS6490 firmware (provides /usr/lib/dsp/cdsp/{cdsp.mbn,*_skel.so,...}
|
|
# and /usr/lib/rfsa/adsp/, both required by the cDSP at runtime).
|
|
RADXA_FW_VER=0.2.29
|
|
echo "==> Installing radxa-firmware-qcs6490 ${RADXA_FW_VER}"
|
|
curl -fsSL -o "${WORKDIR}/radxa-firmware-qcs6490.deb" \
|
|
"https://github.com/radxa-pkg/radxa-firmware/releases/download/${RADXA_FW_VER}/radxa-firmware-qcs6490_${RADXA_FW_VER}_all.deb"
|
|
apt-get install -y "${WORKDIR}/radxa-firmware-qcs6490.deb"
|
|
|
|
# hexagonrpcd from the apt 'hexagonrpcd' package conflicts with cdsprpcd by
|
|
# holding /dev/fastrpc-* exclusively. We need cdsprpcd for QNN HTP.
|
|
echo "==> Disabling conflicting hexagonrpcd services"
|
|
for unit in hexagonrpcd hexagonrpcd-suspend hexagonrpcd-resume; do
|
|
systemctl disable --now "${unit}" 2>/dev/null || true
|
|
done
|
|
|
|
echo "==> Enabling cdsprpcd"
|
|
cat >/etc/systemd/system/cdsprpcd.service <<'UNIT'
|
|
[Unit]
|
|
Description=Qualcomm cDSP FastRPC daemon
|
|
After=local-fs.target
|
|
|
|
[Service]
|
|
Type=simple
|
|
ExecStart=/usr/bin/cdsprpcd
|
|
Restart=always
|
|
|
|
[Install]
|
|
WantedBy=multi-user.target
|
|
UNIT
|
|
systemctl daemon-reload
|
|
systemctl enable --now cdsprpcd
|
|
|
|
# Allow non-root containers + users to open /dev/fastrpc-*.
|
|
echo "==> Adding invoking user to fastrpc group"
|
|
TARGET_USER="${SUDO_USER:-$USER}"
|
|
if [ -n "${TARGET_USER}" ] && id "${TARGET_USER}" >/dev/null 2>&1; then
|
|
usermod -aG fastrpc "${TARGET_USER}"
|
|
fi
|
|
|
|
echo
|
|
echo "Hexagon NPU host setup complete."
|
|
echo "Log out and back in for fastrpc group membership to take effect, then:"
|
|
echo " docker run ... ghcr.io/blakeblackshear/frigate:stable-qcs6490"
|
|
echo "Pass these to the container (devices, group, env):"
|
|
echo " --device /dev/fastrpc-cdsp --device /dev/fastrpc-cdsp-secure"
|
|
echo " --device /dev/fastrpc-adsp --device /dev/dma_heap/system"
|
|
echo " --group-add \$(getent group fastrpc | cut -d: -f3)"
|
|
echo " -v /usr/lib/dsp:/usr/lib/dsp:ro -v /usr/lib/rfsa:/usr/lib/rfsa:ro"
|