Frigate + Coral USB + Proxmox

Hello,

This is yet another post explaining how to set up Coral USB on a LXC container. This is based on my findings after fighting this for days and following tutorials that didn’t end up working for my case.

A few notes

  • This tutorial will show how to run Frigate “natively” (i.e. without Docker) in an unprivileged LXC container. To be honest, running it inside Docker may be easier, but I find this way more interesting for learning purposes.
  • I won’t cover Home Assistant integration because I assume you have that already working.
  • This will work after a reboot, where the USB device id can change.

Creating the container

I just used Proxmox VE Helper-Scripts to create the initial container setup. Don’t worry too much about the configuration options, because we’ll going to change them later. Just run the script and you should have a container ready and running, but with CPU detection.

Install Coral USB in the host system

Basically follow this until you have it working.

Prepare the host system

There are a few changes you have to make in the host system.

  1. Create a group with id 100000. By default LXC containers run with uid/gid 100000/100000. Coral USB will not work with the default permissions. Run:

    groupadd -g 100000 lxc-frigate-root
    
  2. Configure udev. By default Coral setup will create /etc/udev/rules.d/71-edgetpu.rules, change it so it looks like this (the important part is to add the GROUP:

    SUBSYSTEMS=="usb", ATTRS{idVendor}=="1a6e", ATTRS{idProduct}=="089a", MODE="0664", GROUP="lxc-frigate-root"
    SUBSYSTEMS=="usb", ATTRS{idVendor}=="18d1", ATTRS{idProduct}=="9302", MODE="0664", GROUP="lxc-frigate-root"
    
  3. Restart udev:

    udevadm control --reload-rules && udevadm trigger
    
  4. Verify it is working. First find the bus and device ID of your Coral USB:

    lsusb
    
    Bus 002 Device 005: ID 18d1:9302 Google Inc.
    
  5. Check the permissions for that file in the /dev filesystem:

    ls -la /dev/bus/usb/002/005
    
    crw-rw-r-- 1 root lxc-frigate-root 189, 132 Jul 23 12:09 /dev/bus/usb/002/005
    

    It should belong to group lxc-frigate-root.

Prepare the container

  1. Edit the container config (usually in /etc/pve/lxc/<id>.conf) to add these lines (adjust the path to match your USB bus):

    lxc.mount.entry: /dev/bus/usb dev/bus/usb none bind,create=dir
    lxc.cgroup2.devices.allow: c 189:* rwm
    
  2. Configure frigate to use Coral USB detector. You can use the UI or edit the file /config/config.yaml:

    detectors:
      coral:
        type: edgetpu
        device: usb
    

Verify it works

  1. Start the container with pct start <id>

  2. Open a shell to it with pct enter <id>

  3. Check the USB permissions:

    ls -la /dev/bus/usb/002/005
    crw-rw-r-- 1 nobody root 189, 132 Jul 23 12:25 /dev/bus/usb/002/005
    

    Note that device 005 was mounted, and it belongs to group root. If it belongs to nogroup, then you had the group mapping wrong.

    Do not use lsusb to verify it works. lsusb will list all USB devices of the host (even when run inside the container), even if they are not properly mounted in the container.

  4. Start frigate and check the logs:

    [2024-07-23 12:19:09] frigate.detectors.plugins.edgetpu_tfl INFO    : Attempting to    load TPU as usb
    [2024-07-23 12:19:12] frigate.detectors.plugins.edgetpu_tfl INFO    : TPU found
    

And I think that’s it. I hope you find it useful. Please do let me know if there is a mistake or missing info, I’ll add it.

8 Likes

Hi,

I’ve used the script as well (the owner has archived his repository by the way) and it works great. I have my Coral TPU working as well. Flaweless and superfast. Never had this performance on my RPi4.

Question: Where is the file where you mount an extra drive and set the Frigate+ credentials? Normaly that is in docker-compose.yml but as it is no longer running in docker that seems odd.

Can you help me out?

I’d love an answer to this too.

FYI the developer, tteck, archived his helper script repositories after graciously handing the project off just before he passed away. You can find his scripts now being maintained here.

2 Likes

I’m trying to add a Coral USB to my Proxmox server. After following the Coral guide to update it, I expected to see “Google” when running the lsusb command. However, it still shows “Global Unichip Corp.” instead.
Is this a critical issue?

@Martin_de_Bes @HappyCadaver

I don’t use Frigate+, so I’m not 100% sure.

But checking the docs looks like you can pass env variables in the container config.

I think you need to edit the container config (usually /etc/pve/lxc/<id>.conf) and add a line like:

lxc.environment = PLUS_API_KEY =your_api_key

I hope it works.

I think it is fine. Found a GitHub issue where they say that the name changes after the first successful detection, but others say they still have the Unichip name and it works without problems.

For reference: Coral USB changing ID and Vendor · Issue #536 · google-coral/edgetpu · GitHub

Install Coral USB in the host system

echo "deb https://packages.cloud.google.com/apt coral-edgetpu-stable main" | sudo tee /etc/apt/sources.list.d/coral-edgetpu.list

curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -

sudo apt-get update

do I have to type that in one-by-one?

Do you mean the LXC Container with that or the Node?

So do I have to edit those changes on the LXC Container of Frigate?

I do understand with that to edit it on my host system ( which is my Node 1 ) proxmox1

Next question

Configure udev. By default Coral setup will create /etc/udev/rules.d/71-edgetpu.rules, change it so it looks like this (the important part is to add the GROUP:

How can I configure udev? Do I need to go via nano in that rules File or?

I have the rules.d Folder but not the 71-edgetpu.rules in it.

Thankful for any help as I want to learn and get this rolled out.

So appreciate any help.

You copy+paste the first line, execute it (press enter), wait for it to finish, then copy+paste the second line, execute it… and so on.

Correct, you make those changes in the Host system, the computer where you installed Proxmox. Also called a Node.

You either edit an existing file (any) in /etc/udev/rules.d/ and make the changes, or create a new file inside /etc/udev/rules.d/. The file name has to end with .rules for it to work. For example, nano /etc/udev/rules.d/edgetpu.rules, type in the config and save it. The actual name doesn’t matter as long as it is inside /etc/udev/rules.d/ and ends with .rules.

Configure frigate to use Coral USB detector. You can use the UI or edit the file

how to use the UI to config this?

I’m trying this. Stuck on step one.

Proxmox noob. Got a mini PC and coral just for frigate. I might be in over my head. Used the new comunity scripts to install frigate. Stuck on the coral usage. I’ll gladly provide any other info, if anyone is willing to help.

It’s complaining that you don’t have sudo installed. Either install sudo (ask ChatGPT: ChatGPT - Install sudo in Linux), or just remove the word sudo from the command you entered.

Oh my. I’m sorry for such a dumb question. I’ll do that right now. I never thought I needed to install sudo. As you can probably tell, I’m a windows native. Linux as a second language, A2 level at best. Thank you so much.

It’s great that you are sharing this project so others can benefit from it as well.
Also, helping @Balu with that sudo issue: :+1:

But… what is wrong with using just a simple, good old, websearch to find out how to install something and instead using ChatGPT?!? :man_facepalming:
Are you aware how much energy is used for that compared to a simple websearch?

Sorry, but no sorry: I couldn’t resist.

2 Likes

My country uses nearly 100% renewable energy, so it’s just money. If it make’s it easier, don’t care how much energy it costs.

You dont need sudo when you are root.

@scinos Do you have an extra 0 in the groupadd command?

You mention 10000, but the command has 100000 (an extra zero)?

Can you advise the correct value, please?

@MonkeyJug, it should be 100000, with 5 zeros. I’ll edit the post to use the correct value, thanks!

For reference, there is more info abou uid/gid in Understanding LXC user/group mapping - kcore.org

1 Like

@scinos

I have done all the step, and where you have:

ls -la /dev/bus/usb/002/005
crw-rw-r-- 1 nobody root 189, 132 Jul 23 12:25 /dev/bus/usb/002/005

I have the group created lxc-frigate-root:

ls -la /dev/bus/usb/002/003
crw-rw-r-- 1 root lxc-frigate-root 189, 130 May 22 19:34 /dev/bus/usb/002/003

and in the the frigate i have:


2025-05-22 19:33:52     frigate.detectors.plugins.edgetpu_tfl    Attempting to load TPU as usb
2025-05-22 19:33:55     frigate.detectors.plugins.edgetpu_tfl    TPU found

i can see changes on Detector CPU Usage, but not in the detector speed

But still very high detection time.
imagem

Why?
I only have two cameras.

It has been a while since I looked at this, so take this comment with a grain of salt.

Those are two separate things:

Outside the container (i.e. in the host, where you installed Proxmox) the file should belong to root:lxc-frigate-root. But inside the container, it should belong to either root:<anything> or <anything>:root

Try this inside the container (i.e. from inside pct enter <id>).

  1. Check which user is running frigate. Run ps faux | grep frigate and check the first column (mine is root).
$ ps faux | grep frigate
root         110  0.0  0.0   6900   256 ?        ...
  1. Check the groups of that user. Run groups <user>
$ groups root
root : root video render
  1. Verify that the dev device belongs to one of those groups.
$ ls -la /dev/bus/usb/002/003
crw-rw-r-- 1 nobody root 189, 130 May 22 23:16 /dev/bus/usb/002/003

Thanks for the support @scinos

I’m not too much knowledge of proxmox.

Mine is also root:

root@frigate:~# ps faux | grep frigate
root       16835  0.0  0.0   6212 

in groups i have:

root@frigate:~# groups root
root : root render

and i have:

root@frigate:~# ls -la /dev/bus/usb/002/003
crw-rw-r-- 1 root lxc-frigate-root 189, 130 May 22 23:00 /dev/bus/usb/002/003

is this ok?

1 Like