Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Support]: No EdgeTPU was detected, ValueError: Failed to load delegate from libedgetpu.so.1.0. Was working previously. #3116

Closed
tehniemer opened this issue Apr 17, 2022 · 32 comments

Comments

@tehniemer
Copy link

Describe the problem you are having

Frigate has stopped detecting the EdgeTPU I've been using successfully for quite some time. Everything was working until recently, but I don't have an exact timeframe when it stopped. I'm using a M.2 Accelerator with Dual Edge TPU with a couple adapters to get it into a pcie slot. I haven't had any luck troubleshooting this on my own. Looking for some next steps I could try.

Version

0.10.1-83481AF

Frigate config file

mqtt:
  host: 192.168.10.111
  port: 1883
  topic_prefix: frigate
  client_id: frigate
  user: admin
  password: '{FRIGATE_MQTT_PASSWORD}'
  stats_interval: 60
  
####################################################
#                                                  #
#              GLOBAL CONFIGURATION                #
#                                                  #
####################################################

detectors:
  coral1:
    type: edgetpu
    device: pci:0
#  coral2:
#    type: edgetpu
#    device: pci:1
    
database:
  path: /config/frigate.db

ffmpeg:
  global_args: -hide_banner -loglevel warning
  hwaccel_args:
    - -hwaccel
    - vaapi
    - -hwaccel_device
    - /dev/dri/renderD128
    - -hwaccel_output_format
    - yuv420p
  input_args: -avoid_negative_ts make_zero -fflags +genpts+discardcorrupt -rtsp_transport tcp -stimeout 5000000 -use_wallclock_as_timestamps 1
  output_args:
    detect: -f rawvideo -pix_fmt yuv420p
    record: -f segment -segment_time 60 -segment_format mp4 -reset_timestamps 1 -strftime 1 -c:v copy -c:a aac
    rtmp: -f flv -c:v copy -c:a aac
    
detect:
  width: 640
  height: 480
  fps: 5
  enabled: True
  max_disappeared: 25

record:
  enabled: True
  retain:
    days: 15
    mode: all
  events:
    max_seconds: 300
    pre_capture: 5
    post_capture: 15
    objects:
      - person
    required_zones: []
    retain:
      default: 15
      objects:
        person: 30
        
snapshots:
  enabled: True
  timestamp: True
  bounding_box: True
  crop: False
  height: 175
  required_zones: []
  retain:
    default: 10
    objects:
      person: 15
      
rtmp:
  enabled: True
  
live:
  height: 640
  quality: 12

timestamp_style:
  position: "tl"
  format: "%m/%d/%Y %H:%M:%S"
  color:
    red: 255
    green: 255
    blue: 255
  thickness: 2
  effect: shadow
  
####################################################
#                                                  #
#              CAMERA CONFIGURATION                #
#                                                  #
####################################################

cameras:
  front:
    ffmpeg:
      inputs:
        - path: rtsp://admin:{FRIGATE_AMCSH_PASSWORD}@192.168.44.110:554/cam/realmonitor?channel=1&subtype=0&authbasic=64
          roles:
            - record
            - rtmp
        - path: rtsp://admin:{FRIGATE_AMCSH_PASSWORD}@192.168.44.110:554/cam/realmonitor?channel=1&subtype=1&authbasic=64
          roles:
            - detect
    detect:
      enabled: True
    record:
      enabled: True
    objects:
      track:
        - person
        - car
        - dog
        - cat
        - bird
        - bicycle
    
  kitchen:
    ffmpeg:
      inputs:
        - path: rtsp://admin:{FRIGATE_AMCIP_PASSWORD}@192.168.44.111:554/cam/realmonitor?channel=1&subtype=0
          roles:
            - record
            - rtmp
        - path: rtsp://admin:{FRIGATE_AMCIP_PASSWORD}@192.168.44.111:554/cam/realmonitor?channel=1&subtype=1
          roles:
            - detect
    detect:
      enabled: True
    record:
      enabled: True
    objects:
      track:
        - person

  living_room:
    ffmpeg:
      inputs:
        - path: rtsp://admin:{FRIGATE_AMCIP_PASSWORD}@192.168.44.112:554/cam/realmonitor?channel=1&subtype=0
          roles:
            - record
            - rtmp
        - path: rtsp://admin:{FRIGATE_AMCIP_PASSWORD}@192.168.44.112:554/cam/realmonitor?channel=1&subtype=1
          roles:
            - detect
    detect:
      enabled: True
    record:
      enabled: True
    objects:
      track:
        - person

  garage:
    ffmpeg:
      inputs:
        - path: rtsp://admin:{FRIGATE_AMCIP_PASSWORD}@192.168.44.113:554/cam/realmonitor?channel=1&subtype=0
          roles:
            - record
            - rtmp
        - path: rtsp://admin:{FRIGATE_AMCIP_PASSWORD}@192.168.44.113:554/cam/realmonitor?channel=1&subtype=1
          roles:
            - detect
    detect:
      enabled: True
    record:
      enabled: True
    objects:
      track:
        - person
        - dog
        - cat
        - bird
        - mouse
        - car

  den:
    ffmpeg:
      inputs:
        - path: rtsp://admin:{FRIGATE_AMCIP_PASSWORD}@192.168.44.114:554/cam/realmonitor?channel=1&subtype=0
          roles:
            - record
            - rtmp
        - path: rtsp://admin:{FRIGATE_AMCIP_PASSWORD}@192.168.44.114:554/cam/realmonitor?channel=1&subtype=1
          roles:
            - detect
    detect:
      enabled: True
    record:
      enabled: True
    objects:
      track:
        - person

  baby:
    ffmpeg:
      inputs:
        - path: rtsp://admin:{FRIGATE_AMCIP_PASSWORD}@192.168.44.115:554/cam/realmonitor?channel=1&subtype=0
          roles:
            - record
            - rtmp
        - path: rtsp://admin:{FRIGATE_AMCIP_PASSWORD}@192.168.44.115:554/cam/realmonitor?channel=1&subtype=1
          roles:
            - detect
    detect:
      enabled: True
    record:
      enabled: True
    objects:
      track:
        - person

Relevant log output

[2022-04-17 14:01:30] detector.coral1                INFO    : Starting detection process: 213
    self.run()
[2022-04-17 14:01:30] frigate.edgetpu                INFO    : Attempting to load TPU as pci:0
[2022-04-17 14:01:30] frigate.edgetpu                ERROR   : No EdgeTPU was detected. If you do not have a Coral device yet, you must configure CPU detectors.
Process detector:coral1:
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:
  File "/usr/lib/python3.8/multiprocessing/process.py", line 315, in _bootstrap
  File "/usr/lib/python3.8/multiprocessing/process.py", line 108, in run
    self._target(*self._args, **self._kwargs)
  File "/opt/frigate/frigate/edgetpu.py", line 136, in run_detector
    object_detector = LocalObjectDetector(
  File "/opt/frigate/frigate/edgetpu.py", line 44, in __init__
    edge_tpu_delegate = load_delegate("libedgetpu.so.1.0", device_config)
  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.0

FFprobe output from your camera

Input #0, rtsp, from 'rtsp://user:pass@192.168.44.111:554':
  Metadata:
    title           : Media Server
  Duration: N/A, start: 0.080000, bitrate: N/A
    Stream #0:0: Video: h264, yuvj420p(pc, bt709, progressive), 1920x1080 [SAR 1:1 DAR 16:9], 20 fps, 50 tbr, 90k tbn, 40 tbc
    Stream #0:1: Audio: aac, 16000 Hz, mono, fltp

Frigate stats

No response

Operating system

Debian

Install method

Docker Compose

Coral version

M.2

Network connection

Wired

Camera make and model

AMCREST IP3M-HX2

Any other information that may be helpful

No response

@NickM-27
Copy link
Collaborator

Have you try redownloading the drivers?
If you use lspci from the linux commandline do you see any coral / Google device at all?

@tehniemer
Copy link
Author

Drivers are up to date and the device shows up.

root@nvr:/# lspci -nn | grep 089a
01:00.0 System peripheral [0880]: Global Unichip Corp. Coral Edge TPU [1ac1:089a]

@NickM-27
Copy link
Collaborator

Drivers are up to date and the device shows up.


root@nvr:/# lspci -nn | grep 089a

01:00.0 System peripheral [0880]: Global Unichip Corp. Coral Edge TPU [1ac1:089a]

If you set the config to use cpu (so it doesn't die immediately) and you run the same inside the frigate container, is it visible?

@tehniemer
Copy link
Author

lspci does not exist in the container.

@maslyankov
Copy link

maslyankov commented Apr 18, 2022

Having the same exact issue running PCIE Coral with Frigate. It works for a day or two and then starts crashing with this error above. If you reboot the server it works until it starts crashing again. When it starts crashing, I’ve tried to run from the host an example image classification script that uses tensorflow as well and it fails with the same error.
So far I haven’t been able to find a solution. I read in a forum that it could be a stuck process that uses the tpu and locks it somehow, but I tried stopping the frigate container and that does not help.

When these crashes start, the tpu is still findable in pci devices list, as well as under “apex”.

@didi767
Copy link

didi767 commented Apr 24, 2022

I have the same exact issue here as well! out of the blue it stopped working (was working great for the last 6 months).
every time it detects a motion Frigate crashes. super frustrated :/

@tehniemer
Copy link
Author

Has anyone had luck fixing this issue? I tried rolling back to 0.9.4 and have the same issue, I'm at a loss.

@sytem
Copy link

sytem commented Apr 28, 2022

I have seen this same issue with two different systems, at some point with ”docker-compose restart frigate”, it lost Coral. Reboot of system has not fixed it, and I have had to fall back to cpu.

One system is Ubuntu with pci-e coral, other is debian and usb. Both running last stable frigate with docker compose.

Later lost with Debian host happened today when I added one more camera, Ubuntu has been with cpu for months as I have had no time to further debug and those three cameras on that system are with very few motion.

@sytem
Copy link

sytem commented Apr 29, 2022

Log output from boot after problem started:

frigate | [services.d] starting services frigate | [services.d] done. frigate | [2022-04-29 09:53:49] frigate.app INFO : Starting Frigate (0.10.0-bfecee9) frigate | Starting migrations frigate | [2022-04-29 09:53:49] peewee_migrate INFO : Starting migrations frigate | There is nothing to migrate frigate | [2022-04-29 09:53:49] peewee_migrate INFO : There is nothing to migrate frigate | [2022-04-29 09:53:49] detector.coral INFO : Starting detection process: 257 frigate | [2022-04-29 09:53:49] detector.cpu1 INFO : Starting detection process: 259 frigate | [2022-04-29 09:53:49] frigate.edgetpu WARNING : CPU detectors are not recommended and should only be used for testing or for trial purposes. frigate | [2022-04-29 09:53:49] detector.cpu2 INFO : Starting detection process: 262 frigate | [2022-04-29 09:53:49] frigate.edgetpu WARNING : CPU detectors are not recommended and should only be used for testing or for trial purposes. frigate | [2022-04-29 09:53:49] frigate.app INFO : Output process started: 265 frigate | [2022-04-29 09:53:49] ws4py INFO : Using epoll frigate | Process detector:coral: frigate | [2022-04-29 09:53:49] frigate.edgetpu INFO : Attempting to load TPU as usb frigate | [2022-04-29 09:53:49] frigate.app INFO : Camera processor started for cam1: 269 frigate | [2022-04-29 09:53:49] frigate.edgetpu ERROR : No EdgeTPU was detected. If you do not have a Coral device yet, you must configure CPU detectors. frigate | [2022-04-29 09:53:49] frigate.app INFO : Camera processor started for cam2: 271 frigate | [2022-04-29 09:53:49] frigate.app INFO : Camera processor started for cam4: 273 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 136, in run_detector frigate | object_detector = LocalObjectDetector( frigate | File "/opt/frigate/frigate/edgetpu.py", line 44, 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 frigate | frigate | [2022-04-29 09:53:49] frigate.app INFO : Camera processor started for cam5: 274 frigate | [2022-04-29 09:53:49] frigate.app INFO : Camera processor started for cam6: 276 frigate | [2022-04-29 09:53:49] frigate.app INFO : Camera processor started for cam7: 278 frigate | [2022-04-29 09:53:49] frigate.app INFO : Camera processor started for cam8: 280 frigate | [2022-04-29 09:53:49] frigate.app INFO : Camera processor started for cam9: 281 frigate | [2022-04-29 09:53:49] frigate.app INFO : Camera processor started for cam10: 283 frigate | [2022-04-29 09:53:49] frigate.app INFO : Capture process started for cam1: 284 frigate | [2022-04-29 09:53:49] frigate.app INFO : Capture process started for cam2: 288 frigate | [2022-04-29 09:53:49] frigate.app INFO : Capture process started for cam4: 290 frigate | [2022-04-29 09:53:49] frigate.app INFO : Capture process started for cam5: 295 frigate | [2022-04-29 09:53:49] frigate.app INFO : Capture process started for cam6: 302 frigate | [2022-04-29 09:53:49] frigate.app INFO : Capture process started for cam7: 311 frigate | [2022-04-29 09:53:49] frigate.app INFO : Capture process started for cam8: 322 frigate | [2022-04-29 09:53:49] frigate.app INFO : Capture process started for cam9: 339 frigate | [2022-04-29 09:53:49] frigate.app INFO : Capture process started for cam10: 343 frigate | [2022-04-29 09:53:49] ws4py INFO : Using epoll

on docker host:
`
teppo@testirata:$ lsusb
Bus 001 Device 004: ID 18d1:9302 Google Inc.
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 006 Device 002: ID 03f0:7029 HP, Inc Virtual Keyboard
Bus 006 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
teppo@testirata:
$ sudo lsusb -v -d 18d1:9302

Bus 001 Device 004: ID 18d1:9302 Google Inc.
Device Descriptor:
bLength 18
bDescriptorType 1
bcdUSB 2.10
bDeviceClass 0
bDeviceSubClass 0
bDeviceProtocol 0
bMaxPacketSize0 64
idVendor 0x18d1 Google Inc.
idProduct 0x9302
bcdDevice 1.00
iManufacturer 0
iProduct 0
iSerial 0
bNumConfigurations 1
Configuration Descriptor:
bLength 9
bDescriptorType 2
wTotalLength 0x003c
bNumInterfaces 1
bConfigurationValue 1
iConfiguration 0
bmAttributes 0x80
(Bus Powered)
MaxPower 498mA
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 0
bAlternateSetting 0
bNumEndpoints 6
bInterfaceClass 255 Vendor Specific Class
bInterfaceSubClass 255 Vendor Specific Subclass
bInterfaceProtocol 255 Vendor Specific Protocol
iInterface 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x01 EP 1 OUT
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0200 1x 512 bytes
bInterval 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x02 EP 2 OUT
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0200 1x 512 bytes
bInterval 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x03 EP 3 OUT
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0200 1x 512 bytes
bInterval 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x81 EP 1 IN
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0200 1x 512 bytes
bInterval 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x82 EP 2 IN
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0200 1x 512 bytes
bInterval 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x83 EP 3 IN
bmAttributes 3
Transfer Type Interrupt
Synch Type None
Usage Type Data
wMaxPacketSize 0x0040 1x 64 bytes
bInterval 1
Binary Object Store Descriptor:
bLength 5
bDescriptorType 15
wTotalLength 0x0016
bNumDeviceCaps 2
USB 2.0 Extension Device Capability:
bLength 7
bDescriptorType 16
bDevCapabilityType 2
bmAttributes 0x00000002
HIRD Link Power Management (LPM) Supported
SuperSpeed USB Device Capability:
bLength 10
bDescriptorType 16
bDevCapabilityType 3
bmAttributes 0x00
wSpeedsSupported 0x000c
Device can operate at High Speed (480Mbps)
Device can operate at SuperSpeed (5Gbps)
bFunctionalitySupport 2
Lowest fully-functional device speed is High Speed (480Mbps)
bU1DevExitLat 0 micro seconds
bU2DevExitLat 0 micro seconds
can't get debug descriptor: Resource temporarily unavailable
Device Status: 0x0000
(Bus Powered)`

@didi767
Copy link

didi767 commented May 4, 2022

Somehow I made a progress...
TPU is now visible/detected by Frigate, but it doesn't capture any events no matter what I tried (it works with CPU as detectors).

seeing this in the logs:

frigate | [2022-05-03 03:20:43] peewee.sqliteq DEBUG : received query with grouped_events as ( frigate | select id, frigate | label, frigate | camera, frigate | has_snapshot, frigate | has_clip, frigate | row_number() over ( frigate | partition by label, camera, round(start_time/5,0)*5 frigate | order by end_time-start_time desc frigate | ) as copy_number frigate | from event frigate | ) frigate | frigate | select distinct id, camera, has_snapshot, has_clip from grouped_events frigate | where copy_number > 1;

@sytem
Copy link

sytem commented May 4, 2022

After few boots of host computers and docker etc (not because of this issue), I tried to add USB-TPU again in config and it works again.

@sytem
Copy link

sytem commented May 4, 2022

And almost after I wrote above, after yet another "docker compose restart frigate" no Coral again and had to switch CPU-detection. Could this be something about stick left to some wrong state on shutdown?

@didi767
Copy link

didi767 commented May 6, 2022

Somehow I made a progress...
TPU is now visible/detected by Frigate, but it doesn't capture any events no matter what I tried (it works with CPU as detectors).

seeing this in the logs:

frigate | [2022-05-03 03:20:43] peewee.sqliteq DEBUG : received query with grouped_events as ( frigate | select id, frigate | label, frigate | camera, frigate | has_snapshot, frigate | has_clip, frigate | row_number() over ( frigate | partition by label, camera, round(start_time/5,0)*5 frigate | order by end_time-start_time desc frigate | ) as copy_number frigate | from event frigate | ) frigate | frigate | select distinct id, camera, has_snapshot, has_clip from grouped_events frigate | where copy_number > 1;

Screenshot_20220505-214513_Brave.jpg

Why it looks like everything is okay but now events are generated? Any ideas?

@didi767
Copy link

didi767 commented May 7, 2022

And I can also verify that the TPU is working properly with the example test:

`root@frigate:~/coral/pycoral/tflite/python/examples/classification# python3 classify_image.py --model models/mobilenet_v2_1.0_224_inat_bird_quant_edgetpu.tflite --labels models/inat_bird_labels.txt --input images/parrot.jpg
----INFERENCE TIME----
Note: The first inference on Edge TPU is slow because it includes loading the model into Edge TPU memory.
12.5ms
2.4ms
2.4ms
2.4ms
2.4ms
-------RESULTS--------
Corvus albus (Pied Crow): 0.50000

but still it doesn't work through Frigate itself, no events are being generated :/

@maslyankov
Copy link

In my case, when the issue appears and I start getting failed to load delegate in frigate, if I try to run the above test from the host, I get the same errors unless I reboot the system.

@phammichael
Copy link

I've got the same problem. Problem started today or yesterday. I've reinstalled Google's drivers but Frigate still doesn't detect it. Ubuntu detects it fine. lspci shows the tpu, and ls /dev/apex shows the device.

@didi767
Copy link

didi767 commented May 10, 2022

I tried with an older version (0.9.3-5E692AC) and still has the same issue.
I have no idea what made it stop all of a sudden. I have no choice but to use the CPU for now until someone hopefully finds a solution. I spent so many days trying to resolve this, so frustrating :/

@blakeblackshear
Copy link
Owner

Does this coincide with some host os update? Maybe a new kernel update isn't compatible with the apex driver?

@didi767
Copy link

didi767 commented May 10, 2022

I thought that this might be an issue so I tried with an older kernel version asl well.
currently I'm using:

root@frigate:~# uname -r
5.13.0-40-generic

root@frigate:~# ls -l /dev/apex_0
crwxrwxrwx 1 root apex 120, 0 May 7 03:05 /dev/apex_0

@didi767
Copy link

didi767 commented May 10, 2022

I downgraded the kernel now, nothing changed:

root@frigate:~# uname -r
5.4.0-109-generic

@phammichael
Copy link

Are any of you running this in docker? There was a recent docker upgrade.

@didi767
Copy link

didi767 commented May 10, 2022

@phammichael yes. I'm using docker. please be my savior :)

btw, I just tried to reinstall all the drivers and follow the instructions on the Coral website, I thought that after a kernel change this was required, but no change.

@tehniemer
Copy link
Author

I'm running in docker, just pulled the latest, no change in behavior.

@phammichael
Copy link

Sorry my last comment wasn't clear. What I meant: Docker was recently updated, and the new version of Docker might be the cause of the problem.

@didi767
Copy link

didi767 commented May 10, 2022

Is there a way to revert to a previous version? Which version are you running currently?

`
root@frigate:~# docker version
Client: Docker Engine - Community
Version: 20.10.14
API version: 1.41
Go version: go1.16.15
Git commit: a224086
Built: Thu Mar 24 01:48:02 2022
OS/Arch: linux/amd64
Context: default
Experimental: true

Server: Docker Engine - Community
Engine:
Version: 20.10.14
API version: 1.41 (minimum version 1.12)
Go version: go1.16.15
Git commit: 87a90dc
Built: Thu Mar 24 01:45:53 2022
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: 1.5.11
GitCommit: 3df54a852345ae127d1fa3092b95168e4a88e2f8
runc:
Version: 1.0.3
GitCommit: v1.0.3-0-gf46b6ba
docker-init:
Version: 0.19.0
GitCommit: de40ad0
`

@tehniemer
Copy link
Author

tehniemer commented May 10, 2022

@phammichael I'm running Docker version 20.10.15, build fd82621

@sytem
Copy link

sytem commented May 10, 2022

I also run this in Docker, debian host with USB-coral :

Linux testirata 5.10.0-11-amd64 #1 SMP Debian 5.10.92-1 (2022-01-18) x86_64 GNU/Linux

Client: Docker Engine - Community
Version: 20.10.12
API version: 1.41
Go version: go1.16.12
Git commit: e91ed57
Built: Mon Dec 13 11:45:48 2021
OS/Arch: linux/amd64
Context: default
Experimental: true

Server: Docker Engine - Community
Engine:
Version: 20.10.12
API version: 1.41 (minimum version 1.12)
Go version: go1.16.12
Git commit: 459d0df
Built: Mon Dec 13 11:43:56 2021
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: 1.4.12
GitCommit: 7b11cfaabd73bb80907dd23182b9347b4245eb5d
runc:
Version: 1.0.2
GitCommit: v1.0.2-0-g52b36a2
docker-init:
Version: 0.19.0
GitCommit: de40ad0

Ubuntu with PCI-Coral:

Linux sahara 5.13.0-40-generic #45~20.04.1-Ubuntu SMP Mon Apr 4 09:38:31 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

Client:
Version: 20.10.7
API version: 1.41
Go version: go1.13.8
Git commit: 20.10.7-0ubuntu5~20.04.2
Built: Mon Nov 1 00:34:17 2021
OS/Arch: linux/amd64
Context: default
Experimental: true

Server:
Engine:
Version: 20.10.7
API version: 1.41 (minimum version 1.12)
Go version: go1.13.8
Git commit: 20.10.7-0ubuntu520.04.2
Built: Fri Oct 22 00:45:53 2021
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: 1.5.5-0ubuntu3
20.04.2
GitCommit:
runc:
Version: 1.0.1-0ubuntu2~20.04.1
GitCommit:
docker-init:
Version: 0.19.0
GitCommit:

Havent done any active upgrade to either system just before this started, but it still could be something happened weeks before actual frigate restart that drops Coral undetectable. But at least with that debian-system I have been tweaking a lot recently, it wasn't something like next restart after host reboot, but I had restarted container many times in few hours, and then it just stopped to run when there was no detectors online.

@phammichael
Copy link

phammichael commented May 29, 2022

I was able to fix my problem with Coral. I think it was a problem with my python installation.

Coral was previously working correctly with Frigate, but recently stopped working. I have a dual TPU Coral using a PCIe adapter, Ubuntu system, and Frigate running in Docker.

ls /dev showed apex0 and lspci -nn | grep 089a showed the correct device, so that meant the Coral PCIe driver and the Edge TPU runtime were installed correctly.

But when I tested pycoral with the example from Google, it failed. This suggested something was wrong with either my pycoral installation or python installation on my system.

Listed below are the commands I ran. Some of it might not be required, but that's what I ran this morning and now my Coral is working again with Frigate.

Remove python2 if it's installed

sudo apt remove --purge python2

Set python3 version

update-alternatives --config python3

Note: I set mine to 3.9. If you're using a different version, the below commands will need to be modified accordingly.

Reinstall python3.9

sudo apt reinstall python3.9
sudo apt remove --purge python3-apt
sudo apt autoclean
sudo apt reinstall python3.9-distutils
sudo apt reinstall python3-pip
python3.9 -m pip install --upgrade pip
sudo apt reinstall python3.9-venv

Reboot system

sudo reboot

Reinstall pycoral and numpy

sudo apt reinstall python3-pycoral
sudo pip uninstall numpy
pip install numpy

Install Pillow if missing

pip install -U Pillow

Remove existing example for pycoral and then reinstall it

sudo rm -fr coral
mkdir coral && cd coral
git clone https://github.com/google-coral/pycoral.git
cd pycoral
bash examples/install_requirements.sh classify_image.py

Test pycoral with Google's example

python3 examples/classify_image.py
--model test_data/mobilenet_v2_1.0_224_inat_bird_quant_edgetpu.tflite
--labels test_data/inat_bird_labels.txt
--input test_data/parrot.jpg

If the test with Google's example was successful, then Coral TPU should now also work in Frigate.

@tehniemer
Copy link
Author

tehniemer commented May 29, 2022

@phammichael I'm not sure if I'm doing this right, but this was the output I got after following your instructions

root@nvr:~/coral/pycoral# python3 examples/classify_image.py --model test_data/mobilenet_v2_1.0_224_inat_bird_quant_edgetpu.tflite --input test_data/parrot.jpg --labels test_data/inat_bird_labels.txt
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 "/root/coral/pycoral/examples/classify_image.py", line 121, in <module>
    main()
  File "/root/coral/pycoral/examples/classify_image.py", line 71, in main
    interpreter = make_interpreter(*args.model.split('@'))
  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

@tehniemer tehniemer changed the title [Support]: No EdgeTPU was detected. Was working previously [Support]: No EdgeTPU was detected, ValueError: Failed to load delegate from libedgetpu.so.1.0. Was working previously. Jun 2, 2022
@stale
Copy link

stale bot commented Jul 6, 2022

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.

@stale stale bot added the stale label Jul 6, 2022
@tehniemer
Copy link
Author

Found my solution here google-coral/edgetpu#611

@calco88
Copy link

calco88 commented Aug 12, 2022

phammichael solution has now worked for me twice. I might add those commands into a bash script and automate it when docker logs show the coral acting up. Sucks this happens but glad to have a working solution

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants