Proxmox / Debian 12 LXC / CodeProject.ai / Coral usb TPU : My working setup !

tlex

Member
Mar 9, 2021
103
14
23
43
Taught this could help others as I found it difficult to setup !

I've been using the typical "Proxmox / LXC / Docker / Codeproject" with Coral TPU usb passthough setup but it's been unreliable (at least for me) and the boot process is pretty long. Not super usefull when used with blueiris for ai detection.

Now i've done a manual install of a fresh Debian 12 lxc and that works rock solid. Here is my deployments steps. Based on instructions I've found on a few forums.
The main issue I see with the docker setup is that it add some latency and for some reasons the connection with coral usb tpu drops from time to time. I didn't had that issue since I removed docker from the equation and it boot superfast.

# My install steps:

# Proxmox host config
groupadd -g 100000 Codeproject # Create container’s root group (100000)

# specific for Coral usb tpu
nano /etc/udev/rules.d/60-coraltpu.rules

Code:
SUBSYSTEMS=="usb", ATTRS{idVendor}=="18d1", ATTRS{idProduct}=="9302", GROUP="100000"
SUBSYSTEMS=="usb", ATTRS{idVendor}=="1a6e", ATTRS{idProduct}=="089a", GROUP="100000"

# lxc container creation
-Create unpriviledge lxc container
-debian 12 / 4 cores / 8gb storage / 4gb ram (4 cores needed for installation, ram and cpu can be reduced after the installation is completed)
-Configure network

# On the host, run lsusb to find on what bus your coral device is (Google Inc.):
lsusb
Code:
Bus 004 Device 002: ID 18d1:9302 Google Inc.


# Modify lxc config file based on client Coral usb module selection (add the following lines)

usb0: host=1a6e:089a,usb4=1 # coral ID pre-load // replace USB4 with selection
usb1: host=18d1:9302,usb4=1 # coral ID post-load // replace USB4 with selection
lxc.mount.entry: /dev/bus/usb/004 dev/bus/usb/004 none bind,optional,create=dir # Replace USB4 with selection

## In the container

# enable ssh
sed -i /"^PermitRootLogin.*$"/d /etc/ssh/sshd_config
echo "PermitRootLogin yes" >> /etc/ssh/sshd_config
systemctl restart sshd


# Grab ip and continue the setup with ssh
ip -c -4 -brief address show

# install required packages
wget https://packages.microsoft.com/config/debian/12/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
dpkg -i packages-microsoft-prod.deb
rm packages-microsoft-prod.deb
apt update
apt upgrade
apt install unzip dotnet-sdk-7.0 sudo psmisc curl xz-utils jq


# install codeproject
wget https://www.codeproject.com/KB/Articles/5322557/codeproject.ai-server_2.6.5_Ubuntu_x64.zip
unzip codeproject.ai-server_2.6.5_Ubuntu_x64.zip
rm codeproject.ai-server_2.6.5_Ubuntu_x64.zip
dpkg -i codeproject.ai-server_2.6.5_Ubuntu_x64.deb
rm codeproject.ai-server_2.6.5_Ubuntu_x64.deb
pushd "/usr/bin/codeproject.ai-server-2.6.5/" && bash start.sh && popd
cd /usr/bin/codeproject.ai-server-2.6.5 && bash start.sh

# Go to your browser and check the logs untils the installation is done. when nothing moves anymore you can kill the process in your ssh session !

# uninstall unused modules and install Coral module (it will fail but will point you to the script to run *this will take a while - 10-15mins):
cd /usr/bin/codeproject.ai-server-2.6.5/modules/ObjectDetectionCoral && sudo bash ../../setup.sh
# I had to kill the script in the end since it was not doing anything anymore but still show up as succeed. I think these scripts definitely need some cleanup !

# Enable the cpai service (I have no idea why they didn't enable it by default during the install)
systemctl enable codeproject.ai-server

# Enable coral module autostart (set autostart value to true)
nano /usr/bin/codeproject.ai-server-2.6.5/modules/ObjectDetectionCoral/modulesettings.json

# reboot and test, no more disconnect issues like when using the docker version

20ms response time with tiny objects :)
 
this is fine, but could you tell me how or where to find a procedure to correctly install google coral on promox 8.2.2? I installed the gasket drivers but with lsusb I still see Global Unichip and not Google Coral, I have tried various solutions by reading on various forums but until now Proxmox 8.2.2 does not see usb Google Coral correctly. This is a new installation done on a Beelink S12 N100

Code:
root@promoxserver:~# lsusb
Bus 002 Device 002: ID 1a6e:089a Global Unichip Corp.
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 002: ID 8087:0026 Intel Corp. AX201 Bluetooth
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
 
Last edited:
Thanks for this guide. FWIW I stared vanila without a gpu or tpu. I got error;
Code:
ImportError: libGL.so.1: cannot open shared object file: No such file or directory

I had to;
Bash:
apt install libgl1-mesa-dev
cd /usr/bin/codeproject.ai-server-2.6.5/modules/ObjectDetectionYOLOv5-6.2 && sudo bash ../../setup.sh

Works on my machine! : - )
 
this is fine, but could you tell me how or where to find a procedure to correctly install google coral on promox 8.2.2? I installed the gasket drivers but with lsusb I still see Global Unichip and not Google Coral, I have tried various solutions by reading on various forums but until now Proxmox 8.2.2 does not see usb Google Coral correctly. This is a new installation done on a Beelink S12 N100

Code:
root@promoxserver:~# lsusb
Bus 002 Device 002: ID 1a6e:089a Global Unichip Corp.
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 002: ID 8087:0026 Intel Corp. AX201 Bluetooth
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Well this is fine,
The name will change once the container initialize the module.
This is why you have :
usb0: host=1a6e:089a,usb4=1 # coral ID pre-load // replace USB4 with selection
usb1: host=18d1:9302,usb4=1 # coral ID post-load // replace USB4 with selection
 
Good tutorial. Maybe tag it with [TUTORIAL] (right-hand corner edit under title thread name).
 
hi there,
first of all, thanks a lot for this tutorial!
cpai is running on my machine, but can´t find the TPU.
I think i made something wrong with the USB settings.
This is my lsusb:

Code:
root@pve1-amd:~# lsusb
Bus 006 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 005 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 004 Device 003: ID 17e9:4301 DisplayLink USB3.0 to HDMI Adapter
Bus 004 Device 002: ID 174c:3074 ASMedia Technology Inc. ASM1074 SuperSpeed hub
Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 003 Device 003: ID 051d:0003 American Power Conversion UPS
Bus 003 Device 002: ID 174c:2074 ASMedia Technology Inc. ASM1074 High-Speed hub
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 005: ID 18d1:9302 Google Inc.
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 005: ID 26ce:01a2 ASRock LED Controller
Bus 001 Device 004: ID 05e3:0608 Genesys Logic, Inc. Hub
Bus 001 Device 003: ID 0461:4d0f Primax Electronics, Ltd HP Optical Mouse
Bus 001 Device 002: ID 1c4f:0027 SiGma Micro USB Keyboard
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
root@pve1-amd:~#

i´ve inserted to the conf file of the lxc:

Code:
usb0: host=1a6e:089a,usb2=1
usb1: host=18d1:9302,usb2=1
lxc.mount.entry: /dev/bus/usb/002 dev/bus/usb/002 none bind,optional,create=dir
is this correct?
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!