Frigate is an open-source NVR that does real-time object detection on your security cameras. I had an old NVIDIA GTX 750 Ti (2 GB) sitting in my Proxmox server and wanted Frigate to actually use it. This post covers the setup that finally worked, and the config files are all in the repo.
My setup
- Host: Proxmox → Debian LXC → Docker
- RAM: 18 GB given to the container
- GPU: NVIDIA GTX 750 Ti, 2 GB
- Storage: an SSD passed from the host into the LXC and then into Docker for recordings
Why not the ready-made LXC?
I first tried the Frigate LXC template from the Proxmox helper scripts. It ran, but the GPU sat at about 2% usage while the CPU did all the work. To use the card properly I started again with a plain Debian LXC and set up the NVIDIA runtime and Docker myself.
Step 1: NVIDIA on the Proxmox host
Install the NVIDIA driver on the Proxmox host first. There are many tutorials; this one worked for me.
Step 2: a Debian LXC with the GPU passed through
I created the container with the Debian community script, then edited its config to pass the NVIDIA and render devices through. The key lines are:
features: nesting=1
lxc.cgroup2.devices.allow: c 195:* rwm
lxc.cgroup2.devices.allow: c 237:* rwm
lxc.cgroup2.devices.allow: c 226:0 rwm
lxc.cgroup2.devices.allow: c 226:128 rwm
lxc.mount.entry: /dev/nvidia0 dev/nvidia0 none bind,optional,create=file
lxc.mount.entry: /dev/nvidiactl dev/nvidiactl none bind,optional,create=file
lxc.mount.entry: /dev/nvidia-modeset dev/nvidia-modeset none bind,optional,create=file
lxc.mount.entry: /dev/nvidia-uvm dev/nvidia-uvm none bind,optional,create=file
lxc.mount.entry: /dev/nvidia-uvm-tools dev/nvidia-uvm-tools none bind,optional,create=file
lxc.mount.entry: /dev/dri dev/dri none bind,optional,create=dir
The full file, including the recording-SSD mount point, is proxmox.lxc.conf in the repo.
Step 3: the NVIDIA runtime inside Debian
The preferred way is to let the NVIDIA Container Toolkit configure the runtime:
sudo nvidia-ctk runtime configure --runtime=containerd
If that doesn't work for you, install the matching driver manually with .run installer from the NVIDIA site:
mkdir downloads && cd downloads
wget "https://us.download.nvidia.com/XFree86/Linux-x86_64/570.124.04/NVIDIA-Linux-x86_64-570.124.04.run"
chmod +x NVIDIA-Linux-x86_64-570.124.04.run
sudo bash NVIDIA-Linux-x86_64-570.124.04.run
Step 4: Frigate with Docker Compose
I tried several compose files before landing on this one. The important parts are the stable-tensorrt image, the nvidia runtime, and the YOLO models to build on first start:
services:
frigate:
container_name: frigate
restart: unless-stopped
image: ghcr.io/blakeblackshear/frigate:stable-tensorrt
runtime: nvidia
environment:
- NVIDIA_VISIBLE_DEVICES=all
- NVIDIA_DRIVER_CAPABILITIES=compute,utility,video
- YOLO_MODELS=yolov7-320,yolov7-640
- USE_FP16=false
volumes:
- ./config:/config/
- /dev/dri:/dev/dri
- /ssdtank/frigate:/media/frigate
- /opt/frigate/logs:/var/log/frigate
- type: tmpfs
target: /tmp/cache
tmpfs:
size: 6g
shm_size: 12g
ports:
- "5000:5000"
- "8554:8554"
- "8555:8555/tcp"
- "8555:8555/udp"
USE_FP16=false matters on this card: the 750 Ti is a Maxwell GPU without fast half-precision, so the models are built in FP32.
Step 5: the Frigate config
Inside Frigate, point the detector at the GPU with TensorRT, use the YOLOv7 320 model, and turn on NVIDIA decoding for the camera streams:
detectors:
tensorrt:
type: tensorrt
device: 0
model:
path: /config/model_cache/tensorrt/yolov7-320.trt
input_tensor: nchw
input_pixel_format: rgb
width: 320
height: 320
ffmpeg:
hwaccel_args: preset-nvidia
input_args: preset-rtsp-generic
The full frigate.config.yaml also covers MQTT, Birdseye, detection and recording retention.
Result
With this setup the GTX 750 Ti handles both video decoding and object detection, instead of idling at 2% while the CPU struggles. It is a nice second life for a graphics card that is more than ten years old.
Comments
Post a Comment