google-coral / edgetpu

Coral issue tracker (and legacy Edge TPU API source)
https://coral.ai
Apache License 2.0
412 stars 124 forks source link

Failed to load delegate from edgetpu.dll #769

Open andreamaglione opened 1 year ago

andreamaglione commented 1 year ago

Description

C:|Users\pycoral>py examples/detect_image.py -m test_data/efficientdet-lite-mini_dataset.tflite -l test_data/labels.txt -i test_data/prova.jpg -o test_data/result.jpg Traceback (most recent call last): File "C:\Python\Python39\lib\site-packages\tflite_runtime\interpreter.py", line 160, in load_delegate delegate = Delegate(library, options) File "C:\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 "C:\Users\pycoral\examples\detect_image.py", line 108, in main() File "C:\Users\pycoral\examples\detect_image.py", line 73, in main interpreter = make_interpreter(args.model) File "C:\Python\Python39\lib\site-packages\pycoral\utils\edgetpu.py", line 87, in make_interpreter delegates = [load_edgetpu_delegate({'device': device} if device else {})] File "C:\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 "C:\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

Any ideas how to fix?

Click to expand! ### Issue Type Support ### Operating System Windows 10 ### Coral Device USB Accelerator ### Other Devices _No response_ ### Programming Language Python 3.8, Python 3.9 ### Relevant Log Output _No response_
hjonnala commented 1 year ago

@andreamaglione have you installed the edgetpu runtime.

If yes, please add the below lines at import section in your test script and share the logs:

from pycoral.pybind._pywrap_coral import SetVerbosity as set_verbosity
set_verbosity(10)
melyux commented 11 months ago

@hjonnala I have the same issue, and already tried your suggestion here without any luck. I added the lines to the example classify_image.py and got this output:

I tflite/edgetpu_manager_direct.cc:453] No matching device is already opened for shared ownership.
I driver/usb/local_usb_device.cc:944] EnumerateDevices: vendor:0x1a6e, product:0x89a
I driver/usb/local_usb_device.cc:979] EnumerateDevices: checking bus[1] port[1]
I driver/usb/local_usb_device.cc:998] EnumerateDevices: found [/sys/bus/usb/devices/1-1]
I driver/usb/local_usb_device.cc:944] EnumerateDevices: vendor:0x18d1, product:0x9302
I driver/usb/local_usb_device.cc:979] EnumerateDevices: checking bus[1] port[1]
I driver/beagle/beagle_usb_driver_provider.cc:218] Enumerate: adding path [/sys/bus/usb/devices/1-1]
I driver/driver_factory_windows.cc:29] DriverFactoryWin::EnumerateByClass()...
I driver/driver_factory_windows.cc:75] DriverFactoryWin::EnumerateByClass returns empty list.
I tflite/edgetpu_manager_direct.cc:471] No device of type Apex (PCIe) is available.
I tflite/edgetpu_context_direct.cc:106] USB always DFU: False (default)
I tflite/edgetpu_context_direct.cc:147] USB bulk-in queue capacity: 8
I tflite/edgetpu_context_direct.cc:63] Performance expectation: High when USB connected EdgeTpu is throttled
I driver/usb/usb_driver.cc:1383] Open device and check if DFU is needed
I driver/usb/local_usb_device.cc:1013] OpenDevice: [/sys/bus/usb/devices/1-1]
I driver/usb/local_usb_device.cc:1050] OpenDevice: checking bus[1] port[1]
I driver/usb/local_usb_device.cc:1081] OpenDevice: device opened 000002049AF8B340
I driver/usb/local_usb_device.cc:184] LocalUsbDevice
I driver/usb/usb_standard_commands.cc:36] UsbStandardCommands
I driver/usb/usb_dfu_commands.cc:37] UsbDfuCommands
I driver/usb/usb_standard_commands.cc:43] GetDeviceDescriptor
I driver/usb/local_usb_device.cc:398] GetDescriptor
I driver/usb/usb_standard_commands.cc:78] Vender ID: 0x1a6e
I driver/usb/usb_standard_commands.cc:79] Product ID: 0x89a
I driver/usb/usb_driver.cc:1417] Device is in DFU mode
I driver/usb/usb_driver.cc:1422] Resetting device
I driver/usb/local_usb_device.cc:243] Close: closing device 000002049AF8B340
I driver/usb/local_usb_device.cc:216] DoCancelAllTransfers: cancelling 0 async transfers
I driver/usb/local_usb_device.cc:224] DoCancelAllTransfers: waiting for all async transfers to complete
I driver/usb/local_usb_device.cc:234] DoCancelAllTransfers: all async transfers have completed
I driver/usb/local_usb_device.cc:276] Close: releasing 0 transfer buffers
I driver/usb/local_usb_device.cc:289] Close: performing graceful reset
I driver/usb/local_usb_device.cc:322] Close: final clean up completed
I driver/usb/usb_driver.cc:1432] Opening device expecting DFU mode
I driver/usb/local_usb_device.cc:1013] OpenDevice: [/sys/bus/usb/devices/1-1]
I driver/usb/local_usb_device.cc:1050] OpenDevice: checking bus[1] port[1]
I driver/usb/local_usb_device.cc:1081] OpenDevice: device opened 000002049AF8B340
I driver/usb/local_usb_device.cc:184] LocalUsbDevice
I driver/usb/usb_standard_commands.cc:36] UsbStandardCommands
I driver/usb/usb_dfu_commands.cc:37] UsbDfuCommands
I driver/usb/usb_dfu_commands.cc:40] ~UsbDfuCommands
I driver/usb/usb_standard_commands.cc:39] ~UsbStandardCommands
I driver/usb/local_usb_device.cc:196] ~LocalUsbDevice
I driver/usb/local_usb_device.cc:243] Close: closing device 0000000000000000
I driver/usb/usb_driver.cc:1450] DFU with built-in firmware image
I driver/usb/usb_dfu_util.cc:62] UsbUpdateDfuDevice Loading descriptor for the first configuration
I driver/usb/usb_standard_commands.cc:87] GetConfigurationDescriptor index 1
I driver/usb/local_usb_device.cc:398] GetDescriptor
I driver/usb/usb_standard_commands.cc:116] Configuration requested: 1
I driver/usb/usb_standard_commands.cc:117] Configuration reported: 1
I driver/usb/usb_standard_commands.cc:119] Number of interfaces: 1
I driver/usb/usb_standard_commands.cc:121] Is self powered: 0
I driver/usb/usb_standard_commands.cc:122] Supports remote wakeup: 0
I driver/usb/usb_standard_commands.cc:124] Encoded max power: 0x0
I driver/usb/usb_standard_commands.cc:126] Raw data size: 27
I driver/usb/usb_dfu_commands.cc:103] FindDfuInterfaces cursor 9
I driver/usb/usb_dfu_commands.cc:108] FindDfuInterfaces type 0x4, length 9
I driver/usb/usb_dfu_commands.cc:134] FindDfuInterfaces interface 0, alternate settings 0, num of extra endpoints 0, class 0xfe, subclass 0x1
I driver/usb/usb_dfu_commands.cc:103] FindDfuInterfaces cursor 18
I driver/usb/usb_dfu_commands.cc:108] FindDfuInterfaces type 0x21, length 9
I driver/usb/usb_dfu_commands.cc:180] Will detach: 0, manifestation tolerant: 1
I driver/usb/usb_dfu_commands.cc:183] Can upload: 1, can download: 1
I driver/usb/usb_dfu_commands.cc:186] Transfer Size: 0x100
I driver/usb/usb_dfu_commands.cc:188] Detach Timeout: 0x3e8
I driver/usb/usb_dfu_commands.cc:190] DFU version in BCD: 0x101
I driver/usb/usb_dfu_commands.cc:103] FindDfuInterfaces cursor 27
I driver/usb/usb_dfu_util.cc:77] UsbUpdateDfuDevice Num of DFU interfaces 1, claiming interface 0
I driver/usb/local_usb_device.cc:352] ClaimInterface
I driver/usb/usb_dfu_commands.cc:68] SetDfuInterface set to 0
I driver/usb/usb_dfu_commands.cc:411] UpdateFirmware Downloading firmware
I driver/usb/usb_dfu_commands.cc:417] UpdateFirmware Firmware image size 10783 bytes
I driver/usb/usb_dfu_commands.cc:435] UpdateFirmware Transfer size 256 bytes, already transferred 0 bytes
I driver/usb/usb_dfu_commands.cc:351] DfuDownloadBlock block 0, request size 256
I driver/usb/local_usb_device.cc:475] SendControlCommandWithDataOut
I driver/usb/local_usb_device.cc:482] SYNC CTRL WITH DATA OUT begin
I driver/usb/local_usb_device.cc:60] ConvertLibUsbError: USB error -1 [DfuDownloadBlock]
I driver/usb/local_usb_device.cc:125] [DfuDownloadBlock] failed [1].
I driver/usb/local_usb_device.cc:60] ConvertLibUsbError: USB error -1 [DfuDownloadBlock]
I driver/usb/local_usb_device.cc:125] [DfuDownloadBlock] failed [2].
I driver/usb/local_usb_device.cc:60] ConvertLibUsbError: USB error -1 [DfuDownloadBlock]
I driver/usb/local_usb_device.cc:125] [DfuDownloadBlock] failed [3].
I driver/usb/local_usb_device.cc:60] ConvertLibUsbError: USB error -1 [DfuDownloadBlock]
I driver/usb/local_usb_device.cc:125] [DfuDownloadBlock] failed [4].
I driver/usb/local_usb_device.cc:60] ConvertLibUsbError: USB error -1 [DfuDownloadBlock]
I driver/usb/local_usb_device.cc:125] [DfuDownloadBlock] failed [5].
I driver/usb/local_usb_device.cc:60] ConvertLibUsbError: USB error -1 [DfuDownloadBlock]
I driver/usb/usb_dfu_commands.cc:40] ~UsbDfuCommands
I driver/usb/usb_standard_commands.cc:39] ~UsbStandardCommands
I driver/usb/local_usb_device.cc:196] ~LocalUsbDevice
I driver/usb/local_usb_device.cc:243] Close: closing device 000002049AF8B340
I driver/usb/local_usb_device.cc:263] Close: releasing claimed interface 0
I driver/usb/local_usb_device.cc:216] DoCancelAllTransfers: cancelling 0 async transfers
I driver/usb/local_usb_device.cc:224] DoCancelAllTransfers: waiting for all async transfers to complete
I driver/usb/local_usb_device.cc:234] DoCancelAllTransfers: all async transfers have completed
I driver/usb/local_usb_device.cc:276] Close: releasing 0 transfer buffers
I driver/usb/local_usb_device.cc:322] Close: final clean up completed
I tflite/edgetpu_context_direct.cc:401] Failed to open device [Apex (USB)] at [/sys/bus/usb/devices/1-1]: Unknown: USB error -1 [DfuDownloadBlock]
Traceback (most recent call last):
  File "C:\Program Files\CodeProject\AI\modules\ObjectDetectionCoral\bin\windows\python37\venv\lib\site-packages\tflite_runtime\interpreter.py", line 160, in load_delegate
    delegate = Delegate(library, options)
  File "C:\Program Files\CodeProject\AI\modules\ObjectDetectionCoral\bin\windows\python37\venv\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 "C:\Users\melyux\Downloads\classify_image.py", line 124, in <module>
    main()
  File "C:\Users\melyux\Downloads\classify_image.py", line 74, in main
    interpreter = make_interpreter(*args.model.split('@'))
  File "C:\Program Files\CodeProject\AI\modules\ObjectDetectionCoral\bin\windows\python37\venv\lib\site-packages\pycoral\utils\edgetpu.py", line 87, in make_interpreter
    delegates = [load_edgetpu_delegate({'device': device} if device else {})]
  File "C:\Program Files\CodeProject\AI\modules\ObjectDetectionCoral\bin\windows\python37\venv\lib\site-packages\pycoral\utils\edgetpu.py", line 52, in load_edgetpu_delegate
    return tflite.load_delegate(_EDGETPU_SHARED_LIB, options or {})
  File "C:\Program Files\CodeProject\AI\modules\ObjectDetectionCoral\bin\windows\python37\venv\lib\site-packages\tflite_runtime\interpreter.py", line 163, in load_delegate
    library, str(e)))
ValueError: Failed to load delegate from edgetpu.dll
melyux commented 10 months ago

Errors went away after I ran the examples on Linux bare metal. I guess it was trying to update the firmware of the Coral through the Windows VM, and that caused USB hotplugging issues. Running it bare metal on Linux must have updated the firmware. Now works over Windows VM (at least until the next firmware update...).