Use Frigate and Coral Usb Accelerator in Synology NAS

After long time wating, my google coral usb accelerate finally arrived. A quick glance of my old setup for object detection using security cameras. (ref: Complete Home Automation Setup)

  • An Intel NUC i5 bare box running frigate docker
    • CPU detector
  • Black Synology w/ DSM 7.1 running on a i5 custom build box with 6 HDDs & 1 SSD for cache.
  • Home Assistant docker container running in DSM 7.1

The obvious drawback of the above configuration is the performance bottleneck caused by the slow CPU detector in the NUC i5. Although it does the job, adding more security cameras to the network could seriously impact the overall detection rate.

The Google Coral USB accelerator is a USB accessory featuring the Edge TPU that brings ML inferencing to existing systems. We could leave the heavy-lifting work to Coral and only let the CPU does the ffmpeg encoding work, which dramatically improves the performance of home automation.

The docker compose file is pretty much the same as old one, except one tricky part: specifying the usb device in the volume section as /dev/bus/usb:/dev/bus/usb

 1  frigate:
 2    container_name: frigate
 3    privileged: true # this may not be necessary for all setups
 4    restart: unless-stopped
 5    image: ghcr.io/blakeblackshear/frigate:stable
 6    shm_size: "128mb" # update for your cameras based on calculation above
 7    devices:
 8      - /dev/bus/usb:/dev/bus/usb # passes the USB Coral, needs to be modified for other versions
 9      # - /dev/apex_0:/dev/apex_0 # passes a PCIe Coral, follow driver instructions here https://coral.ai/docs/m2/get-started/#2a-on-linux
10      # - /dev/dri/renderD128 # for intel hwaccel, needs to be updated for your hardware
11    volumes:
12      - /etc/localtime:/etc/localtime:ro
13      - ${USERDIR}/frigate/config.yml:/config/config.yml:ro
14      - ${USERDIR}/frigate/db:/database
15      - ${USERDIR}/frigate/media:/media/frigate
16      - /dev/bus/usb:/dev/bus/usb
17      - type: tmpfs # Optional: 1GB of memory, reduces SSD/SD Card wear
18        target: /tmp/cache
19        tmpfs:
20          size: 1000000000
21    ports:
22      - "5050:5000"
23      - "1935:1935" # RTMP feeds
24    environment:
25      FRIGATE_RTSP_PASSWORD: ${FRIGATE_RTSP_PASSWORD}

Now I have successfully migrated my frigate container from the NUC to the Synology NAS. Sweet! Look at the container list, my synology box is working really hard.

Synology Docker Container List

comments powered by Disqus

Translations: