blakeblackshear / frigate

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

[Support]: 0.9.2-amd64: EdgeTPU not found on Synology Docker #2088

Closed InToSSH closed 2 years ago

InToSSH commented 2 years ago

Describe the problem you are having

Hello, I upgraded from v0.8.4 to 0.9.2, made a new config, but now Frigate keeps restarting with an error that EdgeTPU was not found, however when I go back to 0.8.4, it all works right away.

These are commands I ran to create the container: v0.9.2

docker run -d \
  --name frigate \
  --privileged \
  --restart=unless-stopped \
  --mount type=tmpfs,target=/tmp/cache,tmpfs-size=1000000000 \
  --device /dev/bus/usb:/dev/bus/usb \
  --device /dev/dri/renderD128 \
  --shm-size=164m \
  -v /volume1/docker/Frigate/media:/media/frigate \
  -v /volume1/docker/Frigate/config/config.yml:/config/config.yml:ro \
  -v /etc/localtime:/etc/localtime:ro \
  -e FRIGATE_RTSP_PASSWORD='xxxx' \
  -p 23500:5000 \
  -p 1935:1935 \
  blakeblackshear/frigate:0.9.2-amd64

v0.8.4

docker run -d \
--name frigate \
--privileged \
--mount type=tmpfs,target=/tmp/cache,tmpfs-size=1000000000 \
-v /dev/bus/usb:/dev/bus/usb \
-v /volume1/docker/Frigate/config:/config \
-v /volume1/docker/Frigate/media:/media/frigate \
-v /etc/localtime:/etc/localtime:ro \
-p 23500:5000 \
-p 1935:1935 \
-e FRIGATE_RTSP_PASSWORD='xxxx' \
blakeblackshear/frigate:0.8.4-amd64

When running 0.8.4 log states: 2021-10-22 23:11:33 | stderr | frigate.edgetpu  INFO    : TPU found

Config uses the same detectors settings for both versions:

detectors:
  coral:
    type: edgetpu
    device: usb

Version

0.9.2

Frigate config file

detectors:
  coral:
    type: edgetpu
    # Optional: device name as defined here: https://coral.ai/docs/edgetpu/multiple-edgetpu/#using-the-tensorflow-lite-python-api
    device: usb

# Required: mqtt configuration
mqtt:
  host: 10.10.1.10
  port: 1883
  topic_prefix: frigate
  client_id: frigate
  user: mqtt_frigate
  password: xxx

record:
  # Optional: Enable recording (default: shown below)
  enabled: True
  retain_days: 0
  # Optional: Event recording settings
  events:
    max_seconds: 300
    # Optional: Number of seconds before the event to include (default: shown below)
    pre_capture: 3
    # Optional: Number of seconds after the event to include (default: shown below)
    post_capture: 3
    # Optional: Objects to save recordings for. (default: all tracked objects)
    objects:
      - person
      - car
    # Optional: Retention settings for recordings of events
    retain:
      # Required: Default retention days (default: shown below)
      default: 7
      # Optional: Per object retention days
      objects:
        person: 7
        car: 7

# Optional: Global ffmpeg args
# "ffmpeg" + global_args + input_args + "-i" + input + output_args
ffmpeg:
  hwaccel_args:
    - -hwaccel
    - vaapi
    - -hwaccel_device
    - /dev/dri/renderD128
    - -hwaccel_output_format
    - yuv420p

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: 30
  # Optional: Minimum size in pixels in the resized motion image that counts as motion
  # Increasing this value will prevent smaller areas of motion from being detected. Decreasing will make motion detection more sensitive to smaller
  # moving objects.
  contour_area: 100
  # 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.15
  # 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.23

timestamp_style:
  # Optional: Position of the timestamp (default: shown below)
  #           "tl" (top left), "tr" (top right), "bl" (bottom left), "br" (bottom right)
  position: "tl"
  # Optional: Format specifier conform to the Python package "datetime" (default: shown below)
  #           Additional Examples:
  #             german: "%d.%m.%Y %H:%M:%S"
  format: "%d.%m.%Y %H:%M:%S"
  # Optional: Color of font
  color:
    # All Required when color is specified (default: shown below)
    red: 255
    green: 255
    blue: 255
  # Optional: Line thickness of font (default: shown below)
  thickness: 2
  # Optional: Effect of lettering (default: shown below)
  #           None (No effect),
  #           "solid" (solid background in inverse color of font)
  #           "shadow" (shadow for font)
  effect: "shadow"

# Optional: Global object filters for all cameras.
# NOTE: can be overridden at the camera level
objects:
  track:
    - person
  filters:
    person:
      # Optional: minimum width*height of the bounding box for the detected object (default: 0)
      min_area: 2000
      # Optional: maximum width*height of the bounding box for the detected object (default: max_int)
      max_area: 1000000
      # Optional: minimum score for the object to initiate tracking (default: shown below)
      min_score: 0.55

detect:
  # Optional: Number of frames without a detection before frigate considers an object to be gone. (default: double the frame rate)
  max_disappeared: 75    

# Required: configuration section for cameras
cameras:
  # Required: name of the camera
  entry:
    # Required: ffmpeg settings for the camera
    ffmpeg:
      inputs:
        - path: rtsp://admin:@10.10.3.242/third
          roles:
            - detect
            - record

    detect:
      height: 1080
      width: 1920
      fps: 5
    best_image_timeout: 20

    snapshots:
      enabled: True
      timestamp: True
      bounding_box: True
      height: 1080

    mqtt:
      enabled: True
      timestamp: True
      bounding_box: True
      crop: True
      height: 400

    rtmp:
      enabled: False

    motion:    
      mask: 0,259,0,0,964,0,969,80,649,125

    zones:
      at_door:
        coordinates: 823,890,673,597,686,376,808,241,986,210,1091,37,1232,75,1420,144,1782,309,1656,636,1539,892,1465,973,1056,977
      getting_to_door:
        coordinates: 75,1068,50,792,65,500,269,344,476,258,664,248,818,225,788,249,683,373,669,607,818,894,1063,983,1273,1078,688,1072,311,1066

    objects:
      track:
        - person
        - dog
        - cat

  frontyard:
    ffmpeg:
      inputs:
        - path: rtsp://admin:@10.10.3.243/third
          roles:
            - detect
            - record

    detect:
      height: 1080
      width: 1920
      fps: 5
    best_image_timeout: 20

    rtmp:
      enabled: False

    snapshots:
      enabled: True
      timestamp: True
      bounding_box: True
      height: 1080

    mqtt:
      enabled: True
      timestamp: True
      bounding_box: True
      crop: True
      height: 400

    motion:
      mask: 
        - 966,63,969,3,1912,8,1919,236,1756,195,1531,141,1324,95,1166,71
        - 428,46,425,0,0,0,0,47

    zones:
      driveway:
        coordinates: 6,1072,18,451,147,365,445,272,852,250,1154,288,1495,293,1848,363,1897,456,1902,529,1916,722,1897,919,1895,1055,1297,1066,523,1066
      outside_road:
        coordinates: 4,363,8,239,13,124,160,112,428,86,688,58,893,66,1105,78,1241,119,1327,195,1268,258,1034,297,727,298,447,297,276,317 
      frontyard_close:
        coordinates: 1920,1080,1529,1080,1322,1080,1321,723,1391,433,1693,411,1920,418
      mailbox:
        coordinates: 791,291,895,292,891,244,796,250

    objects:
      track:
        - person
        - car
        - truck
        - dog
        - cat
      filters:
        car:
          threshold: 0.7
          mask: 1920,1080,1920,804,1920,576,1920,210,1649,138,1423,68,1188,59,1022,100,1010,160,1034,220,1019,353,1072,429,1118,599,967,682,645,676,476,532,357,368,248,287,0,322,0,1080
        truck:
          threshold: 0.7
          mask: 1920,1080,1920,804,1920,576,1920,210,1649,138,1423,68,1188,59,1022,100,1010,160,1034,220,1019,353,1072,429,1118,599,967,682,645,676,476,532,357,368,248,287,0,322,0,1080
        person:
          mask:
            - 556,1080,810,1080,811,952,551,951

  east:
    ffmpeg:
      inputs:
        - path: rtsp://admin:@10.10.3.246/third
          roles:
            - detect
            - record

    detect:
      height: 1080
      width: 1920
      fps: 5
    best_image_timeout: 20

    rtmp:
      enabled: False

    snapshots:
      enabled: True
      timestamp: True
      bounding_box: True
      height: 1080

    mqtt:
      enabled: True
      timestamp: True
      bounding_box: True
      crop: True
      height: 400

    motion:
      mask:
        - 0,147,389,87,954,25,1050,0,0,0

    zones:
      east_close:
        coordinates: 900,1075,913,115,1071,47,1222,0,1354,12,1919,15,1919,463,1919,804,1919,1075,1816,1078,1722,1075,1283,1072

    objects:
      track:
        - person
        - dog
        - cat

  north:
    ffmpeg:
      inputs:
        - path: rtsp://admin:@10.10.3.245/third
          roles:
            - detect
            - record

    detect:
      height: 1080
      width: 1920
      fps: 5
    best_image_timeout: 20

    motion:
      mask: 
        - 1,381,0,0,929,0,930,58
        - 1636,1080,1761,356,1651,331,1448,1080

    zones:
      garden:
        coordinates: 0,1080,1566,1080,1648,839,1706,485,1737,92,1519,73,1274,56,970,97,437,277,0,493

    rtmp:
      enabled: False

    snapshots:
      enabled: True
      timestamp: True
      bounding_box: True
      height: 1080

    mqtt:
      enabled: True
      timestamp: True
      bounding_box: True
      crop: True
      height: 400

    objects:
      track:
        - person
        - dog
        - cat
      filters:
        person:
          mask:
            - 1636,1080,1761,356,1651,331,1448,1080
            - 787,885,886,820,1081,714,1148,590,1032,487,803,551,694,773

Relevant log output

[2021-10-23 01:18:02] frigate.edgetpu                INFO    : Attempting to load TPU as usb
[2021-10-23 01:18:33] frigate.edgetpu                ERROR   : No EdgeTPU was detected. If you do not have a Coral device yet, you must configure CPU detectors.
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 "/usr/lib/python3.8/multiprocessing/process.py", line 315, in _bootstrap
    self.run()
  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 156, in run_detector
    object_detector = LocalObjectDetector(
  File "/opt/frigate/frigate/edgetpu.py", line 64, 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

ffprobe version 4.2.4-1ubuntu0.1 Copyright (c) 2007-2020 the FFmpeg developers
  built with gcc 9 (Ubuntu 9.3.0-10ubuntu2)
  configuration: --prefix=/usr --extra-version=1ubuntu0.1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-nvenc --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared
  libavutil      56. 31.100 / 56. 31.100
  libavcodec     58. 54.100 / 58. 54.100
  libavformat    58. 29.100 / 58. 29.100
  libavdevice    58.  8.100 / 58.  8.100
  libavfilter     7. 57.100 /  7. 57.100
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  5.100 /  5.  5.100
  libswresample   3.  5.100 /  3.  5.100
  libpostproc    55.  5.100 / 55.  5.100
[rtsp @ 0x565354012a00] UDP timeout, retrying with TCP
Input #0, rtsp, from 'rtsp://admin:@10.10.3.242/third':
  Metadata:
    title           : RTSP/RTP stream from IPNC
    comment         : third
  Duration: N/A, start: 0.000000, bitrate: N/A
    Stream #0:0: Video: h264 (Main), yuvj420p(pc, bt709, progressive), 1920x1080, 25 tbr, 90k tbn, 180k tbc
    Stream #0:1: Audio: pcm_mulaw, 8000 Hz, 1 channels, s16, 64 kb/s
    Stream #0:2: Data: none

Frigate stats

No response

Operating system

Other Linux

Install method

Docker CLI

Coral version

USB

Network connection

Wired

Camera make and model

Milesight

Any other information that may be helpful

No response

blakeblackshear commented 2 years ago

I can't think of any reason this would happen. Have you tried restarting the Synology? Are you certain there isnt another process still using the Coral?

InToSSH commented 2 years ago

Yes I tried restart, replugging the Coral, nothing helped. There is nothing else using the Coral, as soon as I recreate the container with the 0.8.4 it starts working, then go back to 0.9.2 and I get this error.

blakeblackshear commented 2 years ago

Have you tried 0.9.1? I know some other synology users have upgraded fine, so I am not sure why this would happen.

InToSSH commented 2 years ago

@blakeblackshear It gives me exactly the same error on 0.9.1. As soon as I rebuild the container with 0.8.4 and swap the old config I am back up and running.

And I am running DSM 6.2.4 - didn't upgrade to DSM 7 because of the dropped USB support.

InToSSH commented 2 years ago

Ok, I followed the docker run example from the docs for 0.9.2 and noticed the /dev/usb folder is mounted differently than previous version. I got it working now.

--device /dev/bus/usb:/dev/bus/usb

doesn't work and needs to be swapped with:

-v /dev/bus/usb:/dev/bus/usb

now it detected the TPU successfully.