google-coral / tflite

Examples using TensorFlow Lite API to run inference on Coral devices
https://coral.withgoogle.com
Apache License 2.0
182 stars 67 forks source link

EdgeTpuDelegateForCustomOp failed to prepare #16

Closed petewarden closed 4 years ago

petewarden commented 4 years ago

When following the guide at https://coral.ai/docs/dev-board/get-started#6-run-a-model-using-the-tensorflow-lite-api I see the following error instead of the expected classification results:

mendel@red-bunny:~/tflite/python/examples/classification$ python3 classify_image.py \
> --model models/mobilenet_v2_1.0_224_inat_bird_quant_edgetpu.tflite \
> --labels models/inat_bird_labels.txt \
> --input images/parrot.jpg
Traceback (most recent call last):
  File "classify_image.py", line 122, in <module>
    main()
  File "classify_image.py", line 100, in main
    interpreter.allocate_tensors()
  File "/home/mendel/.local/lib/python3.7/site-packages/tflite_runtime/interpreter.py", line 242, in allocate_tensors
    return self._interpreter.AllocateTensors()
  File "/home/mendel/.local/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: 0Node number 1 (EdgeTpuDelegateForCustomOp) failed to prepare.
Namburger commented 4 years ago

@petewarden Can you share the outputs of these commands:

$ dpkg -l | grep edgetpu
$ python3 -c 'print(__import__("tflite_runtime").__version__)'
petewarden commented 4 years ago

Sure, thanks!

$ dpkg -l | grep edgetpu
ii  edgetpudemo                          3-1                         all          Edge TPU demo script
ii  libedgetpu1-std:arm64                12-1                        arm64        Support library for Edge TPU
ii  python3-edgetpu                      12.1-1                      arm64        Edge TPU Python API
ii  python3-edgetpuvision                6-1                         arm64        EdgeTPU camera API
$ python3 -c 'print(__import__("tflite_runtime").__version__)'
2.1.0.post1
Namburger commented 4 years ago

@petewarden So the issue is that you got mismatching version of libedgetpu1-std:arm64 and tflite_runtime. The fix for this should be as easy as an apt update and reinstall your package:

$ sudo apt update
$ sudo apt upgrade libedgetpu1-std

Here is the correct version for reference:

mendel@purple-orange:~$ dpkg -l | grep edgetpu
ii  edgetpudemo                          3-1                                 all          Edge TPU demo script
ii  libedgetpu1-max:arm64                14.0                                arm64        Support library for Edge TPU
ii  python3-edgetpu                      14.0                                arm64        Edge TPU Python API
ii  python3-edgetpuvision                6-1                                 arm64        EdgeTPU camera API
petewarden commented 4 years ago

Awesome, thanks, that works! Closing.

mattheys commented 4 years ago

For windows users trying to run the demo, download 2.14.0 not 2.14.1 from here https://dl.google.com/coral/edgetpu_api/edgetpu_runtime_20200331.zip

Namburger commented 4 years ago

@mattheys are you having issues with 2.14.1? They should be the same library with 2.14.1 added window supports for pcie

mattheys commented 4 years ago

Yes, I got the following error with 2.14.1, downgrading to 2.14.0 worked fine with the edgetpu models here https://github.com/google-coral/edgetpu/raw/master/test_data.

python classify_image.py --model models/mobilenet_v2_1.0_224_inat_bird_quant_edgetpu.tflite --labels models/inat_bird_labels.txt --input images/parrot.jpg

Traceback (most recent call last):
  File "classify_image.py", line 122, in <module>
    main()
  File "classify_image.py", line 100, in main
    interpreter.allocate_tensors()
  File "C:\Users\<userid>\AppData\Local\Programs\Python\Python37\lib\site-packages\tflite_runtime\interpreter.py", line 243, in allocate_tensors
    return self._interpreter.AllocateTensors()
  File "C:\Users\<userid>\AppData\Local\Programs\Python\Python37\lib\site-packages\tflite_runtime\tensorflow_wrap_interpreter_wrapper.py", line 110, in AllocateTensors
    return _tensorflow_wrap_interpreter_wrapper.InterpreterWrapper_AllocateTensors(self)
RuntimeError: Internal: Unsupported data type in custom op handler: 0Node number 1 (EdgeTpuDelegateForCustomOp) failed to prepare.

Sorry do you want me to open a new issue?

Namburger commented 4 years ago

@mattheys are you using a pcie module or a USB Accelerator? Let me confirm with our team to make sure that this isn't expected first, thanks for reporting

mattheys commented 4 years ago

It's a USB Accelerator

Namburger commented 4 years ago

@mattheys as it turned out, we uploaded the wrong zip file lol If you redownload it again and reinstall it'll works :)

musekeskin commented 3 years ago

Hi, I have a similar problem. mendel@xenial-yarn:~/coral/pycoral$ 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 Traceback (most recent call last): File "examples/classify_image.py", line 82, in main() File "examples/classify_image.py", line 60, in main interpreter.allocate_tensors() File "/home/mendel/.local/lib/python3.7/site-packages/tflite_runtime/interpreter.py", line 242, in allocate_tensors return self._interpreter.AllocateTensors() File "/home/mendel/.local/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 1 (EdgeTpuDelegateForCustomOp) failed to prepare.

mendel@xenial-yarn:~/coral/pycoral$ dpkg -l | grep edgetpu ii edgetpudemo 3-1 all Edge TPU demo script ii libedgetpu1-std:arm64 15.0 arm64 Support library for Edge TPU ii python3-edgetpuvision 7-1 arm64 EdgeTPU camera API

Namburger commented 3 years ago

@musekeskin can you check your tflite_runtime version also? It should be 2.5.0 at this time!

musekeskin commented 3 years ago

mendel@xenial-yarn:~$ python3 -c 'print(import("tflite_runtime").version)' 2.1.0

Namburger commented 3 years ago

Yelp, please upgrade the package. https://www.tensorflow.org/lite/guide/python

musekeskin commented 3 years ago

it is need to be version 2.15 or is it 2.5? mendel@xenial-yarn:~$ pip3 install https://github.com/google-coral/pycoral/releases/download/release-frogfish/tflite_runtime-2.5.0-cp37-cp37m-linux_armv7l.whl

tflite_runtime-2.5.0-cp37-cp37m-linux_armv7l.whl is not a supported wheel on this platform.

Namburger commented 3 years ago

@musekeskin sorry 2.5 is what I meant.

is not a supported wheel on this platform.

is a very self explanatory message

Are you trying to run this on the Dev Board? If so it should be using the arm64 wheel as opposed to arm32.

musekeskin commented 3 years ago

yes dev board. mendel@xenial-yarn:~$ pip3 install https://github.com/google-coral/pycoral/releases/download/release-frogfish/tflite_runtime-2.5.0-cp37-cp37m-linux_aarch64.whl Collecting tflite-runtime==2.5.0 from https://github.com/google-coral/pycoral/releases/download/release-frogfish/tflite_runtime-2.5.0-cp37-cp37m-linux_aarch64.whl Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0xffff9e2bd6a0>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution')': /google-coral/pycoral/releases/download/release-frogfish/tflite_runtime-2.5.0-cp37-cp37m-linux_aarch64.whl Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0xffff9e6eccc0>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution')': /google-coral/pycoral/releases/download/release-frogfish/tflite_runtime-2.5.0-cp37-cp37m-linux_aarch64.whl Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0xffff9e6eceb8>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution')': /google-coral/pycoral/releases/download/release-frogfish/tflite_runtime-2.5.0-cp37-cp37m-linux_aarch64.whl Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0xffff9e6ece48>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution')': /google-coral/pycoral/releases/download/release-frogfish/tflite_runtime-2.5.0-cp37-cp37m-linux_aarch64.whl Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0xffff9e6ecef0>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution')': /google-coral/pycoral/releases/download/release-frogfish/tflite_runtime-2.5.0-cp37-cp37m-linux_aarch64.whl Could not install packages due to an EnvironmentError: HTTPSConnectionPool(host='github.com', port=443): Max retries exceeded with url: /google-coral/pycoral/releases/download/release-frogfish/tflite_runtime-2.5.0-cp37-cp37m-linux_aarch64.whl (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0xffff9ef41128>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution'))

Namburger commented 3 years ago

@musekeskin okay, now this is kind of an internet issue, you can try wget it first and then install?

musekeskin commented 3 years ago

I downloaded the file somehow. But now I am getting such an error;

mendel@xenial-yarn:~$ python3 --version Python 3.7.3 mendel@xenial-yarn:~$ ls coral labels.txt dog.jpg mobilenet_v2_1.0_224_inat_bird_quant_edgetpu.tflite edgetpu-2.14.1-py3-none-any.whl pycoral-1.0.0-cp38-cp38-linux_x86_64.whl google-coral pycoral.git İndirilenler tflite_runtime-2.5.0-cp37-cp37m-linux_aarch64.whl mendel@xenial-yarn:~$ pip3 install tflite_runtime-2.5.0-cp37-cp37m-linux_aarch64.whl Processing ./tflite_runtime-2.5.0-cp37-cp37m-linux_aarch64.whl Exception: Traceback (most recent call last): File "/usr/lib/python3/dist-packages/pip/_internal/cli/base_command.py", line 143, in main status = self.run(options, args) File "/usr/lib/python3/dist-packages/pip/_internal/commands/install.py", line 338, in run resolver.resolve(requirement_set) File "/usr/lib/python3/dist-packages/pip/_internal/resolve.py", line 102, in resolve self._resolve_one(requirement_set, req) File "/usr/lib/python3/dist-packages/pip/_internal/resolve.py", line 259, in _resolve_one dist = abstract_dist.dist(self.finder) File "/usr/lib/python3/dist-packages/pip/_internal/operations/prepare.py", line 77, in dist self.req.source_dir))[0] IndexError: list index out of range

musekeskin commented 3 years ago

After deleting the old installed version I was able to install the new version. Worked. Thanks !

luckywangchenxi commented 3 years ago

Hello, I have a similar problem. mendel@neat-kid:~/coral/pycoral$ 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
Traceback (most recent call last):
File "examples/classify_image.py", line 82, in
main()
File "examples/classify_image.py", line 60, in main
interpreter.allocate_tensors()
File "/home/mendel/.local/lib/python3.7/site-packages/tflite_runtime/interpreter.py", line 242, in allocate_tensors
return self._interpreter.AllocateTensors()
File "/home/mendel/.local/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: 1081772464Node number 1 (EdgeTpuDelegateForCustomOp) failed to prepare.

mendel@purple-orange:~$ dpkg -l | grep edgetpu ii edgetpudemo 3-1 all Edge TPU demo script ii libedgetpu1-max:arm64 14.1 arm64 Support library for Edge TPU ii python3-edgetpu 14.1 arm64 Edge TPU Python API ii python3-edgetpuvision 6-1 arm64 EdgeTPU camera API

$ python3 -c 'print(import("tflite_runtime").version)' 2.5.0.post1

hjonnala commented 3 years ago

@wangchenxi777 please try python3 -c 'from pycoral.utils.edgetpu import get_runtime_version; print(get_runtime_version())' if the output is not same below BuildLabel(COMPILER=6.3.0 20170516,DATE=redacted,TIME=redacted), RuntimeVersion(14)

to upgrade the edgetpu runtime please follow these instructions https://coral.ai/docs/dev-board/reflash/#update-your-board-with-apt-get

luckywangchenxi commented 3 years ago

ok thankyou now I will try it