-
Notifications
You must be signed in to change notification settings - Fork 74.7k
Failed to load delegate from libedgetpu.so.1.0 with tflite_runtime 1.14 #32743
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Hi @Namburger , I had the same issue! Make sure your Coral USB Accelerator is plugged in when you run your code. If the USB Accelerator isn't plugged in when you call the 'load_delegate' function, it will result in that error. If it IS plugged in, that error won't occur. |
I am facing the same issue , even when the USB accelerator is plugged in and the LED in it is shining bright ........ |
@EdjeElectronics wow... you were correct... thanks. |
@programmer290399 you might need to add your linux user to plugdev group:
|
I plugged in the device, and I did this too, it still is showing the same error. I am using ubuntu installed on a virtualbox in Mac. The USB device is getting attached, but load_delegate is giving error |
@krishna-nag ahh, I see, most likely the usb device isn't detected in your VM. Possibly this will help: https://dev.to/kojikanao/coral-edgetpu-usb-with-virtualbox-57e1 |
I got the same problem in native Ubuntu. Reboot helps. |
There were two issues that needed resolving on my setup, coming from a fresh installed Pi 4 + fresh installed edge TPU.
|
Thanks @cruzzer for the suggestions! Does anyone have tried to use the TPU with a program in a Docker container? |
@adr-arroyo you can check this out :) |
OS env:
runtime error message:
checked as below:
|
Thanks @Namburger ! Now my program is able to use the TPU from docker, I had to add |
I have another question for you guys, In my case I cast float32 values between (0 and 1) to uint8, then I need this cast back to a proper float32 values to use my scaler and descale the results. |
same issue on a raspberry pi
|
rebooting my pi - fixed the issue for me |
In my case, Coral USB accelerator works on USB3.0 so, I've changed USB compatibility option to USB 3.0 and it solved. |
by the way guys, please also upgrading the tflite_runtime package. |
Can you explain how you did that? |
@Syirrus are you still having the same issue? |
I installed the tflite_runtime-2.1.0 (tflite_runtime-2.1.0.post1-cp37-cp37m-linux_armv7l.whl). I still get the same behavior on a RPI4. However, if I plug the coral USB stick in to a USB 2.0 port, instead of the USB3.0 port it works. When I switch to the native 3.0 USB port on the RPI4 I get the same error as above. In fact, after I run the classification script and they run a lsusb, the Coral USB stick is no longer attached logically to the system, though physically it is still plugged in. |
Does that make sense? |
Exactly, it is working on USB 2.0, but NOT USB 3.0 which is a bottleneck :(. I will check out the link to RPI4 issues. Thank you so much! |
No problems! |
After spending many hours on and off thinking about this problem and combing the net, I finally solved this problem with this "Failed to load delegate from libedgetpu.so.1.0 error". Essentially, the cable that Google provided with my Coral USB TPU stinks. I broke down and purchased a USB 3.1 (10Gbps) (NOT 5Gbps) cable and everything worked perfectly on the USB 3.0 port for the Raspberry Pi 4b (4GB). I hope this helps someone else in the same situation I was in. |
Weird as it may seem, I can confirm what @Syirrus reports. After many hours of fighting this error, it finally worked when I changed the USB cable. Thanks! |
I recently moved from a USB 2.0 system to USB 3.0 and had the same issue. It is intermittent, so it's not a plugdev issue. As suggested above it does seem to be an issue with Google’s cable. I bought this cable and replaced the google provided cable. That seems to have completely eliminated the issue and I’m getting good inference speed (averaging 19ms for an 800px image using mobiledet and pycoral wrappers) |
I am getting the same error, running a docker in win10...Using Google coral edge tpu pci version |
(last edit: May 28,2021, to handle situation when lsusb works, but coral doesn't load the library) I'm going to leave another finding here (Only applies to intermittent libedgetpu delegate loading issues, unrelated to plugdev/permissions)
So the rest of the post is how I go about detecting failure and then I reset the full USB system.
So to make sure the device always works, I do the following:
Specifically, I have set up a cron file that checks that the coral device is detected every hour:
The modified script (credit above in my notes): pp@homeserver:~$ cat /usr/local/bin/usb_reset_all.sh
#!/bin/bash
filename='/tmp/coral_status.txt'
now=$(date)
if [[ $EUID != 0 ]] ; then
echo "${now}:$0 must be run as root!"
echo "${now}:$0 must be run as root!" > ${filename}
exit 1
fi
# keep log file to 100 lines
if [ -f "${filename}" ] ;then
echo "$(tail -100 ${filename})" > ${filename}
fi
[[ "${1}" == "--force" ]] && IS_FORCED=true || IS_FORCED=false
is_coral_working() {
# Note if you have multiple results from this lsusb command
# You can specifically check with lsusb -d <deviceid>
# Example: lsusb -d 18d1:9302 in my case which is what lsusb prints as the "ID" for my device
if [[ -z `lsusb | grep -i google` ]] ; then
echo "${now}:lsusb check failed" >> ${filename}
return 0
fi
echo "${now}:lsusb check passed, checking load_edgetpu_delegate()" >> ${filename}
res=`python << HEREDOC
from pycoral.utils.edgetpu import load_edgetpu_delegate
try:
load_edgetpu_delegate()
print ('success')
except Exception as e:
print('error')
HEREDOC
`
if [[ "${res}" = "success" ]] The nice part is my resident services that depend on coral automatically get restarted (not sure how, but it does). So I don't need to restart it manually. |
USB Accelerator connected to a Proxmox VM failure scenario (FIXED) I experienced a similar but different problem when connecting the USB Accelerator to a VM hosted on proxmox: When I plugged the USB Accelerator into the physical machine (proxmox physical host), it showed up like this:
So added device to the VM where I want to work with Coral:
And rebooted the VM. The
After trying a bunch of fixes from this thread, I noticed the USB Accelerator device had changed:
What?! Looks like running the example changed the device host ID of the USB Accelerator (was:
Reboot my VM again. And the sample runs! Also, at one point, I ran this to add myself to the plugdev group, but I'm not sure it this had any effect:
Hope this saves someone a bit of time. \\Joe |
I have the same setup using the tpu on a proxmox VM , added the as a pci device with an adapter. I believe resetting the USB will also work as mentioned above. |
This works for me when my application inside the container is not running as root user. |
System information
pip3 install tflite_runtime-1.14.0-cp36-cp36m-linux_x86_64.whl
Python 3.6.5 :: Anaconda, Inc.
This is the code that I ran:
following this tutorial:
https://www.tensorflow.org/lite/guide/python
This was working before, but somehow broken with this error:
I have been messing around a lot with my machine since by installing different versions of tf. But for the purpose of using the tflite_runtime.interpreter's load_delegate function, shouldn't just the pip install works?
Very weird behavior :/
also I do have
libedgetpu.so.1.0
installed here:Thanks in advance for the help!
[EDIT]
I guess I'll update the issue here with a solution so that any body else can reference:
ValueError: Failed to load delegate from libedgetpu.so.1.0
really is just due to the delegate library not being able to communicate with the edgetpu. This is a very standard linux problem and has nothing to do with the tensorflow library or libedgetpu. The failures most likely stems from some type of errno from the kernel which returns as failure to the user side.So the easiest fix is to run with sudo:
But the most permanent fix is to add your linux user to the
plugdev
group which will allows you to access devices without sudo (this will requires a reboot after):The text was updated successfully, but these errors were encountered: