edgetpu: unable to run tflite_runtime with libedgetpu on raspberry pi zero wh

Hi,

Having some issues getting the edgetpu runtime to work with the tflite_runtime package on my raspberry pi zero (with the USB accelerator) - I’m new to all this and I’ve tried everything I can think of, can anyone help? Findings are below, many many thanks in advance.

dpkg -l | grep edgetpu
ii  libedgetpu1-std:armhf                 14.1                                   armhf        Support library for Edge TPU
ii  python3-edgetpu                       14.1                                   armhf        Edge TPU Python API

Attempting using my own compiled tflite_runtime package following the steps specified here: https://github.com/google-coral/edgetpu/issues/198 results in: Illegal instruction:

python3 -c 'print(__import__("tflite_runtime").__version__)'
2.1.0
LD_PRELOAD=/usr/lib/arm-linux-gnueabihf/libatomic.so.1.2.0 python3 index.python
Illegal instruction

and then I’ve tried using some prebuilt wheels that other people have posted on the various issues reported, the one below is tflite_runtime 2.2.0 (not sure if the rc3 makes any significant differences here)

python3 -c 'print(__import__("tflite_runtime").__version__)'
2.2.0rc3
LD_PRELOAD=/usr/lib/arm-linux-gnueabihf/libatomic.so.1.2.0 python3 index.python
Traceback (most recent call last):
  File "index.python", line 94, in <module>
    interpreter.allocate_tensors()
  File "/home/pi/Documents/Python 3/Object Detection/tflite1-env/lib/python3.7/site-packages/tflite_runtime/interpreter.py", line 242, in allocate_tensors
    return self._interpreter.AllocateTensors()
  File "/home/pi/Documents/Python 3/Object Detection/tflite1-env/lib/python3.7/site-packages/tflite_runtime/interpreter_wrapper.py", line 115, in AllocateTensors
    return _interpreter_wrapper.InterpreterWrapper_AllocateTensors(self)
RuntimeError: Internal: Unsupported data type in custom op handler: 0Node number 2 (EdgeTpuDelegateForCustomOp) failed to prepare.

Then the last one is tflite_runtime 2.3.1:

python3 -c 'print(__import__("tflite_runtime").__version__)'
2.3.1
LD_PRELOAD=/usr/lib/arm-linux-gnueabihf/libatomic.so.1.2.0 python3 index.python
Traceback (most recent call last):
  File "index.python", line 94, in <module>
    interpreter.allocate_tensors()
  File "/home/pi/Documents/Python 3/Object Detection/tflite1-env/lib/python3.7/site-packages/tflite_runtime/interpreter.py", line 243, in allocate_tensors
    return self._interpreter.AllocateTensors()
RuntimeError: Internal: Unsupported data type in custom op handler: 0Node number 2 (EdgeTpuDelegateForCustomOp) failed to prepare.

From what I can tell the last 2 issues (tflite_runtime_2.2.0rc3 & tflite_runtimme_2.3.1) are closer to success than the first, the issues reported before mine indicate some sort of mismatch between the commit of tensorflow that the libedgetpu runtime has been built with and the version used by the tflite_runtime, however my compiled version of tflite_runtime_2.1.0 should have fixed this shouldn’t it?

(All of these have been ran making sure I have the correct libedgetpu runtime for the architecture of the RPI0 (armv6) by doing the below commands from the official edgetpu git repository (which I believe is 14.1?):

git clone https://github.com/google-coral/edgetpu.git
cd edgetpu/libedgetpu/throttled/armv6
sudo cp libedgetpu.so.1 /usr/lib/arm-linux-gnueabihf

but the above is just me guessing that this needs to be done really.

Once again, thanks in advance!

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 19

Most upvoted comments

Hi @Namburger - yeah I did manage to build it but it took a while to do (and I don’t quite remember how I did it 😄 )

All the .whl files that I tried can be found here (only the 2.3.1 one worked in the end for me): https://drive.google.com/drive/folders/1VtkKbpKnv9vHylQ62ekuGvyco2Jg9pQe?usp=sharing

To build the libedgetpu runtime I:

  1. got the commit hash for this specific build by running:
python3 -c 'print(__import__("tflite_runtime").__git_version__)'
  1. Get the full commit hash by running:
git rev-parse {short-hash-here}
  1. Then just build the libedgetpu runtime by using your instructions above and replacing the hash in this file with the commit hash returned from the above command.

Hope this helps!

Not spam at all, the more I can try the better! 😄

Brilliant yeah I never thought of building the edgetpu runtime myself, completely overlooked that.

This is more of a hobby project for me, curious to see what the performance improvements look like with the usb accelerator as without it’s 0.07 fps when doing object detection on a sample model (which is understandable considering the memory limitations of the RPI0).

Once again, many thanks for the quick responses and the suggestions 😃

@rhadnum thanks for the package, you’re amazing!