jveitchmichaelis / edgetpu-yolo

Minimal-dependency Yolov5 and Yolov8 export and inference demonstration for the Google Coral EdgeTPU
101 stars 31 forks source link

Failed to load delegate from libedgetpu.so.1 #6

Closed kirkanshin closed 2 years ago

kirkanshin commented 2 years ago

When running python3 detect.py -m yolov5s-int8-224_edgetpu.tflite --bench_image from the docker, I got the following error

INFO:EdgeTPUModel:Confidence threshold: 0.25
INFO:EdgeTPUModel:IOU threshold: 0.45
INFO:EdgeTPUModel:Loaded 80 classes
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/tflite_runtime/interpreter.py", line 160, 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 "detect.py", line 47, in <module>
    model = EdgeTPUModel(args.model, args.names, conf_thresh=args.conf_thresh, iou_thresh=args.iou_thresh)
  File "/yolo/edgetpumodel.py", line 56, in __init__
    self.make_interpreter()
  File "/yolo/edgetpumodel.py", line 81, in make_interpreter
    self.interpreter = etpu.make_interpreter(self.model_file)
  File "/usr/lib/python3/dist-packages/pycoral/utils/edgetpu.py", line 87, in make_interpreter
    delegates = [load_edgetpu_delegate({'device': device} if device else {})]
  File "/usr/lib/python3/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 162, in load_delegate
    raise ValueError('Failed to load delegate from {}\n{}'.format(
ValueError: Failed to load delegate from libedgetpu.so.1
jveitchmichaelis commented 2 years ago

How are you launching Docker? If you have a device connected to your system you need to provide the container access to your hardware.

That error (failed to load delegate) sounds like your device can't be found.

What if you run lsusb/lspci inside the container?

See https://coral.ai/docs/notes/build-coral/#troubleshooting

kirkanshin commented 2 years ago

I am launching it with docker-compose. Indeed, the problem was due to no container access to the hardware. The problem was solved by specifying privileged: true in docker-compose.yml