google-coral / tflite

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

tflite_runtime on Windows 11 raises a ValueError: Failed to load delegate from edgetpu.dll #54

Closed RobertFlatt closed 2 years ago

RobertFlatt commented 2 years ago

Description

ValueError: Failed to load delegate from edgetpu.dll
>>> print(tflite_runtime.__git_version__)
a4dfb8d1a71385bd6d122e4f27f86dcebb96712d

dll version:

image

Looks like https://github.com/google-coral/tflite/issues/46 Except this is Windows 11, is first time install of Edge TPU runtime, and tflite-runtime is 2.5.0.post1

Tried a restart, no change. Any suggestions?

Click to expand! ### Issue Type Support ### Operating System _No response_ ### Coral Device USB Accelerator ### Other Devices _No response_ ### Programming Language Python 3.8 ### Relevant Log Output ```shell C:\Users\Bobf\Documents\kivy\coral\pycoral>python examples/classify_image.py --model test_data/mobile net_v2_1.0_224_inat_bird_quant_edgetpu.tflite --labels test_data/inat_bird_labels.txt --input test_da ta/parrot.jpg Traceback (most recent call last): File "C:\Users\Bobf\AppData\Local\Programs\Python\Python38\lib\site-packages\tflite_runtime\interpreter.py", line 160, in load_delegate delegate = Delegate(library, options) File "C:\Users\Bobf\AppData\Local\Programs\Python\Python38\lib\site-packages\tflite_runtime\interpreter.py", line 119, 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 121, in main() File "examples/classify_image.py", line 71, in main interpreter = make_interpreter(*args.model.split('@')) File "C:\Users\Bobf\AppData\Local\Programs\Python\Python38\lib\site-packages\pycoral\utils\edgetpu.py", line 87, in make_interpreter delegates = [load_edgetpu_delegate({'device': device} if device else {})] File "C:\Users\Bobf\AppData\Local\Programs\Python\Python38\lib\site-packages\pycoral\utils\edgetpu.py", line 52, in load_edgetpu_delegate return tflite.load_delegate(_EDGETPU_SHARED_LIB, options or {}) File "C:\Users\Bobf\AppData\Local\Programs\Python\Python38\lib\site-packages\tflite_runtime\interpreter.py", line 162, in load_delegate raise ValueError('Failed to load delegate from {}\n{}'.format( ValueError: Failed to load delegate from edgetpu.dll ```
hjonnala commented 2 years ago

@RobertFlatt please try with edgetpu runtime 13. Edgetpu runtime 14 does not work on Windows.

RobertFlatt commented 2 years ago

Works, thank you.

----INFERENCE TIME---- Note: The first inference on Edge TPU is slow because it includes loading the model into Edge TPU memory. 13.2ms 4.4ms 4.3ms 4.3ms 4.3ms -------RESULTS-------- Ara macao (Scarlet Macaw): 0.75781

google-coral-bot[bot] commented 2 years ago

Are you satisfied with the resolution of your issue? Yes No

BasavaG commented 2 years ago

I faced the same issue for long hours (maybe 2days). I Tried the below method and I got the results as expected.
uninstall Edge TPU runtime. reboot the laptop. Try installing a different version of edge tpu. connect USB accelerator. follow the further process.

If everything is ok, then LED on the USB accelerator blinks for a second, and the program runs successfully.

35grain commented 1 year ago

This is just painful. Uninstalled previous version, restarted, installed runtime 13, restarted, plugged tpu in, still broken. It is also weird that for some models it does work but is awfully slow. Using an older runtime also means that the model needs to be compiled with that version btw.