Add Coral TPU to LXC
Share a Google Coral TPU (USB Accelerator or M.2 / Mini-PCIe) with a Proxmox LXC container. ProxMenux handles the LXC config and the inside-container Edge TPU runtime install. Coral is TPU-only: for GPU / iGPU sharing (Quick Sync, VA-API, NVENC) in the same container, run Add GPU to LXC separately.
What this does
/etc/pve/lxc/<ctid>.conf — different entries depending on whether the host has a USB Accelerator, a M.2 / PCIe Coral, or both. Then it starts the container and installs Google's latest libedgetpu runtime inside it. iGPU / GPU passthrough is handled by a separate script (Add GPU to LXC) — this one focuses on the TPU.When to use this
Use this for Frigate or another compatible Linux detection app in LXC. Coral runs supported ML inference instead of the CPU. Performance depends on the model and hardware; video decoding and other application work still consume resources.
Before you start
- Prepare the Coral device on the host. M.2 / PCIe needs the host driver loaded; USB needs device access and suitable permissions. See Install Coral TPU on the Host. The script installs the app runtime in Debian/Ubuntu containers; other distributions must provide it separately.
ls /dev/apex_* 2>/dev/null ; lsusb | grep -E '1a6e:089a|18d1:9302' - An existing LXC container, ideally running a Debian / Ubuntu-based distro — the in-container runtime install uses
apt-get. Non-Debian containers (Alpine, Arch, RHEL, SUSE…) are still supported in passthrough-only mode: the script detects the distro and offers a prompt to skip thelibedgetpuAPT install while still writing the device passthrough config — useful for app containers that bundle the runtime themselves (e.g. the Frigate Docker image). - Be OK with a brief downtime of the container. The script stops it to apply config changes, then starts it back up to install drivers inside. No host reboot needed.
Host must be prepared first
gasket/apex driver and a working device node. USB needs the connected device and permissions; it does not require the host to run the app. The libedgetpu runtime must be available where the app runs. Follow host preparation → LXC device access → app setup.Running the script
Open ProxMenux on the host, go to Hardware: GPUs and Coral-TPU → Add Coral TPU to LXC.

How the script runs
Choose the target container. The script configures USB access even if no USB Coral is currently connected, then adds M.2 / PCIe access when the corresponding hardware is detected.
┌────────────────────────────────────────────────┐
│ 1. User picks the LXC container │
│ (pct list → dialog → CTID) │
└────────────────┬───────────────────────────────┘
▼
Stop container if running
│
▼
┌─────────┴──────────┐
│ │
▼ ▼
Coral M.2/PCIe? Coral USB?
lspci "Global (udev rule creates
Unichip" /dev/coral symlink
│ on the host)
│ │
Yes Yes
│ │
▼ ▼
/dev/apex_0 Write udev rule
exists? /etc/udev/rules.d/
│ 99-coral-usb.rules
├─ Yes → (ATTRS idVendor/idProduct
│ dev<N>: → SYMLINK /dev/coral)
│ /dev/apex_0 │
│ gid=apex ▼
│ Append to LXC config:
└─ No → lxc.cgroup2.devices.allow:
cgroup2 c 189:* rwm
fallback lxc.mount.entry:
(major 245 /dev/bus/usb dev/bus/usb
from /proc/ none bind,optional,
devices) create=dir
│ (bind the WHOLE usb tree,
▼ not /dev/coral — survives
cgroup2 USB replug to other port)
+ mount │
│
└──────────────┬──────┘
▼
Clean up duplicate entries in the config
│
▼
┌──────────────┴──────────────┐
│ Start container + wait │
│ up to 15s for readiness │
└──────────────┬──────────────┘
▼
pct exec inside container:
├─ apt-get update
├─ Install Coral deps (gnupg, curl, ca-certificates)
├─ Add Google Coral APT repo
│ /etc/apt/keyrings/coral-edgetpu.gpg
│ /etc/apt/sources.list.d/coral-edgetpu.list
└─ apt install libedgetpu1-std
(or libedgetpu1-max for M.2 if user picks)
│
▼
Show summary (what was enabled)
Container stays running
Note: iGPU passthrough (Quick Sync / VA-API
/ NVENC) is now handled exclusively by
"Add GPU to LXC" — run it BEFORE this script
if you also want hardware video decode.Walking through the flow
Pick the LXC container
The picker lists eligible containers from pct list; OCI-image containers are hidden and managed through OCI manager Apps. Choose the target, running or stopped. The script stops it if needed, writes configuration and starts it for runtime installation.
GPU passthrough suggestion (optional)
If a GPU is detected but not configured for this container, a dialog recommends Add GPU to LXC for hardware video decoding, such as Quick Sync, VA-API or NVENC. It asks whether to continue with Coral only: Yes continues TPU setup; No exits so you can configure the GPU first.
Write LXC config — USB path
The script creates a host udev rule for the /dev/coral symlink and bind-mounts the whole /dev/bus/usb tree into the container. This USB configuration is written even when no Coral USB is currently connected; it exposes more than just that one device.
# /etc/udev/rules.d/99-coral-usb.rules (on the host)
SUBSYSTEM=="usb", ATTRS{idVendor}=="1a6e", ATTRS{idProduct}=="089a", \
SYMLINK+="coral", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="18d1", ATTRS{idProduct}=="9302", \
SYMLINK+="coral", MODE="0666"
# Appended to /etc/pve/lxc/<ctid>.conf
lxc.cgroup2.devices.allow: c 189:* rwm
lxc.mount.entry: /dev/bus/usb dev/bus/usb none bind,optional,create=dirWhy mount /dev/bus/usb instead of /dev/coral?
/dev/bus/usb/001/005 change on reconnect. Older versions bind-mounted the /dev/coral symlink and could retain a stale path. Mounting the whole USB tree makes the current device node visible; the app may still need to reopen it.Write LXC config — M.2 / PCIe path
If a M.2 / PCIe Coral is present on the host and /dev/apex_0 exists (the apex kernel module is loaded), the script uses the modern Proxmox dev API which handles cgroup2 permissions automatically for both privileged and unprivileged containers:
# Appended to /etc/pve/lxc/<ctid>.conf — modern path
dev0: /dev/apex_0,gid=<APEX_GID>If /dev/apex_0 is absent after Install Coral on Host, the script writes a bind mount with create=file and, only when the apex major number is listed in /proc/devices, a classic cgroup2 rule. Neither creates a working device:
# Fallback when /dev/apex_0 isn't yet present on host
lxc.cgroup2.devices.allow: c 245:0 rwm
lxc.mount.entry: /dev/apex_0 dev/apex_0 none bind,optional,create=fileReboot the host first if you just installed Coral drivers
apex driver. Load the driver, or reboot after installation, and verify the host device exists. Re-run the script once the device is ready to apply the modern device entry, then restart the container.Start the container + install Coral runtime inside
The script starts the container and waits up to 15 seconds for its running status, then uses pct exec to run the runtime installer inside. The installer:
- Runs
apt-get update. - Installs the Coral repository prerequisites:
gnupg,curl,ca-certificates. - Imports Google's Coral GPG key to
/etc/apt/keyrings/coral-edgetpu.gpg(modern path, same as the host installer uses) and adds thecoral-edgetpu-stableAPT repository withsigned-by=. - Installs
libedgetpu1-stdby default. When an M.2 Coral is detected, the script offers a choice oflibedgetpu1-stdorlibedgetpu1-max. The choice of runtime package does not itself configure application detection settings.
Summary
The script prints a checklist at the end summarising what was enabled (Coral USB, Coral M.2) with ✓ or ⚠ marks depending on whether the hardware was actually detected. The container stays running — you can jump straight into Frigate / CodeProject.AI / your app config.
Manual equivalent
If you want to see exactly what goes into the LXC config, or apply it by hand:
USB Coral
# On the HOST — persistent udev alias
cat > /etc/udev/rules.d/99-coral-usb.rules <<'EOF'
SUBSYSTEM=="usb", ATTRS{idVendor}=="1a6e", ATTRS{idProduct}=="089a", SYMLINK+="coral", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="18d1", ATTRS{idProduct}=="9302", SYMLINK+="coral", MODE="0666"
EOF
udevadm control --reload-rules
udevadm trigger --subsystem-match=usb
# Append to /etc/pve/lxc/<ctid>.conf
# (container must be stopped to apply)
lxc.cgroup2.devices.allow: c 189:* rwm
lxc.mount.entry: /dev/bus/usb dev/bus/usb none bind,optional,create=dirM.2 / PCIe Coral
# On the HOST — PVE dev API (works in privileged AND unprivileged CTs)
# Append to /etc/pve/lxc/<ctid>.conf
dev0: /dev/apex_0,gid=$(getent group apex | cut -d: -f3)
# ─── OPTIONAL — fallback path ────────────────────────────────────
# Only use this block if /dev/apex_0 doesn't exist yet on the host
# (apex module not loaded — reboot still pending). The PVE dev API
# above is preferred when the device is present.
# ─────────────────────────────────────────────────────────────────
# lxc.cgroup2.devices.allow: c 245:0 rwm
# lxc.mount.entry: /dev/apex_0 dev/apex_0 none bind,optional,create=fileInside the container — Coral runtime
# Assumes Debian / Ubuntu
apt-get update
apt-get install -y gnupg curl ca-certificates
# Google Coral APT repo
mkdir -p /etc/apt/keyrings
curl -fsSL https://packages.cloud.google.com/apt/doc/apt-key.gpg \
| gpg --dearmor -o /etc/apt/keyrings/coral-edgetpu.gpg
echo 'deb [signed-by=/etc/apt/keyrings/coral-edgetpu.gpg] https://packages.cloud.google.com/apt coral-edgetpu-stable main' \
> /etc/apt/sources.list.d/coral-edgetpu.list
apt-get update
apt-get install -y libedgetpu1-std
# Or for M.2 + maximum performance (runs hotter):
# apt-get install -y libedgetpu1-maxVerification
Enter the container and check the Coral is visible:
pct enter <ctid>
# USB Coral
lsusb | grep -E '1a6e:089a|18d1:9302'
ls /dev/bus/usb/
# M.2 Coral
ls -l /dev/apex_0
# Expect: crw-rw---- 1 root apex ... /dev/apex_0
# Runtime installed
dpkg -l libedgetpu1-std
# Frigate-style test: run a quick Python inference
python3 -c "from pycoral.utils.edgetpu import list_edge_tpus; print(list_edge_tpus())"
# Expect a non-empty list with at least one deviceTroubleshooting
Container started but /dev/apex_0 missing inside
lsmod | grep apex. If missing, try modprobe apex or reboot after driver installation. Once /dev/apex_0 exists on the host, verify the LXC device entry (re-run the script if only the fallback entries were written) and restart the container with pct stop <ctid> && pct start <ctid>.USB Coral disappears after replug in a different port
/dev/bus/usb instead of the /dev/coral symlink. If you're hitting this, check your LXC config has lxc.mount.entry: /dev/bus/usb dev/bus/usb ... and not a reference to /dev/coral directly. Old configs from earlier script versions may need updating — re-run the script on the same container and the config gets refreshed.Alpine / Arch / RHEL / SUSE container — runtime not installed
libedgetpu is not installed. Use a compatible community package or build from source; check availability before using a package command such as Alpine apk add. An app image such as Frigate can bundle the runtime. With nested Docker, also forward the M.2 device using --device /dev/apex_0:/dev/apex_0, or mount the USB tree into that Docker container; the LXC mount alone does not forward it into Docker.Frigate says 'Coral EdgeTPU detected but not available'
plugdev membership. For M.2, inspect /dev/apex_0 with ls -l /dev/apex_0. A group name such as apex in /etc/group is not enough: numeric GIDs and LXC mappings must match. Also check whether another process already claims the TPU; do not switch to privileged mode as the first fix.Check both host and container logs
journalctl -k | grep -i -e apex -e gasket -e usb. Inside the container, inspect the app logs; for nested Docker use docker logs <container>. Permissions, missing runtime, USB connectivity or another process claiming the TPU can all cause failures.Related
- Install Coral TPU (Host) — required prerequisite for M.2 / PCIe Coral cards before passing into a CT.
- Add GPU to LXC — same pattern for GPUs (often paired with a Coral TPU in Frigate setups).