Setting up Google Coral USB accelerator on Raspberry Pi 4 for Donkey Car
1. Make sure you have a steady power supply
Coral draws significant amount of energy from the Pi USB 3 interface. If you are experiencing under voltage, the pi will be throttled
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
Install a big heatsink like this before you start. Pi will be throttled and therefore affect the performance of the coral.
3. Install Edgetpu library
Follow official doc. On Pi 4, you might experience this error
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
I am primarily using the coral for Donkey car so I need the virtual environment to support edgetpu library as well.
# The virtual environment is called env in donkey car
cd ~/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 .
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.