blakeblackshear / frigate

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

[Detector Support]: Coral USB not detected correctly inside container #7468

Closed meitham closed 1 year ago

meitham commented 1 year ago

Describe the problem you are having

I am running Frigate Docker on Debian as a full privileged container, passing the entire /dev/bus/usb to Docker. I also have libedgetpu1-std installed on the host, and the host can correctly detect my Coral usb as "Google Inc"

image

Though somehow the container cannot see my Coral usb. Rasing the exception

frigate.detectors.plugins.edgetpu_tfl ERROR   : No EdgeTPU was detected. If you do not have a Coral device yet, you must configure CPU detectors
ValueError: Failed to load delegate from libedgetpu.so.1.0

I have EXECed into the container and and install usbutils and I can see the Coral usb not being detected correctly (18d1:9302)

image

I have tried to swap the libedgetpu1-max package with libedgetpu1-std inside the container but that made no difference. Also tried with few different versions of Frigate and none made a difference. What am I doing wrong?

Version

0.12.1-367d724

Frigate config file

...
detectors:
  coral:
    type: edgetpu
    device: usb
...

docker-compose file or Docker CLI command

---
version: "3.9"
services:
  frigate:
    container_name: frigate
    privileged: true
    restart: unless-stopped
    # image: ghcr.io/blakeblackshear/frigate:dev-3921a7f
    image: ghcr.io/blakeblackshear/frigate:stable
    devices:
      - /dev/bus/usb:/dev/bus/usb
      - /dev/dri/renderD128
    volumes:
      - /etc/localtime:/etc/localtime:ro
        # - /data/mnt/config/frigate/config.yml:/config/config.yml:ro
      - ./config.yml:/config/config.yml
      - /mnt/cctv/frigate:/media/frigate
      - /data/cctv/frigate/db:/db
      - type: tmpfs # Optional: 1GB of memory, reduces SSD/SD Card wear
        target: /tmp/cache
        tmpfs:
          size: 1000000000
    ports:
      - "5000:5000"
      - "8554:8554" # RTSP feeds
      - "8555:8555/tcp" # WebRTC over tcp
      - "8555:8555/udp" # WebRTC over udp      
    environment:
      FRIGATE_RTSP_PASSWORD: "password"
      FLASK_DEBUG: 1

Relevant log output

frigate    | 2023-08-14 07:54:09.031931484  [2023-08-14 07:54:08] frigate.detectors.plugins.edgetpu_tfl INFO    : Attempting to load TPU as usb                                                                                                                                           
frigate    | 2023-08-14 07:54:09.032254047  [2023-08-14 07:54:09] frigate.detectors.plugins.edgetpu_tfl ERROR   : No EdgeTPU was detected. If you do not have a Coral device yet, you must configure CPU detectors.
frigate    | 2023-08-14 07:54:09.032259273  Process detector:coral:                                                                                                                                                                                                                       
frigate    | 2023-08-14 07:54:09.035589356  Traceback (most recent call last):                                                              
frigate    | 2023-08-14 07:54:09.035596112    File "/usr/lib/python3/dist-packages/tflite_runtime/interpreter.py", line 160, in load_delegate                                                                                                                                             
frigate    | 2023-08-14 07:54:09.035598656      delegate = Delegate(library, options)                                                           
frigate    | 2023-08-14 07:54:09.035601429    File "/usr/lib/python3/dist-packages/tflite_runtime/interpreter.py", line 119, in __init__    
frigate    | 2023-08-14 07:54:09.035607361      raise ValueError(capture.message)                                                           
frigate    | 2023-08-14 07:54:09.035625922  ValueError                                                                                      
frigate    | 2023-08-14 07:54:09.035628111                                                                                                  
frigate    | 2023-08-14 07:54:09.035630896  During handling of the above exception, another exception occurred:                             
frigate    | 2023-08-14 07:54:09.035633578                                                                                                  
frigate    | 2023-08-14 07:54:09.035635690  Traceback (most recent call last):                                                              
frigate    | 2023-08-14 07:54:09.035638482    File "/usr/lib/python3.9/multiprocessing/process.py", line 315, in _bootstrap                 
frigate    | 2023-08-14 07:54:09.035640723      self.run()                                                                                  
frigate    | 2023-08-14 07:54:09.035643238    File "/usr/lib/python3.9/multiprocessing/process.py", line 108, in run                        
frigate    | 2023-08-14 07:54:09.035664539      self._target(*self._args, **self._kwargs)                                                   
frigate    | 2023-08-14 07:54:09.035667274    File "/opt/frigate/frigate/object_detection.py", line 98, in run_detector                     
frigate    | 2023-08-14 07:54:09.035670778      object_detector = LocalObjectDetector(detector_config=detector_config)                      
frigate    | 2023-08-14 07:54:09.035673123    File "/opt/frigate/frigate/object_detection.py", line 52, in __init__                         
frigate    | 2023-08-14 07:54:09.035686071      self.detect_api = create_detector(detector_config)                                          
frigate    | 2023-08-14 07:54:09.035688582    File "/opt/frigate/frigate/detectors/__init__.py", line 24, in create_detector                
frigate    | 2023-08-14 07:54:09.035690834      return api(detector_config)                                                                 
frigate    | 2023-08-14 07:54:09.035693020    File "/opt/frigate/frigate/detectors/plugins/edgetpu_tfl.py", line 37, in __init__            
frigate    | 2023-08-14 07:54:09.035695108      edge_tpu_delegate = load_delegate("libedgetpu.so.1.0", device_config)                       
frigate    | 2023-08-14 07:54:09.035709835    File "/usr/lib/python3/dist-packages/tflite_runtime/interpreter.py", line 162, in load_delegate                                                                                                                                             
frigate    | 2023-08-14 07:54:09.035712584      raise ValueError('Failed to load delegate from {}\n{}'.format(                                  
frigate    | 2023-08-14 07:54:09.035714777  ValueError: Failed to load delegate from libedgetpu.so.1.0

Operating system

Debian

Install method

Docker Compose

Coral version

USB

Any other information that may be helpful

No response

NickM-27 commented 1 year ago

I also have libedgetpu1-std installed on the host, and the host can correctly detect my Coral usb as "Google Inc"

There is no need for this, and it may very well be causing complications.

meitham commented 1 year ago

There is no need for this, and it may very well be causing complications.

Amazing, removing libedgetpu1-std from the host actually fixed the issue! I suggested this is something to be added to the documentation.

Thank you

fvalle1 commented 9 months ago

Removing libedgetpu1-max solved the issue for me too