[Detector Support]: EdgeTPU not detected in Frigate Docker (PCI / M.2 Coral) – "Failed to load delegate from libedgetpu.so.1.0" #15685
-
Describe the problem you are havingSorry, to ask such stupid questions, but I don't have any ideas how to proceed after upgrading from a previous (unknown) version of frigate to the new stable version; I’m running Frigate v14 in a Docker container with a PCI/M.2 Coral device. On the host, the Coral is properly installed and recognized (e.g., via [2024-12-25 12:47:22] 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 What I have tried so far
Do you have any additional hints how to proceed? Host OS: Ubuntu 22.04 Version0.14.1-f4f3cfa Frigate config filemqtt:
enabled: true
host: 192.XXX.XXX.XX
port: 1883
topic_prefix: frigate
client_id: frigate
cameras:
Gartenkamera: # <------ Name the camera
ffmpeg:
inputs:
- path: rtsp://XXXUser:[email protected]:XXXX/stream1 # <----- The stream you want to use for detection
input_args: preset-rtsp-generic
roles:
- detect
- record
detect:
enabled: true # <---- disable detection until you have a working camera feed
width: 2304 # <---- update for your camera's resolution
height: 1296 # <---- update for your camera's resolution
birdseye:
enabled: true
mode: continuous
detectors:
# cpu1:
# type: cpu
coral:
type: edgetpu
device: pci
# device: /dev/apex_0
snapshots:
# Optional: Enable writing jpg snapshot to /media/frigate/clips (default: shown below)
enabled: true
# Optional: save a clean PNG copy of the snapshot image (default: shown below)
clean_copy: true
# Optional: print a timestamp on the snapshots (default: shown below)
timestamp: true
retain:
# Required: Default retention days (default: shown below)
default: 30
# Optional: Per object retention days
objects:
person: 40
objects:
# Optional: list of objects to track from labelmap.txt (default: shown below)
track:
- person
- dog
- cat
motion:
# Optional: The threshold passed to cv2.threshold to determine if a pixel is different enough to be counted as motion. (default: shown below)
# Increasing this value will make motion detection less sensitive and decreasing it will make motion detection more sensitive.
# The value should be between 1 and 255.
threshold: 35
# Optional: Minimum size in pixels in the resized motion image that counts as motion (default: 30)
# Increasing this value will prevent smaller areas of motion from being detected. Decreasing will
# make motion detection more sensitive to smaller moving objects.
# As a rule of thumb:
# - 15 - high sensitivity
# - 30 - medium sensitivity
# - 50 - low sensitivity
contour_area: 30
# Optional: Alpha value passed to cv2.accumulateWeighted when averaging the motion delta across multiple frames (default: shown below)
# Higher values mean the current frame impacts the delta a lot, and a single raindrop may register as motion.
# Too low and a fast moving person wont be detected as motion.
delta_alpha: 0.2
# Optional: Alpha value passed to cv2.accumulateWeighted when averaging frames to determine the background (default: shown below)
# Higher values mean the current frame impacts the average a lot, and a new object will be averaged into the background faster.
# Low values will cause things like moving shadows to be detected as motion for longer.
# https://www.geeksforgeeks.org/background-subtraction-in-an-image-using-concept-of-running-average/
frame_alpha: 0.2
# Optional: Height of the resized motion frame (default: 50)
# This operates as an efficient blur alternative. Higher values will result in more granular motion detection at the expense
# of higher CPU usage. Lower values result in less CPU, but small changes may not register as motion.
frame_height: 50
# Optional: motion mask
# NOTE: see docs for more detailed info on creating masks
# Optional: improve contrast (default: shown below)
# Enables dynamic contrast improvement. This should help improve night detections at the cost of making motion detection more sensitive
# for daytime.
improve_contrast: true
# Optional: Delay when updating camera motion through MQTT from ON -> OFF (default: shown below).
mqtt_off_delay: 30
mask:
- 732,0,712,41,227,113,0,106,0,0
logger:
default: debug
record:
# Optional: Enable recording (default: shown below)
# WARNING: If recording is disabled in the config, turning it on via
# the UI or MQTT later will have no effect.
enabled: false
# Optional: Number of minutes to wait between cleanup runs (default: shown below)
# This can be used to reduce the frequency of deleting recording segments from disk if you want to minimize i/o
expire_interval: 60
# Optional: Sync recordings with disk on startup and once a day (default: shown below).
sync_recordings: false
# Optional: Retention settings for recording
retain:
# Optional: Number of days to retain recordings regardless of events (default: shown below)
# NOTE: This should be set to 0 and retention should be defined in events section below
# if you only want to retain recordings of events.
days: 0
# Optional: Mode for retention. Available options are: all, motion, and active_objects
# all - save all recording segments regardless of activity
# motion - save all recordings segments with any detected motion
# active_objects - save all recording segments with active/moving objects
# NOTE: this mode only applies when the days setting above is greater than 0
mode: all
# Optional: Recording Export Settings
export:
# Optional: Timelapse Output Args (default: shown below).
# NOTE: The default args are set to fit 24 hours of recording into 1 hour playback.
# See https://stackoverflow.com/a/58268695 for more info on how these args work.
# As an example: if you wanted to go from 24 hours to 30 minutes that would be going
# from 86400 seconds to 1800 seconds which would be 1800 / 86400 = 0.02.
# The -r (framerate) dictates how smooth the output video is.
# So the args would be -vf setpts=0.02*PTS -r 30 in that case.
timelapse_args: -vf setpts=0.04*PTS -r 30
# Optional: Recording Preview Settings
preview:
# Optional: Quality of recording preview (default: shown below).
# Options are: very_low, low, medium, high, very_high
quality: medium
version: 0.14 docker-compose file or Docker CLI commandversion: "3.9"
services:
frigate:
container_name: frigate
privileged: true # this may not be necessary for all setups
restart: unless-stopped
image: ghcr.io/blakeblackshear/frigate:stable
#image: ghcr.io/blakeblackshear/frigate:0.15.0-beta4-tensorrt
shm_size: "256mb" # update for your cameras based on calculation above
devices:
- /dev/apex_0:/dev/apex_0
volumes:
- /path/to/frigate/config_folder/:/config
- /path/to/frigate/media/:/media/frigate
- 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="<REDACTED>"
networks:
- caddy_net
networks:
caddy_net:
external: true Relevant Frigate log output2024-12-26 09:18:47.068755740 [INFO] Preparing Frigate...
2024-12-26 09:18:47.081471818 [INFO] Starting Frigate...
2024-12-26 09:18:48.419126071 [2024-12-26 09:18:48] frigate.app INFO : Starting Frigate (0.14.1-f4f3cfa)
2024-12-26 09:18:48.419229807 [2024-12-26 09:18:48] frigate.util.config INFO : Checking if frigate config needs migration...
2024-12-26 09:18:48.443826745 [2024-12-26 09:18:48] frigate.util.config INFO : frigate config does not need migration...
2024-12-26 09:18:48.555327155 [2024-12-26 09:18:48] frigate.util.services INFO : Automatically detected vaapi hwaccel for video decoding
2024-12-26 09:18:48.588427558 [2024-12-26 09:18:48] peewee DEBUG : ('CREATE TABLE IF NOT EXISTS "migratehistory" ("id" INTEGER NOT NULL PRIMARY KEY, "name" VARCHAR(255) NOT NULL, "migrated_at" DATETIME NOT NULL)', [])
2024-12-26 09:18:48.589682954 [2024-12-26 09:18:48] peewee DEBUG : ('SELECT "t1"."id", "t1"."name", "t1"."migrated_at" FROM "migratehistory" AS "t1" ORDER BY "t1"."id"', [])
2024-12-26 09:18:48.592514919 [2024-12-26 09:18:48] peewee_migrate.logs INFO : Starting migrations
2024-12-26 09:18:48.592604158 [2024-12-26 09:18:48] peewee DEBUG : ('SELECT "t1"."id", "t1"."name", "t1"."migrated_at" FROM "migratehistory" AS "t1" ORDER BY "t1"."id"', [])
2024-12-26 09:18:48.593288234 [2024-12-26 09:18:48] peewee_migrate.logs INFO : There is nothing to migrate
2024-12-26 09:18:48.603803118 [2024-12-26 09:18:48] frigate.app INFO : Recording process started: 382
2024-12-26 09:18:48.603808387 [2024-12-26 09:18:48] frigate.app INFO : Recording process started: 384
2024-12-26 09:18:48.606010596 [2024-12-26 09:18:48] asyncio DEBUG : Using selector: EpollSelector
2024-12-26 09:18:48.607741755 [2024-12-26 09:18:48] frigate.app INFO : go2rtc process pid: 97
2024-12-26 09:18:48.615211416 [2024-12-26 09:18:48] frigate.comms.mqtt DEBUG : MQTT connected
2024-12-26 09:18:48.631045716 [2024-12-26 09:18:48] detector.cpu1 INFO : Starting detection process: 412
2024-12-26 09:18:48.634554465 [2024-12-26 09:18:48] frigate.detectors WARNING : CPU detectors are not recommended and should only be used for testing or for trial purposes.
2024-12-26 09:18:48.636654653 [2024-12-26 09:18:48] detector.coral INFO : Starting detection process: 414
2024-12-26 09:19:01.492949360 [2024-12-26 09:18:48] frigate.app INFO : Output process started: 418
2024-12-26 09:19:01.493655782 [2024-12-26 09:18:48] tzlocal DEBUG : /etc/timezone found, contents:
2024-12-26 09:19:01.493661388 Etc/UTC
2024-12-26 09:19:06.223911 2024-12-26 09:19:01.493663718
2024-12-26 09:19:01.493666029 Process detector:coral:
2024-12-26 09:19:01.493668865 [2024-12-26 09:18:53] asyncio DEBUG : Using selector: EpollSelector
2024-12-26 09:19:01.493676620 [2024-12-26 09:18:48] peewee.sqliteq DEBUG : received query DELETE FROM "regions" WHERE NOT ("regions"."camera" IN (?))
2024-12-26 09:19:01.493929232 [2024-12-26 09:18:58] asyncio DEBUG : Using selector: EpollSelector
2024-12-26 09:19:01.493934233 [2024-12-26 09:18:48] peewee DEBUG : ('DELETE FROM "regions" WHERE NOT ("regions"."camera" IN (?))', ['Gartenkamera'])
2024-12-26 09:19:01.494120416 [2024-12-26 09:18:48] frigate.detectors.plugins.edgetpu_tfl INFO : Attempting to load TPU as pci
2024-12-26 09:19:01.494255113 [2024-12-26 09:18:48] peewee DEBUG : ('SELECT "t1"."camera", "t1"."grid", "t1"."last_update" FROM "regions" AS "t1" WHERE ("t1"."camera" = ?) LIMIT ? OFFSET ?', ['Gartenkamera', 1, 0])
2024-12-26 09:19:01.494418919 [2024-12-26 09:19:01] frigate.detectors.plugins.edgetpu_tfl ERROR : No EdgeTPU was detected. If you do not have a Coral device yet, you must configure CPU detectors.
2024-12-26 09:19:01.494423151 [2024-12-26 09:18:48] tzlocal DEBUG : /etc/localtime found
2024-12-26 09:19:01.494538745 [2024-12-26 09:18:48] tzlocal DEBUG : 2 found:
2024-12-26 09:19:01.494542674 {'/etc/timezone': 'Etc/UTC', '/etc/localtime is a symlink to': 'Etc/UTC'}
2024-12-26 09:19:01.494654464 [2024-12-26 09:18:48] peewee DEBUG : ('SELECT "t1"."id" FROM "event" AS "t1" WHERE ((("t1"."camera" = ?) AND (("t1"."false_positive" IS NULL) OR ("t1"."false_positive" = ?))) AND ("t1"."start_time" > ?))', ['Gartenkamera', False, 0])
2024-12-26 09:19:01.494808917 [2024-12-26 09:18:48] frigate.util.object DEBUG : Found 0 new events for Gartenkamera
2024-12-26 09:19:01.494899939 [2024-12-26 09:18:48] frigate.app INFO : Camera processor started for Gartenkamera: 433
2024-12-26 09:19:01.495050701 [2024-12-26 09:18:48] frigate.app INFO : Capture process started for Gartenkamera: 435
2024-12-26 09:19:01.495172647 [2024-12-26 09:18:48] peewee DEBUG : ('SELECT COUNT(?) FROM "recordings" AS "t1" WHERE (("t1"."camera" = ?) AND ("t1"."segment_size" > ?))', ['*', 'Gartenkamera', 0.0])
2024-12-26 09:19:01.495308046 [2024-12-26 09:18:48] urllib3.connectionpool DEBUG : Starting new HTTPS connection (1): api.github.com:443
2024-12-26 09:19:01.495334160 Traceback (most recent call last):
2024-12-26 09:19:01.495365592 File "/usr/lib/python3/dist-packages/tflite_runtime/interpreter.py", line 160, in load_delegate
2024-12-26 09:19:01.495368451 delegate = Delegate(library, options)
2024-12-26 09:19:01.495371378 File "/usr/lib/python3/dist-packages/tflite_runtime/interpreter.py", line 119, in __init__
2024-12-26 09:19:01.495373929 raise ValueError(capture.message)
2024-12-26 09:19:01.495390875 ValueError
2024-12-26 09:19:06.223962 2024-12-26 09:19:01.495402504
2024-12-26 09:19:01.495405463 During handling of the above exception, another exception occurred:
2024-12-26 09:19:06.223969 2024-12-26 09:19:01.495407463
2024-12-26 09:19:01.495418783 Traceback (most recent call last):
2024-12-26 09:19:01.495432004 [2024-12-26 09:18:48] peewee DEBUG : ('SELECT AVG("t1"."segment_size" / ("t1"."end_time" - "t1"."start_time")) FROM "recordings" AS "t1" WHERE (("t1"."camera" = ?) AND ("t1"."segment_size" > ?)) LIMIT ?', ['Gartenkamera', 0.0, 100])
2024-12-26 09:19:01.495452275 File "/usr/lib/python3.9/multiprocessing/process.py", line 315, in _bootstrap
2024-12-26 09:19:01.495454838 self.run()
2024-12-26 09:19:01.495457620 File "/usr/lib/python3.9/multiprocessing/process.py", line 108, in run
2024-12-26 09:19:01.495460233 self._target(*self._args, **self._kwargs)
2024-12-26 09:19:01.495476553 File "/opt/frigate/frigate/object_detection.py", line 102, in run_detector
2024-12-26 09:19:01.495479502 object_detector = LocalObjectDetector(detector_config=detector_config)
2024-12-26 09:19:01.495482268 File "/opt/frigate/frigate/object_detection.py", line 53, in __init__
2024-12-26 09:19:01.495484900 self.detect_api = create_detector(detector_config)
2024-12-26 09:19:01.495487671 File "/opt/frigate/frigate/detectors/__init__.py", line 18, in create_detector
2024-12-26 09:19:01.495490016 return api(detector_config)
2024-12-26 09:19:01.495492812 File "/opt/frigate/frigate/detectors/plugins/edgetpu_tfl.py", line 41, in __init__
2024-12-26 09:19:01.495516223 edge_tpu_delegate = load_delegate("libedgetpu.so.1.0", device_config)
2024-12-26 09:19:01.495519809 File "/usr/lib/python3/dist-packages/tflite_runtime/interpreter.py", line 162, in load_delegate
2024-12-26 09:19:01.495547008 raise ValueError('Failed to load delegate from {}\n{}'.format(
2024-12-26 09:19:01.495562151 ValueError: Failed to load delegate from libedgetpu.so.1.0
2024-12-26 09:19:06.223984 2024-12-26 09:19:01.495564463
2024-12-26 09:19:01.495567380 [2024-12-26 09:18:48] frigate.storage DEBUG : Gartenkamera has a bandwidth of 0 MiB/hr.
2024-12-26 09:19:01.496873619 [2024-12-26 09:18:48] urllib3.connectionpool DEBUG : https://api.github.com:443 "GET /repos/blakeblackshear/frigate/releases/latest HTTP/11" 200 1667
2024-12-26 09:19:01.496880184 [2024-12-26 09:18:48] frigate.api.auth DEBUG : Using jwt secret from .jwt_secret file in config directory.
2024-12-26 09:19:01.496884015 [2024-12-26 09:18:48] peewee.sqliteq DEBUG : received query UPDATE "reviewsegment" SET "end_time" = ? WHERE ("reviewsegment"."end_time" IS NULL)
2024-12-26 09:19:01.496887881 [2024-12-26 09:18:48] peewee DEBUG : ('UPDATE "reviewsegment" SET "end_time" = ? WHERE ("reviewsegment"."end_time" IS NULL)', [1735204728.739798])
2024-12-26 09:19:01.496891657 [2024-12-26 09:18:48] peewee.sqliteq DEBUG : received query UPDATE "event" SET "end_time" = ("event"."start_time" + ?) WHERE ("event"."end_time" IS NULL)
2024-12-26 09:19:01.496895456 [2024-12-26 09:18:48] peewee DEBUG : ('UPDATE "event" SET "end_time" = ("event"."start_time" + ?) WHERE ("event"."end_time" IS NULL)', [30])
2024-12-26 09:19:01.496901698 [2024-12-26 09:18:48] peewee DEBUG : ('SELECT COUNT(1) FROM (SELECT 1 FROM "user" AS "t1") AS "_wrapped"', [])
2024-12-26 09:19:01.496939416 [2024-12-26 09:18:51] asyncio DEBUG : Using selector: EpollSelector
2024-12-26 09:19:01.496943170 [2024-12-26 09:18:53] frigate.comms.ws DEBUG : Publishing mqtt message from websockets at onConnect.
2024-12-26 09:19:01.496946828 [2024-12-26 09:18:53] frigate.comms.ws DEBUG : Publishing mqtt message from websockets at onConnect.
2024-12-26 09:19:03.615607294 [2024-12-26 09:19:03] asyncio DEBUG : Using selector: EpollSelector Install methodDocker Compose Object DetectorCoral Screenshots of the Frigate UI's System metrics pagesAny other information that may be helpfulNo response |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 1 reply
-
Can you confirm that no other services are using the coral? |
Beta Was this translation helpful? Give feedback.
-
From a quick look on my working docker compose setup i found the following differences: |
Beta Was this translation helpful? Give feedback.
-
I think the device is mounted properly, but at this point I am not able to debug any further, as I have no knowledge in this area. I tried to run the pycoral tests in the docker environment to test, wether the recommended test procedures worked. I can see, that the edgetpu is also connected
Also adding
to /etc/modprobe.d/tpu.conf on the host, as mentioned in this reddit post did not help https://www.reddit.com/r/VFIO/comments/l5awg0/using_google_coral_mpcie_tpu_in_qemu_vm/ Best Thomas |
Beta Was this translation helpful? Give feedback.
-
Solution was to completely uninstall and reinstall again all coral drivers and adjust the usergroups accordingly on the host machine. So no problem with frigate, but with the configuration on the host. Works not like charm! Thank you for your help! |
Beta Was this translation helpful? Give feedback.
Solution was to completely uninstall and reinstall again all coral drivers and adjust the usergroups accordingly on the host machine. So no problem with frigate, but with the configuration on the host.
Works not like charm! Thank you for your help!