tflite: tflite_runtime on Windows 10 raises a ValueError: Failed to load delegate from edgetpu.dll

Hello everyone, I’m trying to run the following example using a Coral m2 module:

python 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

but the following error is raised:


Traceback (most recent call last):
  File "C:\Program Files\Python38\lib\site-packages\tflite_runtime\interpreter.py", line 152, in load_delegate
    delegate = Delegate(library, options)
  File "C:\Program Files\Python38\lib\site-packages\tflite_runtime\interpreter.py", line 111, in __init__
    raise ValueError(capture.message)
ValueError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "examples/classify_image.py", line 84, in <module>
    main()
  File "examples/classify_image.py", line 61, in main
    interpreter = make_interpreter(*args.model.split('@'))
  File "C:\Program Files\Python38\lib\site-packages\pycoral\utils\edgetpu.py", line 66, in make_interpreter
    delegates = [load_edgetpu_delegate({'device': device} if device else {})]
  File "C:\Program Files\Python38\lib\site-packages\pycoral\utils\edgetpu.py", line 42, in load_edgetpu_delegate
    return tflite.load_delegate(_EDGETPU_SHARED_LIB, options or {})
  File "C:\Program Files\Python38\lib\site-packages\tflite_runtime\interpreter.py", line 154, in load_delegate
    raise ValueError('Failed to load delegate from {}\n{}'.format(
ValueError: Failed to load delegate from edgetpu.dll

python -c "from ctypes import *; cdll.LoadLibrary('edgetpu.dll'); print('success')"
success
print(tflite_runtime.__git_version__)
48c3bae94a8b324525b45f157d638dfd4e8c3be1

Please help me.

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 62 (5 by maintainers)

Most upvoted comments

The possible solutions are:

Compile the model with runtime version 13 by specifying -m flag (https://coral.ai/docs/edgetpu/compiler/#usage) example: ! edgetpu_compiler -s -m 13 ssdlite_mobiledet_dog_vs_cat.tflite

or

If the model(any specific operations) requires runtime 14 try it on coral dev board

or try it on different operating system either linux or mac OS as the model requires edgetpu runtime 14

you can refer to these tutorials: https://github.com/google-coral/tutorials

This section might help: https://colab.research.google.com/github/google-coral/tutorials/blob/master/retrain_classification_ptq_tf2.ipynb#scrollTo=RMLYBDe_e849

Please open new issues as these questions are not relevant to this thread.

@hemanthreddyjonnala with edgetpu_runtime_20201204, it worked fine. The demo functioned today in the morning. But now for my custom object detection model, I got an error saying that I require runtime version(14). Hence, I upgraded to 20210726 version which is runtime version 14.

The below output is with runtime version(13):- edgetpu_runtime_20201204

(pycoral_venv) C:\pycoral_venv\Scripts\coral\pycoral>python examples\detect_image.py --model 3-classes-training\model_quantized_edgetpu.tflite --labels 3-classes-training\labels.txt.txt --input 3-classes-training\holes-test-input.jpg --output holes-output.jpg Traceback (most recent call last): File “examples\detect_image.py”, line 108, in main() File “examples\detect_image.py”, line 74, in main interpreter.allocate_tensors() File “C:\pycoral_venv\lib\site-packages\tflite_runtime\interpreter.py”, line 408, in allocate_tensors return self._interpreter.AllocateTensors() RuntimeError: Failed to prepare for TPU. Failed precondition: Package requires runtime version (14), which is newer than this runtime version (13).Node number 2 (EdgeTpuDelegateForCustomOp) failed to prepare.

Please find the above error that I encountered. Lookling at this error, I chaned it to the newer version 20210726