frigate icon indicating copy to clipboard operation
frigate copied to clipboard

[EdgeTPU Support]: Coral USB recognized/functional in host, but not in Docker. "No edgeTPU detected" loop.

Open kylepyke opened this issue 2 years ago • 3 comments

Describe the problem you are having

Google Coral works with my host machine, but isn't detected in Docker. I understand that the device changes vendors/device IDs once it's handled a program on the host machine. Initially it was listed as '''Global Unichip Corp.''', but I can consistently get it to register as '''Google Inc." without issue.

My best guess is that the device simply isn't being passed to Docker for some reason.

Things I've tried:

-listing /dev/bus/usb:/dev/bus/usb under Volumes.

-updating udev rules as mentioned here

-plugging into a powered hub

Version

0.11.1

Frigate config file

mqtt:
  host: 192.168.1.171
  user: frigate
  password: PASSWORD
cameras:
  playroom:
    ffmpeg:
      inputs:
        - path: rtsp://CAMERAURL
          roles:
            - detect
            - rtmp
    detect:
      width: 1920
      height: 1080

detectors:
  # Required: name of the detector
  coral:
    # Required: type of the detector
    # Valid values are 'edgetpu' (requires device property below) and 'cpu'.
    type: edgetpu
    # Optional: device name as defined here: https://coral.ai/docs/edgetpu/multiple-edgetpu/#using-the-tensorflow-lite-python-api
    device: usb
    # Optional: num_threads value passed to the tflite.Interpreter (default: shown below)

docker-compose file or Docker CLI command

version: "3.9"
services:
  frigate:
    container_name: frigate
    privileged: true # this may not be necessary for all setups
    restart: unless-stopped
    image: blakeblackshear/frigate:stable
    shm_size: "64mb" # update for your cameras based on calculation above
    devices:
      #- /dev/dri/renderD128 # for intel hwaccel, needs to be updated for your hardware
      - /dev/bus/usb:/dev/bus/usb # passes the USB Coral, needs to be modified for other versions

    volumes:
      - /etc/localtime:/etc/localtime:ro
      - /home/frigate/Desktop/Frigate/config.yml:/config/config.yml:ro
      - /home/frigate/Desktop/Frigate/media:/media/frigate
      - type: tmpfs # Optional: 1GB of memory, reduces SSD/SD Card wear
        target: /tmp/cache
        tmpfs:
          size: 1000000000
    ports:
      - "5000:5000"
      - "1935:1935" # RTMP feeds
    environment:
      FRIGATE_RTSP_PASSWORD: "PASSWORD"

Relevant log output

2022-12-07 15:27:47 [s6-init] making user provided files available at /var/run/s6/etc...exited 0.
2022-12-07 15:27:47 [s6-init] ensuring user provided files have correct perms...exited 0.
2022-12-07 15:27:47 [fix-attrs.d] applying ownership & permissions fixes...
2022-12-07 15:27:47 [fix-attrs.d] done.
2022-12-07 15:27:47 [cont-init.d] executing container initialization scripts...
2022-12-07 15:27:47 [cont-init.d] done.
2022-12-07 15:27:47 [services.d] starting services
2022-12-07 15:27:47 [services.d] done.
2022-12-07 15:27:48 [2022-12-07 20:27:48] frigate.app                    INFO    : Starting Frigate (0.11.1-2eada21)
2022-12-07 15:27:48 Starting migrations
2022-12-07 15:27:48 [2022-12-07 20:27:48] peewee_migrate                 INFO    : Starting migrations
2022-12-07 15:27:48 There is nothing to migrate
2022-12-07 15:27:48 [2022-12-07 20:27:48] peewee_migrate                 INFO    : There is nothing to migrate
2022-12-07 15:27:48 [2022-12-07 20:27:48] frigate.app                    INFO    : Output process started: 217
2022-12-07 15:27:48 [2022-12-07 20:27:48] detector.coral                 INFO    : Starting detection process: 216
2022-12-07 15:27:48 [2022-12-07 20:27:48] ws4py                          INFO    : Using epoll
2022-12-07 15:27:48 Process detector:coral:
2022-12-07 15:27:48 [2022-12-07 20:27:48] frigate.edgetpu                INFO    : Attempting to load TPU as usb
2022-12-07 15:27:48 [2022-12-07 20:27:48] frigate.edgetpu                ERROR   : No EdgeTPU was detected. If you do not have a Coral device yet, you must configure CPU detectors.
2022-12-07 15:27:48 Traceback (most recent call last):
2022-12-07 15:27:48   File "/usr/lib/python3/dist-packages/tflite_runtime/interpreter.py", line 160, in load_delegate
2022-12-07 15:27:48     delegate = Delegate(library, options)
2022-12-07 15:27:48   File "/usr/lib/python3/dist-packages/tflite_runtime/interpreter.py", line 119, in __init__
2022-12-07 15:27:48     raise ValueError(capture.message)
2022-12-07 15:27:48 ValueError
2022-12-07 15:27:48 
2022-12-07 15:27:48 During handling of the above exception, another exception occurred:
2022-12-07 15:27:48 
2022-12-07 15:27:48 Traceback (most recent call last):
2022-12-07 15:27:48   File "/usr/lib/python3.9/multiprocessing/process.py", line 315, in _bootstrap
2022-12-07 15:27:48     self.run()
2022-12-07 15:27:48   File "/usr/lib/python3.9/multiprocessing/process.py", line 108, in run
2022-12-07 15:27:48     self._target(*self._args, **self._kwargs)
2022-12-07 15:27:48   File "/opt/frigate/frigate/edgetpu.py", line 135, in run_detector
2022-12-07 15:27:48     object_detector = LocalObjectDetector(
2022-12-07 15:27:48   File "/opt/frigate/frigate/edgetpu.py", line 43, in __init__
2022-12-07 15:27:48     edge_tpu_delegate = load_delegate("libedgetpu.so.1.0", device_config)
2022-12-07 15:27:48   File "/usr/lib/python3/dist-packages/tflite_runtime/interpreter.py", line 162, in load_delegate
2022-12-07 15:27:48     raise ValueError('Failed to load delegate from {}\n{}'.format(
2022-12-07 15:27:48 ValueError: Failed to load delegate from libedgetpu.so.1.0
2022-12-07 15:27:48 
2022-12-07 15:27:48 [2022-12-07 20:27:48] frigate.app                    INFO    : Camera processor started for playroom: 224
2022-12-07 15:27:48 [2022-12-07 20:27:48] frigate.app                    INFO    : Capture process started for playroom: 226
2022-12-07 15:27:48 [2022-12-07 20:27:48] ws4py                          INFO    : Using epoll
2022-12-07 15:27:52 [2022-12-07 20:27:52] frigate.video                  ERROR   : playroom: Unable to read frames from ffmpeg process.
2022-12-07 15:27:52 [2022-12-07 20:27:52] frigate.video                  ERROR   : playroom: ffmpeg process is not running. exiting capture thread...
2022-12-07 15:27:52 [cont-finish.d] executing container finish scripts...
2022-12-07 15:27:52 [cont-finish.d] done.
2022-12-07 15:27:52 [s6-finish] waiting for services.
2022-12-07 15:27:53 [s6-finish] sending all processes the TERM signal.
2022-12-07 15:27:56 [s6-finish] sending all processes the KILL signal and exiting.

Operating system

Other Linux

Install method

Docker Compose

Coral version

USB

Any other information that may be helpful

Ubuntu 22.04 LTS on a 2013 MacBook Pro bare metal, running Docker Compose through Docker Desktop/Portainer.

Ubuntu is a clean install with only updates, Docker, and the pycoral library/dependencies installed.

Output of lsusb:

Bus 002 Device 003: ID 05ac:8406 Apple, Inc. Internal Memory Card Reader
Bus 002 Device 007: ID 18d1:9302 Google Inc. 
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 010: ID 05ac:8289 Apple, Inc. Bluetooth Host Controller
Bus 001 Device 003: ID 0a5c:4500 Broadcom Corp. BCM2046B1 USB 2.0 Hub (part of BCM2046 Bluetooth)
Bus 001 Device 004: ID 05ac:0262 Apple, Inc. Apple Internal Keyboard / Trackpad
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

Output of lsusb -tv:

/:  Bus 02.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/6p, 5000M
    ID 1d6b:0003 Linux Foundation 3.0 root hub
    |__ Port 1: Dev 7, If 0, Class=Vendor Specific Class, Driver=, 5000M
        ID 18d1:9302 Google Inc. 
    |__ Port 4: Dev 3, If 0, Class=Mass Storage, Driver=usb-storage, 5000M
        ID 05ac:8406 Apple, Inc. Internal Memory Card Reader
/:  Bus 01.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/14p, 480M
    ID 1d6b:0002 Linux Foundation 2.0 root hub
    |__ Port 8: Dev 3, If 0, Class=Hub, Driver=hub/3p, 12M
        ID 0a5c:4500 Broadcom Corp. BCM2046B1 USB 2.0 Hub (part of BCM2046 Bluetooth)
        |__ Port 3: Dev 10, If 3, Class=Application Specific Interface, Driver=, 12M
            ID 05ac:8289 Apple, Inc. Bluetooth Host Controller
        |__ Port 3: Dev 10, If 1, Class=Wireless, Driver=btusb, 12M
            ID 05ac:8289 Apple, Inc. Bluetooth Host Controller
        |__ Port 3: Dev 10, If 2, Class=Vendor Specific Class, Driver=btusb, 12M
            ID 05ac:8289 Apple, Inc. Bluetooth Host Controller
        |__ Port 3: Dev 10, If 0, Class=Vendor Specific Class, Driver=btusb, 12M
            ID 05ac:8289 Apple, Inc. Bluetooth Host Controller
    |__ Port 12: Dev 4, If 0, Class=Human Interface Device, Driver=usbhid, 12M
        ID 05ac:0262 Apple, Inc. 
    |__ Port 12: Dev 4, If 1, Class=Human Interface Device, Driver=usbhid, 12M
        ID 05ac:0262 Apple, Inc. 
    |__ Port 12: Dev 4, If 2, Class=Human Interface Device, Driver=bcm5974, 12M
        ID 05ac:0262 Apple, Inc.

kylepyke avatar Dec 08 '22 01:12 kylepyke

If you set it to use CPU detectors and run lsusb in the container what do you see?

NickM-27 avatar Dec 08 '22 02:12 NickM-27

Docker Compose:

services:
  frigate:
    container_name: frigate
    privileged: true # this may not be necessary for all setups
    restart: unless-stopped
    image: blakeblackshear/frigate:stable
    shm_size: "64mb" # update for your cameras based on calculation above
    devices:
      - /dev/dri/renderD128 # for intel hwaccel, needs to be updated for your hardware
      #- /dev/bus/usb:/dev/bus/usb # passes the USB Coral, needs to be modified for other versions

    volumes:
      - /etc/localtime:/etc/localtime:ro
      - /home/frigate/Desktop/Frigate/config.yml:/config/config.yml:ro
      - /home/frigate/Desktop/Frigate/media:/media/frigate
      - type: tmpfs # Optional: 1GB of memory, reduces SSD/SD Card wear
        target: /tmp/cache
        tmpfs:
          size: 1000000000
    ports:
      - "5000:5000"
      - "1935:1935" # RTMP feeds
    environment:
      FRIGATE_RTSP_PASSWORD: "PASSWORD"

config.yaml:

  host: 192.168.1.171
  user: frigate
  password: fr1gate
cameras:
  playroom:
    ffmpeg:
      inputs:
        - path: rtsp://cameraurl
          roles:
            - detect
            - rtmp
    detect:
      width: 1920
      height: 1080

#detectors:
  # Required: name of the detector
  #coral:
    # Required: type of the detector
    # Valid values are 'edgetpu' (requires device property below) and 'cpu'.
    #type: edgetpu
    # Optional: device name as defined here: https://coral.ai/docs/edgetpu/multiple-edgetpu/#using-the-tensorflow-lite-python-api
    #device: usb

lsusb output:

# lsusb
# lsusb -v

kylepyke avatar Dec 08 '22 02:12 kylepyke

I had this same problem. It was due to docker being installed 'rootless' by default on ubuntu.

Modifying udev rules to allow rootless access to usb fixed it for me. Similar to what is done with the following gist. https://gist.github.com/ofstudio/ab8001a21c257d67255c9f43451132c0

dsanner avatar Dec 21 '22 18:12 dsanner

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

github-actions[bot] avatar Jan 21 '23 00:01 github-actions[bot]