[Support]: USB edge TPU not detected

See original GitHub issue

Describe the problem you are having

I have a Coral USB edge TPU passed through to a VM running in ESXi (as a USB 3.0 device). I could see the device both inside the Frigate container and the host VM, but Frigate is crashing on start complaining that the TPU couldn’t be detected:

# lsusb -tv
/:  Bus 02.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/4p, 5000M
    ID 1d6b:0003 Linux Foundation 3.0 root hub
    |__ Port 1: Dev 3, If 0, Class=Application Specific Interface, Driver=, 5000M
        ID 1a6e:089a Global Unichip Corp. 
/:  Bus 01.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/4p, 480M
    ID 1d6b:0002 Linux Foundation 2.0 root hub
    |__ Port 1: Dev 2, If 0, Class=Human Interface Device, Driver=usbhid, 12M
        ID 0e0f:0003 VMware, Inc. Virtual Mouse
# ls -la /dev | grep coral
lrwxrwxrwx   1 root       root          15 Nov  3 19:28 coral -> bus/usb/002/003

# ls -la /dev/bus/usb/002/003
crwxrwxrwx 1 root plugdev 189, 130 Nov  3 19:28 /dev/bus/usb/002/003

This is what I have for docker-compose.yml:

version: "3.9"
services:
  frigate:
    container_name: frigate
    privileged: true
    restart: always
    image: blakeblackshear/frigate:stable-amd64
    shm_size: "1024mb"
    devices:
      - /dev/bus/usb:/dev/bus/usb # coral usb
      - /dev/dri/renderD128 # Intel HWaccel for video decoding
    volumes:
      # - /dev/bus/usb:/dev/bus/usb # coral usb?
      - /etc/localtime:/etc/localtime:ro
      - /frigate/config.yml:/config/config.yml:ro
      - /var/footage:/media/frigate
      - type: tmpfs
        target: /tmp/cache
        tmpfs:
          size: 1000000000
    ports:
      - "5000:5000"
      - "1935:1935" # RTMP feeds
    environment:
      FRIGATE_RTSP_PASSWORD: "secret"

What I’ve tried (none have worked so far, TPU is still not detected):

  • Moving /dev/bus/usb into volumes (as suggested by another comment on another issue)
  • Setting permission for the Coral device itself to 0777 (through udev)
  • Physically changing the USB port the edge TPU is connected to (normally it’s connected through a USB 3.0 hub, I tried a direct connection)

Would appreciate some help and/or debugging tips!

Version

0.9.4-26ae608

Frigate config file

mqtt:
  host: <mqtt server ip>

detectors:
  coral:
    type: edgetpu
    device: usb

cameras:
  01_test_camera:
    ffmpeg:
      inputs:
        - path: <camera rtsp path>
          roles:
            - detect
            - rtmp
    detect:
      width: 1920
      height: 1080

Relevant log output

frigate  | [2021-11-03 19:20:45] ws4py                          INFO    : Using epoll
frigate  | [2021-11-03 19:20:44] detector.coral                 INFO    : Starting detection process: 212
frigate  | [2021-11-03 19:20:44] frigate.edgetpu                INFO    : Attempting to load TPU as usb
frigate  | [2021-11-03 19:20:54] frigate.edgetpu                ERROR   : No EdgeTPU was detected. If you do not have a Coral device yet, you must configure CPU detectors.
frigate  | Process detector:coral:
frigate  | Traceback (most recent call last):
frigate  |   File "/usr/lib/python3/dist-packages/tflite_runtime/interpreter.py", line 160, in load_delegate
frigate  |     delegate = Delegate(library, options)
frigate  |   File "/usr/lib/python3/dist-packages/tflite_runtime/interpreter.py", line 119, in __init__
frigate  |     raise ValueError(capture.message)
frigate  | ValueError
frigate  | 
frigate  | During handling of the above exception, another exception occurred:
frigate  | 
frigate  | Traceback (most recent call last):
frigate  |   File "/usr/lib/python3.8/multiprocessing/process.py", line 315, in _bootstrap
frigate  |     self.run()
frigate  |   File "/usr/lib/python3.8/multiprocessing/process.py", line 108, in run
frigate  |     self._target(*self._args, **self._kwargs)
frigate  |   File "/opt/frigate/frigate/edgetpu.py", line 156, in run_detector
frigate  |     object_detector = LocalObjectDetector(
frigate  |   File "/opt/frigate/frigate/edgetpu.py", line 64, in __init__
frigate  |     edge_tpu_delegate = load_delegate("libedgetpu.so.1.0", device_config)
frigate  |   File "/usr/lib/python3/dist-packages/tflite_runtime/interpreter.py", line 162, in load_delegate
frigate  |     raise ValueError('Failed to load delegate from {}\n{}'.format(
frigate  | ValueError: Failed to load delegate from libedgetpu.so.1.0

FFprobe output from your camera

Likely not relevant?

Frigate stats

No response

Operating system

Debian

Install method

Docker Compose

Coral version

USB

Network connection

Wired

Camera make and model

N/A

Any other information that may be helpful

No response

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:10 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
xawencommented, Nov 7, 2021

I spent a few days trying to get USB passthrough to work into an ESXi VM. What I found is that it won’t work consistently. If you do manage to get it recognized, a reboot will probably break it again.

From what I can tell, the reason for this is that the Coral is an odd device. When you first plug it in, it will show up as a “Global Unichip” device with one device ID. After it initializes, it will change to a “Google USB Device” with a different ID. The Google USB Device is the one you want to use, but it’s not visible to ESXi until it’s initialized…but that can’t happen until the VM is attached to it.

This short version is that, from my testing, the only way to make it work is to pass the entire USB controller into the VM. I did this by buying a cheap PCIe USB3 card for my host and dedicating the whole card to my Home Assistant VM. It’s been rock solid under that configuration.

0reactions
stale[bot]commented, Dec 7, 2021

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Coral TPU not detected by HA blue for Frigate - Configuration
Hi, I added a Coral TPU (USB) to my HA blue, but it's not detected by HA and Frigate will not start, if...
Read more >
TensorFlow models on the Edge TPU - Coral.ai
The Edge TPU is capable of executing deep feed-forward neural networks such as convolutional neural networks (CNN). It supports only TensorFlow Lite models...
Read more >
Coral USB inference not working on Windows 10 (ValueError
Coral USB inference not working on Windows 10 (ValueError: Failed to load delegate from edgetpu.dll). By Maximilian Batz | 2022-10-19.
Read more >
Raspberry PI4 + Coral TPU + Telit LTE get "Under-Voltage"
Why I am getting a lot of Under-Voltage Detected! messages running dmesg if power consumed by the usb ports seems less than the...
Read more >
Google Coral USB Edge TPU ML Accelerator coprocessor for ...
Amazon.com: Google Coral USB Edge TPU ML Accelerator coprocessor for Raspberry Pi and ... We have found the Google Coral, not just the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found