google-coral / edgetpu-platforms

EdgeTPU support for other platforms, specifically Raspberry Pi Zero
Apache License 2.0
81 stars 11 forks source link

RPi0 - undefined symbol: libusb_open #33

Closed zamathebest closed 2 years ago

zamathebest commented 4 years ago

Hi, I'm trying to run the tflite examples provided in the repo: https://github.com/google-coral/tflite

I'm trying them inside a RPi0-W which is running Raspbian Scretch and Python3.5 (I'm using the prebuilt image provided for RaspberryPi Zero: https://github.com/google-coral/edgetpu-platforms)

I've downloaded and installed Tensorflow 2.3.0 using PIP following the official procedure (https://www.tensorflow.org/install/pip). I've installed the wheel for armv6 (https://storage.googleapis.com/tensorflow/raspberrypi/tensorflow-2.3.0-cp35-none-linux_armv6l.whl) and everything went great.

I had to modify the examples because there are few things to fix as the full tensorflow installation is not the same as the _tfliteruntime :

1)

import tensorflow.lite as tflite

instead of

import tflite_runtime.interpreter as tflite

2)

EDGETPU_SHARED_LIB = {
  'Linux': 'libedgetpu.so.1.0',
  'Darwin': 'libedgetpu.1.dylib',
  'Windows': 'edgetpu.dll'
}[platform.system()]

instead of

EDGETPU_SHARED_LIB = {
  'Linux': 'libedgetpu.so.1',
  'Darwin': 'libedgetpu.1.dylib',
  'Windows': 'edgetpu.dll'
}[platform.system()]

this is due to the fact that the name of the .so libary for the edgetpu 1.9.2 is not the same as the one provided in the example. Looking at the /usr/lib/arm-linux-gnueabihf/ I find:

libedgetpu.so libedgetpu.so.1.0 but no libedgetpu.so.1 which was leading to the error

OSError: libedgetpu.so.1: cannot open shared object file: No such file or directory

3)

experimental_delegates=[
          tflite.experimental.load_delegate(EDGETPU_SHARED_LIB,
                               {'device': device[0]} if device else {})
      ])

instead of

experimental_delegates=[
          tflite.load_delegate(EDGETPU_SHARED_LIB,
                               {'device': device[0]} if device else {})
      ])

Once I execute the classify_image.py example I got an error related to an undefined symbol "libusb_open":

Traceback (most recent call last):
  File "detect_image.py", line 130, in <module>
    main()
  File "detect_image.py", line 95, in main
    interpreter = make_interpreter(args.model)
  File "detect_image.py", line 62, in make_interpreter
    {'device': device[0]} if device else {})
  File "/usr/local/lib/python3.5/dist-packages/tensorflow/lite/python/interpreter.py", line 150, in load_delegate
    delegate = Delegate(library, options)
  File "/usr/local/lib/python3.5/dist-packages/tensorflow/lite/python/interpreter.py", line 79, in __init__
    self._library = ctypes.pydll.LoadLibrary(library)
  File "/usr/lib/python3.5/ctypes/__init__.py", line 425, in LoadLibrary
    return self._dlltype(name)
  File "/usr/lib/python3.5/ctypes/__init__.py", line 347, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: /usr/lib/arm-linux-gnueabihf/libedgetpu.so.1.0: undefined symbol: libusb_open
Exception ignored in: <bound method Delegate.__del__ of <tensorflow.lite.python.interpreter.Delegate object at 0xb51d2ef0>>
Traceback (most recent call last):
  File "/usr/local/lib/python3.5/dist-packages/tensorflow/lite/python/interpreter.py", line 114, in __del__
    if self._library is not None:
AttributeError: 'Delegate' object has no attribute '_library'

This seems to be a linker issue during the compilation of the library as the libusb symbol cannot be found.

Here the example: classification.zip

Could you please assist on how to solve this issue?

hjonnala commented 2 years ago

Hi, The edgetpu api is deprecated. Please try these instructions https://coral.ai/docs/accelerator/get-started/#requirements without pre built image.

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

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