Search code examples
pythonpython-3.xtpugoogle-coral

AttributeError: 'Delegate' object has no attribute '_library'


I am using a Coral Dev Board and I'm facing an error I can't get rid of. I am trying to run on the edgetpu the image classifier example of the official tutorial to get started with the Dev Board. I followed the tutorial step by step however when I run

python3 classify_image.py \
--model models/mobilenet_v2_1.0_224_inat_bird_quant_edgetpu.tflite \
--labels models/inat_bird_labels.txt \
--input images/parrot.jpg

I get the following error

  File "classify_image.py", line 118, in <module>
    main()
  File "classify_image.py", line 95, in main
    interpreter = make_interpreter(args.model)
  File "classify_image.py", line 69, in make_interpreter
    {'device': device[0]} if device else {})
  File "/home/mendel/.local/lib/python3.5/site-packages/tflite_runtime/interpreter.py", line 165, in load_delegate
    delegate = Delegate(library, options)
  File "/home/mendel/.local/lib/python3.5/site-packages/tflite_runtime/interpreter.py", line 89, 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/aarch64-linux-gnu/libc++abi.so.1: undefined symbol: _Unwind_GetRegionStart
Exception ignored in: <bound method Delegate.__del__ of <tflite_runtime.interpreter.Delegate object at 0xffff76ecff98>>
Traceback (most recent call last):
  File "/home/mendel/.local/lib/python3.5/site-packages/tflite_runtime/interpreter.py", line 124, in __del__
    if self._library is not None:
AttributeError: 'Delegate' object has no attribute '_library'

It looks like the way to tell the interpreter to delegate operations on the TPU is incorrect. I saw many people facing the same error but none of them has found a solution. Do you have any ideas ? Thanks in advance.


Solution

  • base on your answer from above, you are running on an older version of MendelOS. The newer kernel should be 4.14.98-imx instead of 4.9.51-imx. Also, cat /etc/os-release:

    PRETTY_NAME="Mendel GNU/Linux 4 (Day)"
    NAME="Mendel GNU/Linux"
    ID=mendel
    ID_LIKE=debian
    HOME_URL="https://coral.withgoogle.com/"
    SUPPORT_URL="https://coral.withgoogle.com/"
    BUG_REPORT_URL="https://coral.withgoogle.com/"
    VERSION_CODENAME="day"
    

    Please re-flash the board with the new system image as instructed here:

    https://coral.ai/docs/dev-board/reflash/#flash-a-new-system-image