google-coral / tflite

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

Inference & terminated process with TFLite model & Coral on Windows results in permanent `Failed to load delegate from edgetpu.dll` error #60

Closed Jasonnor closed 1 year ago

Jasonnor commented 1 year ago

Description

Hello, I recently used tfjs-tflite-node to create Coral-related applications, but found that if the application terminated abnormally, Failed to load delegate from edgetpu.dll error would appear in subsequent executions. In some cases, normal termination of the program can also cause this error.

This error will occur permanently unless the USB Accelerator is connected to another USB port. Or uninstalledgetpu_runtime, reboot, and install edgetpu_runtime again (if any steps are missing, the error will still occur).

I have tried to run the official pycoral example (examples/classify_image.py), execute and abort the program abnormally (with Ctrl+C), then the same problem occurs (Failed to load delegate from edgetpu.dll). The solution is also as stated previously.

I am using Coral USB Accelerator on Windows 10 and followed the official instructions to install it. I am using TFLite model compiler version 16.0, so I need edgetpu_runtime_20221024.zip of runtime version 14.

My tfjs-tflite-node program refers to the official CodeLab tutorial, but I don’t think this issue is only on tfjs-tflite-node, because I can reproduce the problem stably using the pycoral example.

I've read #46 and #54, unfortunately, neither can solve this problem, except for the method I mentioned. This would make it difficult for me to productize the Coral app, as it would be very unstable and would require complex procedures to fix.

I hope someone can provide relevant experience or solutions. It would be greatly appreciated, thanks!

Click to expand! ### Issue Type Bug ### Operating System Windows 10 ### Coral Device USB Accelerator ### Other Devices _No response_ ### Programming Language Python 3.9, Other ### Relevant Log Output ```shell Traceback (most recent call last): File "Users\AppData\Local\Programs\Python\Python39\lib\site-packages\tflite_runtime\interpreter.py", line 160, in load_delegate delegate = Delegate(library, options) File "Users\AppData\Local\Programs\Python\Python39\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 "Users\sig-tfjs-main\tfjs-tflite-node-codelab\cpu_inference_working\pycoral\examples\classify_image.py", line 121, in main() File "Users\sig-tfjs-main\tfjs-tflite-node-codelab\cpu_inference_working\pycoral\examples\classify_image.py", line 71, in main interpreter = make_interpreter(*args.model.split('@')) File "Users\AppData\Local\Programs\Python\Python39\lib\site-packages\pycoral\utils\edgetpu.py", line 52, in load_edgetpu_delegate return tflite.load_delegate(_EDGETPU_SHARED_LIB, options or {}) File "Users\AppData\Local\Programs\Python\Python39\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 1 year ago

Hi @Jasonnor can you try with previous runtime libusb version(replace c:/windows/system32/libusb-1.0.dll with edgetpu_runtime_20210119/edgetpu_runtime/third_party/libsub_win/libusb-1.0.dll).

Jasonnor commented 1 year ago

previous runtime libusb version(replace c:/windows/system32/libusb-1.0.dll with edgetpu_runtime_20210119/edgetpu_runtime/third_party/libsub_win/libusb-1.0.dll).

Thanks, it works!

Now the abnormal termination program will not cause the same error again, I will continue to try and ask you if there is any problem, thank you!

google-coral-bot[bot] commented 1 year ago

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