How to install Coral Edge TPU M.2 A+E Key on Jetson Nano
This tutorial will highlight the steps required to run a Google Coral TPU Accelerator on Jetson Nano.
Note : I installed on a Jetson Nano B01 on JetPack 4.4 and I would expect this to work with the A02 as well. It includes the same slot M.2 Key E Slot under the SoC (the module that looks like it connects with a laptop RAM slot).
Mounting the M.2 TPU Accelerator
Under the heatsink, there is a slot for you to place your Coral TPU. You just need to do the following steps. This should only take about 5 minutes.
- unscrew the SoC, remove it and set it aside.
-
Mount your Coral TPU
- Your Jetson Nano should include a screw to secure it in place.
- Replace your SoC as it was prior. Ensure the screws are secure.
Driver Installation
Now that the hard part is over. You can move on to installation. All steps mentioned in this section are referenced from https://coral.ai/docs/m2/get-started/
Run the following :
apt install curl nano -y sudo bash <(https://gitlab.com/Shinobi-Systems/Shinobi-Installer/-/raw/master/jetson-coral-m2-key-install.sh)
Then Reboot.
sudo reboot
After the Reboot. Check to see if your Jetson Nano detects the Coral TPU.
lspci -x | grep 089a
You should see something like this.
03:00.0 System peripheral: Device 1ac1:089a
Now run this.
ls /dev/apex_0
to see this.
/dev/apex_0
Install PyCoral and TensorFlow Lite
sudo apt-get install python3-pycoral
Awesome. Drivers are ready.
Hold on we're almost done. One more thing.
The Jetson Nano requires an adjustment to your extlinux.conf. If you do not make this change the Coral TPU will fail to load.
This fix for the Jetson Nano was offered by Namburger on Github within this Issue https://github.com/google-coral/edgetpu/issues/96
nano /boot/extlinux/extlinux.conf
Then on the APPEND line add this to the end.
pcie_aspm=off
So if your APPEND line appears like this
APPEND ${cbootargs} quiet root=/dev/mmcblk0p1 rw rootwait rootfstype=ext4 console=ttyS0,115200n8 console=tty0 fbcon=map:0 net.ifnames=0
make it this
APPEND ${cbootargs} quiet root=/dev/mmcblk0p1 rw rootwait rootfstype=ext4 console=ttyS0,115200n8 console=tty0 fbcon=map:0 net.ifnames=0 pcie_aspm=off
Just a simple addition of pcie_aspm=off.
Then save the file and Reboot the Jetson Nano.
Test the TPU
This test is referenced from https://coral.ai/docs/m2/get-started/#4-run-a-model-on-the-edge-tpu
1. Download the example from Github.
mkdir coral && cd coral git clone https://github.com/google-coral/pycoral.git cd pycoral
2. Download the model, labels, and bird photo.
bash examples/install_requirements.sh classify_image.py
3. Run the image classifier with a test photo that was downloaded in Step 2.
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
You should see something like this.
INFO: Initialized TensorFlow Lite runtime. ----INFERENCE TIME---- Note: The first inference on Edge TPU is slow because it includes loading the model into Edge TPU memory. 11.8ms 3.0ms 2.8ms 2.9ms 2.9ms -------RESULTS-------- Ara macao (Scarlet Macaw): 0.76562