Setting Up
— Google's Coral TPU in 2024 with a Mac


22. October 2024, using macOS 14.6.1, Google Coral Edge TPU

1. Installation

Install the runtime edgetpu and PyCoral according to Coral's setup guide.

☞ Hint: Last supported Python version of the library PyCoral is version 3.9, setup your Python environment accordingly — already Python 3.10 did not worked out for me!

conda create -n coral python=3.9

2. The Numpy Error

As soon as trying to run the first example ...

python3 examples/classify_image.py \
--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

... I got the following errors ...

A module that was compiled using NumPy 1.x cannot be run in NumPy 2.0.2 as it may crash. To support both 1.x and 2.x versions of NumPy, modules must be compiled with NumPy 2.0. Some module may need to rebuild instead e.g. with 'pybind11>=2.12'.

If you are a user of the module, the easiest solution will be to downgrade to 'numpy<2' or try to upgrade the affected module. We expect that some modules will need time to support NumPy 2.

[...] AttributeError: _ARRAY_API not found

[...] SystemError: initialization of _pywrap_coral raised unreported exception

☞ to resolve this downgrade Numpy to last 1.X.X version

pip install "numpy<2.0"

3. The Library Error

After (2) was fixed, the following error occured...

ValueError: Failed to load delegate from libedgetpu.1.dylib

In the official Coral documentation I found two hints for this issue:

1. Check if the device is registered by your machine with the following command:

lsusb -d 1a6e:089a

2. Check if the edgetpu library is reachable via Python:

python -c "from ctypes.util import find_library; print(find_library(\"edgetpu\"))"

For me the second snipped returned None. This means the edgetpu library is not accessible for our Python program.

Since the library installation worked without any issues, a problem with linking the library is likely. Therefore, I used the following comand to point from libedgetpu.dylib to libedgetpu.1.dylib.

sudo ln -s /usr/local/lib/libedgetpu.1.dylib /usr/local/lib/libedgetpu.dylib

4. Happy Hacking!

☞ Hint: Only tensorflow lite models are supported by the runtime library edgetpu. No support for basic operations like matmul. Find out about the internal mechanics here!