Setting up Google Coral USB accelerator on Raspberry Pi 4 for Donkey Car

1. Make sure you have a steady power supply

Use this handy one-liner to check the status.

vcgencmd version; vcgencmd get_throttled; vcgencmd measure_volts; vcgencmd measure_temp;vcgencmd measure_clock arm;

You can also stress test your Pi to see if your power supply is stable enough.

2. Take care of system cooling

3. Install Edgetpu library

edgetpu_api/install.sh: line 51: warning: command substitution: ignored null byte in input
Your platform is not supported.

I have add the following lines in edgetpu_api/install.sh to make it work:

elif [[ "${MODEL}" == "Raspberry Pi 4 Model B Rev"* ]]; then
info "Recognized as Raspberry Pi 4B."
LIBEDGETPU_SUFFIX=arm32
HOST_GNU_TYPE=arm-linux-gnueabihf
fi

You might also run into the following error:

ModuleNotFoundError: No module named '_edgetpu_cpp_wrapper'

As advised by the coral doc, copy the library for python 3.7

cd /usr/local/lib/python3.7/dist-packages/edgetpu/swig
sudo cp _edgetpu_cpp_wrapper.cpython-35m-arm-linux-gnueabihf.so _edgetpu_cpp_wrapper.cpython-37m-arm-linux-gnueabihf.so

4. Run a demo

cd /usr/local/lib/python3.7/dist-packages/edgetpu/demopython3 classify_image.py \
--model ~/Downloads/mobilenet_v2_1.0_224_inat_bird_quant_edgetpu.tflite \
--label ~/Downloads/inat_bird_labels.txt \
--image ~/Downloads/parrot.jpg

5. Install the EdgeTPU in your virtual env

# The virtual environment is called env in donkey car
cd ~/env/lib/python3.7/site-packages
ln -s /usr/local/lib/python3.7/dist-packages/edgetpu .
ln -s /usr/local/lib/python3.7/dist-packages/edgetpu-2.11.1.dist-info .

If you are setting up your local PC to use the coral and you are using conda, do this:

cd ~/anaconda3/envs/<your_env>/lib/python3.7/site-packagesln -s /usr/local/lib/python3.7/dist-packages/edgetpu .
ln -s /usr/local/lib/python3.7/dist-packages/edgetpu-2.11.1.dist-info .

That’s it. If you have any question, just leave me some message. If you want to purchase donkey car, you could visit our store and check out our community on facebook.

Love Self-driving technology and machine learning. Community leader in DIYRobocar Hong Kong.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store