Wednesday, May 10, 2023

Using Google Coral TPU on OpenSUSE

Installing the TPU driver

The official guide only covers steps for Debian. Third-party compiled binaries are available for Fedora, RHEL, and OpenSUSE etc. The RPM for OpenSUSE Tumbleweed can be downloaded directly here

Once downloaded, install the RPM file with "sudo zypper install gasket..."

Seems OpenSUSE now has the gasket driver in repository. Just install it with "sudo zypper install gasket-driver gasket-driver-kmp-default"

EDIT 20240524: seems that the gasket driver is removed from the OpenSUSE repository. So I guess back to manual installation with RPM.

Installing the userspace runtime driver

The userspace driver can be built from source inside docker:

git clone
cd libedgetpu
CPU=k8 DOCKER_CPUS="k8" DOCKER_IMAGE="ubuntu:18.04" DOCKER_TARGETS=libedgetpu make docker-build

Copy the files from "out" folder and install using ldconfig:

sudo mkdir -p /usr/lib/tpu/lib
sudo cp --preserve=links out/direct/k8/* /usr/lib/tpu/lib
echo /usr/lib/tpu/lib | sudo tee -a /etc/
sudo ldconfig

Grant permission

Running the Python examples may fail with error "failed to load delegate...". This is due to permission issue. Add your user to the group "apex" with the command "sudo usermod -aG apex [your username]".

Also, if using the USB accelerator instead, add two rules to the udev file "/etc/udev/rules.d/65-apex.rules" and reboot:


Running the examples

If you followed the above steps to install drivers, you may need to reboot before running any example.

The "pycoral" package mentioned on the officail guide is kind of confusing. The "pycoral" from pypi is actually a totally unrelated package. What we need for the TPU can be found here.

Also, there is no support for Python 3.10 yet. So needed to use 3.9. To install packages in order to run the example:

python3.9 -m venv venv
. venv/bin/activate
pip install numpy pillow
python -m pip install --extra-index-url pycoral~=2.0

Then follow the steps on the official guide to run the example.

$ python3 examples/ --model test_data/mobilenet_v2_1.0_224_inat_bird_quant_edgetpu.tflite --labels test_data/inat_bird_labels.txt --input test_data/parrot.jpg
Note: The first inference on Edge TPU is slow because it includes loading the model into Edge TPU memory.
Ara macao (Scarlet Macaw): 0.75781

1 comment:

Raju said...


My Self Raju from India. Trying to bring-up M.2 Coral Edge TPU on my PC with OpenSuse-15.4. Here, I have followed all your steps but couldn't success to get "/dev/apex_0".

Could you please help me on same?