Google Coral LXC Frigate Setup
Installing and using a Google Coral B+M Key Edge TPU

Gotta love Google.
Not only do they make a nice machine learning chip which is essentially a black box of magic, but also their drivers are old and their install docs suck. Seriously, though, no one but Coral and Google know how the silicon works.
A preface: I run the most excellent Frigate NVR to gather my cctv streams in one place and retain footage of people and animals. The detection part is what requires the Google Coral ML accelerator. This could be done with a GPU, but I don't have one on my current setup and the Coral achieves amazing inference speeds per watt, much less electricity to do the same thing a GPU could.
I've done this whole thing before, about a year ago. Of course, I've completely forgotten the ins and outs of setting up the apex drivers for the coral on my old server, so this post acts as a how-to for myself, as much as anything.
Google's Instructions
A normal person would start at Coral's own linux install docs.
echo "deb https://packages.cloud.google.com/apt coral-edgetpu-stable main" | tee /etc/apt/sources.list.d/coral-edgetpu.list
curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add -
apt update
Superfluous sudo and apt-get commands removed, since I'm on a root system and apt-get is so 2009.
apt install gasket-dkms libedgetpu1-std
sh -c "echo 'SUBSYSTEM==\"apex\", MODE=\"0660\", GROUP=\"apex\"' >> /etc/udev/rules.d/65-apex.rules"
groupadd apex
adduser $USER apex
Reboot. The command
lspci -nn | grep 089a
should show something like
03:00.0 System peripheral: Device 1ac1:089a
Jack Barry's Instructions
The last line of Google's instructions is a big let down, because there is no /dev/apex_0 device after carrying them out.
This person documented exactly the issue I was having with my Coral driver install, particularly the part that yields nothing when looking for /dev/apex_0, which turns out to be a very dumb issue of not having kernel headers installed:
apt install pve-headers
which of course needs a reboot.
I didn't indicate this above, but problems immediately arise trying to install gasket-dkms, it just bails out with an unceremonious build script error.
This is because the gasket drivers in the above google repo have not been updated in several years and something in the build environment of a 6.8.12-8 kernel doesn't like the dkms module build scripts. According to this github issue, the gasket-dkms issue arose around the time of linux kernel 6.5.0, which puts the age of Coral's awful instructions at at least Aug 2023.
Newer gasket Driver
I say "new" with some sarcasm, because Google's latest commit to gasket is 10.... Yes, 10 months ago as of this writing. A whole diatribe on Google's abandoned services can be found in any number of youtuber channels, I won't waste your time with gasps and outrage here about it.
A number of people seem to have reported this, because the github issue above is full of the same complaint. One needs to pull the latest gasket driver from Google's gasket git and build an install package. In my case, that's a .deb.
apt install devscripts debhelper git
git clone https://github.com/google/gasket-driver.git
cd gasket-driver/
debuild -us -uc -tc -b
ls -l gasket-dkms*deb
The last line should show there to be a freshly-built gasket .deb package, which we can now install:
dpkg -i gasket-dkms_1.0-18_all.deb
I can now rebuild my Frigate container, but I'll save that for the next post.
(I Hate) Conclusions
I don't like to end articles with literal conclusion sections, it seems like too much exposition. Show, don't tell, you know?
However, this must be said: Google's coral drivers are a PITA. If we had any alternative for neural net ML hardware, I'd have gone with that option. But WOW, what a clustercuss.