blakeblackshear / frigate

NVR with realtime local object detection for IP cameras
https://frigate.video
MIT License
19.02k stars 1.74k forks source link

[Detector Support]: Frigate detects only one Coral #7069

Closed PilaScat closed 1 year ago

PilaScat commented 1 year ago

Describe the problem you are having

I have a Dual Edge TPU (https://coral.ai/products/m2-accelerator-dual-edgetpu) I'm passing it to docker via /dev/apex_0 but when I add two coral it tells me: ValueError: Failed to load delegate from libedgetpu.so.1.0

Version

0.12.1-367D724

Frigate config file

WORKING
detectors:
  coral:
    type: edgetpu
    device: pci:0

NOT WORKING BUT IT SHOULD
detectors:
  coral1:
    type: edgetpu
    device: pci:0
  coral2:
    type: edgetpu
    device: pci:1

docker-compose file or Docker CLI command

docker run
  -d
  --name='Frigate'
  --net='docker-network'
  --privileged=true
  -e TZ="Europe/Berlin"
  -e HOST_OS="Unraid"
  -e HOST_HOSTNAME="unRAID"
  -e HOST_CONTAINERNAME="Frigate"
  -e 'FRIGATE_RTSP_PASSWORD'='pwd'
  -e 'LIBVA_DRIVER_NAME'='iHD'
  -l net.unraid.docker.managed=dockerman
  -l net.unraid.docker.webui='http://[IP]:[PORT:5000]'
  -l net.unraid.docker.icon='https://raw.githubusercontent.com/yayitazale/unraid-templates/main/frigate.png'
  -p '5000:5000/tcp'
  -p '8554:8554/tcp'
  -p '8555:8555/tcp'
  -p '8555:8555/udp'
  -p '1984:1984/tcp'
  -v '/mnt/user/appdata/frigate':'/config':'rw'
  -v '/mnt/user/nvr/':'/media/frigate':'rw'
  -v '/etc/localtime':'/etc/localtime':'rw'
  --device='/dev/apex_0'
  --device='/dev/dri/renderD128'
  --shm-size=256mb
  --mount type=tmpfs,target=/tmp/cache,tmpfs-size=100000000
  --restart unless-stopped 'ghcr.io/blakeblackshear/frigate:stable'

Relevant log output

2023-07-07 11:09:43.036734785  [2023-07-07 11:09:43] frigate.detectors.plugins.edgetpu_tfl INFO    : Attempting to load TPU as pci:0
2023-07-07 11:09:43.039687516  [2023-07-07 11:09:43] frigate.detectors.plugins.edgetpu_tfl INFO    : Attempting to load TPU as pci:1
2023-07-07 11:09:43.039690489  Process detector:coral2:
2023-07-07 11:09:43.039735651  [2023-07-07 11:09:43] frigate.detectors.plugins.edgetpu_tfl INFO    : TPU found
2023-07-07 11:09:43.039767132  [2023-07-07 11:09:43] frigate.detectors.plugins.edgetpu_tfl ERROR   : No EdgeTPU was detected. If you do not have a Coral device yet, you must configure CPU detectors.
2023-07-07 11:09:43.040312337  Traceback (most recent call last):
2023-07-07 11:09:43.040321935    File "/usr/lib/python3/dist-packages/tflite_runtime/interpreter.py", line 160, in load_delegate
2023-07-07 11:09:43.040323001      delegate = Delegate(library, options)
2023-07-07 11:09:43.040324265    File "/usr/lib/python3/dist-packages/tflite_runtime/interpreter.py", line 119, in __init__
2023-07-07 11:09:43.040326723      raise ValueError(capture.message)
2023-07-07 11:09:43.040330449  ValueError
2023-07-07 11:09:43.040331187  
2023-07-07 11:09:43.040332029  During handling of the above exception, another exception occurred:
2023-07-07 11:09:43.040332819  
2023-07-07 11:09:43.040333814  Traceback (most recent call last):
2023-07-07 11:09:43.040338239    File "/usr/lib/python3.9/multiprocessing/process.py", line 315, in _bootstrap
2023-07-07 11:09:43.040339080      self.run()
2023-07-07 11:09:43.040340000    File "/usr/lib/python3.9/multiprocessing/process.py", line 108, in run
2023-07-07 11:09:43.040340936      self._target(*self._args, **self._kwargs)
2023-07-07 11:09:43.040341955    File "/opt/frigate/frigate/object_detection.py", line 98, in run_detector
2023-07-07 11:09:43.040342918      object_detector = LocalObjectDetector(detector_config=detector_config)
2023-07-07 11:09:43.040344446    File "/opt/frigate/frigate/object_detection.py", line 52, in __init__
2023-07-07 11:09:43.040356938      self.detect_api = create_detector(detector_config)
2023-07-07 11:09:43.040358190    File "/opt/frigate/frigate/detectors/__init__.py", line 24, in create_detector
2023-07-07 11:09:43.040359194      return api(detector_config)
2023-07-07 11:09:43.040360138    File "/opt/frigate/frigate/detectors/plugins/edgetpu_tfl.py", line 37, in __init__
2023-07-07 11:09:43.040377281      edge_tpu_delegate = load_delegate("libedgetpu.so.1.0", device_config)
2023-07-07 11:09:43.040382939    File "/usr/lib/python3/dist-packages/tflite_runtime/interpreter.py", line 162, in load_delegate
2023-07-07 11:09:43.040383968      raise ValueError('Failed to load delegate from {}\n{}'.format(
2023-07-07 11:09:43.040384882  ValueError: Failed to load delegate from libedgetpu.so.1.0

Operating system

UNRAID

Install method

Docker CLI

Coral version

M.2

Any other information that may be helpful

No response

NickM-27 commented 1 year ago

Your docker cli command is only passing one coral not both

PilaScat commented 1 year ago

Your docker cli command is only passing one coral not both

How could I fix? I have only apex_0 (and the two tpu are on the same chip)

NickM-27 commented 1 year ago

if your dual tpu is working correctly there will also be apex_1. If you don't see apex_1 that is because your system does not support multiple buses on the m.2 e interface. see https://github.com/magic-blue-smoke/Dual-Edge-TPU-Adapter for more info

PilaScat commented 1 year ago

Sad, thanks, I waited 1 year to get this and now I can't use it full potential At least i'm getting 5ms inference speed In the future I'll get the pci adapter