Skip to content
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

Edge TPU lifespan resulted in Failed to load delegate #589

Closed
smart-face opened this issue May 10, 2022 · 10 comments
Closed

Edge TPU lifespan resulted in Failed to load delegate #589

smart-face opened this issue May 10, 2022 · 10 comments
Assignees
Labels
comp:model Model related isssues Hardware:Dev Board Coral Dev Board issues Hardware:SoM Coral System-on-Module (SoM) issues subtype:Mendel Linux Mendel Linux Build/installation issues type:performance Performance issues

Comments

@smart-face
Copy link

smart-face commented May 10, 2022

Description

I have used Dev board SoM continuously for 2 years in the following two cases:
case (1) EdgeTPU lasted about 8 months for continuous object detection (without motion sensing) on the mobilenetSSD model and now I got the following error,
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "face_run.py", line 129, in
experimental_delegates=[load_delegate('libedgetpu.so.1.0')])
File "/usr/local/lib/python3.7/dist-packages/tflite_runtime/interpreter.py", line 163, in load_delegate
library, str(e)))
ValueError: Failed to load delegate from libedgetpu.so.1.0

case (2) A model inference is only performed when a motion is detected in the camera scene, and this device lasted about 1.5 years, and again I got the same error as above.
Then, I performed and device query so there are no available TPU devices.
image

Any luck on extending the lifespan of EdgeTPU or solving these errors?

Click to expand!

Issue Type

Performance

Operating System

Mendel Linux

Coral Device

Dev Board

Other Devices

No response

Programming Language

Python 3.7

Relevant Log Output

No response

@google-coral-bot google-coral-bot bot added comp:model Model related isssues Hardware:Dev Board Coral Dev Board issues Hardware:SoM Coral System-on-Module (SoM) issues subtype:Mendel Linux Mendel Linux Build/installation issues type:performance Performance issues labels May 10, 2022
@smart-face smart-face changed the title Edge TPU del Edge TPU lifespan resulted in Failed to load delegate May 10, 2022
@hjonnala
Copy link
Contributor

Hello @smart-face can you please update/reflash the mendel software and share the output of following commands.

mendel@undefined-apple:~$ uname -r
4.14.98-imx
mendel@undefined-apple:~$ cat /etc/mendel_version
5.3
Python 3.9.7 (default, Sep  3 2021, 06:18:44) 
[GCC 10.2.1 20210110] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tflite_runtime as tflite
>>> import pycoral
>>> from pycoral.utils.edgetpu import get_runtime_version
>>> get_runtime_version()
'BuildLabel(COMPILER=6.3.0 20170516,DATE=redacted,TIME=redacted), RuntimeVersion(14)'
>>> tflite.__version__
'2.5.0.post1'
>>> pycoral.__version__
'2.0.0'
>>> from pycoral.pybind._pywrap_coral import ListEdgeTpus as list_edge_tpus
>>> list_edge_tpus()
[{'type': 'pci', 'path': '/dev/apex_0'}]

@sharoseali
Copy link

Hi, I am using py coral on raspberry PI4 with a USB edge TPU accelerator. I get the same error when I run the example code provided in pycoral. I also download edge you runtime repo from here https://github.com/google-coral/libedgetpu/releases/download/release-grouper/edgetpu_runtime_20210726.zip and run install.sh to generate libedgetpu.so library for my armv7l device and then I change the path to newly generated .so file. But still I get the same error.
My Error logs are printed below:

python3 make_inference_pycoral.py 
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/tflite_runtime/interpreter.py", line 162, in load_delegate
    delegate = Delegate(library, options)
  File "/usr/lib/python3/dist-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 "make_inference_pycoral.py", line 17, in <module>
    interpreter = make_interpreter(model_file)
  File "/usr/local/lib/python3.7/dist-packages/pycoral/utils/edgetpu.py", line 87, in make_interpreter
    delegates = [load_edgetpu_delegate({'device': device} if device else {})]
  File "/usr/local/lib/python3.7/dist-packages/pycoral/utils/edgetpu.py", line 52, in load_edgetpu_delegate
    return tflite.load_delegate(_EDGETPU_SHARED_LIB, options or {})
  File "/usr/lib/python3/dist-packages/tflite_runtime/interpreter.py", line 166, in load_delegate
    library, str(e)))
ValueError: Failed to load delegate from libedgetpu.so.1

After generating new libedgetpu.so and changing path in "/usr/lib/python3/dist-packages/tflite_runtime/interpreter.py" I get again the same issue:

 $ python3 make_inference_pycoral.py 
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/tflite_runtime/interpreter.py", line 162, in load_delegate
    delegate = Delegate(library, options)
  File "/usr/lib/python3/dist-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 "make_inference_pycoral.py", line 17, in <module>
    interpreter = make_interpreter(model_file)
  File "/usr/local/lib/python3.7/dist-packages/pycoral/utils/edgetpu.py", line 87, in make_interpreter
    delegates = [load_edgetpu_delegate({'device': device} if device else {})]
  File "/usr/local/lib/python3.7/dist-packages/pycoral/utils/edgetpu.py", line 52, in load_edgetpu_delegate
    return tflite.load_delegate(_EDGETPU_SHARED_LIB, options or {})
  File "/usr/lib/python3/dist-packages/tflite_runtime/interpreter.py", line 166, in load_delegate
    library, str(e)))
ValueError: Failed to load delegate from /usr/lib/arm-linux-gnueabihf/libedgetpu.so.1.0

any help or suggestion. Thanks

@hjonnala
Copy link
Contributor

@sharoseali can you please share the output of below commands:

  • ls -al /usr/lib/arm-linux-gnueabihf/libedgetpu*
  • python3 -c 'from pycoral.utils.edgetpu import get_runtime_version; print(get_runtime_version())'

@sharoseali
Copy link

@sharoseali can you please share the output of below commands:

  • ls -al /usr/lib/arm-linux-gnueabihf/libedgetpu*
  • python3 -c 'from pycoral.utils.edgetpu import get_runtime_version; print(get_runtime_version())'

Here are the results

ls -al /usr/lib/arm-linux-gnueabihf/libedgetpu*
lrwxrwxrwx 1 root root     17 Jul  9  2021 /usr/lib/arm-linux-gnueabihf/libedgetpu.so.1 -> libedgetpu.so.1.0
-rw-r--r-- 1 root root 780032 May 23 11:29 /usr/lib/arm-linux-gnueabihf/libedgetpu.so.1.0

python3 -c 'from pycoral.utils.edgetpu import get_runtime_version; print(get_runtime_version())'
BuildLabel(COMPILER=6.3.0 20170516,DATE=redacted,TIME=redacted), RuntimeVersion(14)

Good News !! I managed to make it work by using libedgetpu.so.1 from usr/lib/arm-linux-gnueabihf/ by running python3 with sudo and it worked. Without sudo even if you point usr/lib/arm-linux-gnueabihf/libedgtpu.so.1 it didn't work. Thanks for your reply and sorry for my late reply.

@hjonnala
Copy link
Contributor

@sharoseali can you please try changing the permissions so that you don't need to run with sudo.

sudo chmod +rwx /usr/lib/arm-linux-gnueabihf/libedgetpu.so.1.0
sudo chmod +rwx /usr/lib/arm-linux-gnueabihf/libedgetpu.so.1

@sharoseali
Copy link

Thanks @hjonnala i tried but it gives the same message without sudo

python3 inference_TFLite.py --video ./test.mp4 --model best-int8_edgetpu.tflite

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/tflite_runtime/interpreter.py", line 162, in load_delegate
    delegate = Delegate(library, options)
  File "/usr/lib/python3/dist-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 "inference_TFLite_YOLO_with_nms.py", line 266, in <module>
    model_path=model, experimental_delegates=[tflite.load_delegate(_EDGETPU_SHARED_LIB,  {})])
  File "/usr/lib/python3/dist-packages/tflite_runtime/interpreter.py", line 166, in load_delegate
    library, str(e)))
ValueError: Failed to load delegate from /usr/lib/arm-linux-gnueabihf/libedgetpu.so.1

@smart-face
Copy link
Author

Hello @smart-face can you please update/reflash the mendel software and share the output of following commands.

mendel@undefined-apple:~$ uname -r
4.14.98-imx
mendel@undefined-apple:~$ cat /etc/mendel_version
5.3
Python 3.9.7 (default, Sep  3 2021, 06:18:44) 
[GCC 10.2.1 20210110] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tflite_runtime as tflite
>>> import pycoral
>>> from pycoral.utils.edgetpu import get_runtime_version
>>> get_runtime_version()
'BuildLabel(COMPILER=6.3.0 20170516,DATE=redacted,TIME=redacted), RuntimeVersion(14)'
>>> tflite.__version__
'2.5.0.post1'
>>> pycoral.__version__
'2.0.0'
>>> from pycoral.pybind._pywrap_coral import ListEdgeTpus as list_edge_tpus
>>> list_edge_tpus()
[{'type': 'pci', 'path': '/dev/apex_0'}]

Hello, sorry for the delay, the first device with continuous inference was not showing any of the PCI devices, and later it started heating up more so I dumped it. I tried flashing a new installation.

For a second case, I figured out the issue by reinstalling a new Mendel. There was a problem with a kernel module that handles the socket connections. BTW thanks for the replay.

@hjonnala
Copy link
Contributor

@smart-face Thanks for response. Can you please confirm that issue got resolved with new Mendel software for the second case. Thanks!

@smart-face
Copy link
Author

smart-face commented May 26, 2022 via email

@google-coral-bot
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
comp:model Model related isssues Hardware:Dev Board Coral Dev Board issues Hardware:SoM Coral System-on-Module (SoM) issues subtype:Mendel Linux Mendel Linux Build/installation issues type:performance Performance issues
Projects
None yet
Development

No branches or pull requests

3 participants