question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Support]: CPU usage even with using Coral

See original GitHub issue

Describe the problem you are having

Hello,

I’m not sure what is going on, but it seems like I am using a decent amount of CPU even though I am using a Coral on my system. When just idling I will use about 15% of my CPU, when it starts to detect stuff it goes to about 20-25%. Its not an amazing CPU, but not bad either. Im running a Intel® Core™ i7-9700 CPU @ 3.00GHz, and this is the power being pulled by the container itself, not the rest of the stuff going on on the server.

Version

0.10.1-83481AF

Frigate config file

mqtt:
  host: 192.168.1.9
  port: 1883

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)
    # This value is only used for CPU types
    num_threads: 3

objects:
  track:
   - person
   - vehicle
   - animal
record:
      # Optional: Enable recording (default: shown below)
  enabled: True
      # 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: 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: Event recording settings
  events:
        # Optional: Number of seconds before the event to include (default: shown below)
    pre_capture: 5
        # Optional: Number of seconds after the event to include (default: shown below)
    post_capture: 5
        # Optional: Objects to save recordings for. (default: all tracked objects)
        #objects:
        #  - person
        # Optional: Restrict recordings to objects that entered any of the listed zones (default: no required zones)
    required_zones: []
        # Optional: Retention settings for recordings of events
    retain:
          # Required: Default retention days (default: shown below)
      default: 10
          # Optional: Per object retention days
          #objects:
          #  person: 15


      # Optional: birdseye configuration
birdseye:
      # Optional: Enable birdseye view (default: shown below)
  enabled: True
      # Optional: Width of the output resolution (default: shown below)
  width: 1920
      # Optional: Height of the output resolution (default: shown below)
  height: 1080
      # Optional: Encoding quality of the mpeg1 feed (default: shown below)
      # 1 is the highest quality, and 31 is the lowest. Lower quality feeds utilize less CPU resources.
  quality: 8
      # Optional: Mode of the view. Available options are: objects, motion, and continuous
      #   objects - cameras are included if they have had a tracked object within the last 30 seconds
      #   motion - cameras are included if motion was detected in the last 30 seconds
      #   continuous - all cameras are included always
  mode: continuous

snapshots: 
      # Optional: Enable writing jpg snapshot to /media/frigate/clips (default: shown below)
      # This value can be set via MQTT and will be updated in startup based on retained value
  enabled: True
      # Optional: print a timestamp on the snapshots (default: shown below)
  timestamp: True
      # Optional: draw bounding box on the snapshots (default: shown below)
  bounding_box: True
      # Optional: crop the snapshot (default: shown below)
  crop: False
      # Optional: height to resize the snapshot to (default: original size)
      #height: 175
      # Optional: Restrict snapshots to objects that entered any of the listed zones (default: no required zones)
  required_zones: []
      # Optional: Camera override for retention settings (default: global values)
  #retain:
        # Required: Default retention days (default: shown below)
  #default: 10
        # Optional: Per object retention days
        #objects:
        #  person: 15
cameras:
  Driveway:
    ffmpeg:
      global_args:
        -an
      inputs:
        - path: rtsps://192.168.1.10:7441/2V6OZFHH6UxgtPie?enableSrtp # <----- Update for your camera
          roles:
            - detect
            - clips
            - rtmp
    detect: 
      width: 2688
      height: 1512
      fps: 5

  Back_Patio:
    ffmpeg:
      global_args:
        -an
      inputs:
        - path: rtsps://192.168.1.10:7441/gd9MqEqFP0PpNRzL?enableSrtp # <----- Update for your camera
          roles:
            - detect
            - clips
            - rtmp
    detect: 
      width: 2688
      height: 1512
      fps: 5

  G4_Doorbell_Pro:
    ffmpeg:
      global_args:
        -an
      inputs:
          - path: rtsps://192.168.1.10:7441/QrGgPhnPXdW99klh?enableSrtp # <----- Update for your camera
            roles:
              - detect
              - clips
              - rtmp
    detect: 
      width: 2688
      height: 1512
      fps: 5

Relevant log output

[2022-09-16 14:03:32] frigate.app                    INFO    : Starting Frigate (0.10.1-83481af)
Starting migrations
[2022-09-16 14:03:32] peewee_migrate                 INFO    : Starting migrations
There is nothing to migrate
[2022-09-16 14:03:41] peewee_migrate                 INFO    : There is nothing to migrate
[2022-09-16 14:03:41] detector.coral                 INFO    : Starting detection process: 225
[2022-09-16 14:03:41] frigate.edgetpu                INFO    : Attempting to load TPU as usb
[2022-09-16 14:03:41] ws4py                          INFO    : Using epoll
[2022-09-16 14:03:41] frigate.app                    INFO    : Output process started: 227
[2022-09-16 14:03:41] frigate.app                    INFO    : Camera processor started for Driveway: 231
[2022-09-16 14:03:41] frigate.app                    INFO    : Camera processor started for Back_Patio: 233
[2022-09-16 14:03:41] frigate.app                    INFO    : Camera processor started for G4_Doorbell_Pro: 234
[2022-09-16 14:03:41] frigate.app                    INFO    : Capture process started for Driveway: 235
[2022-09-16 14:03:41] frigate.app                    INFO    : Capture process started for Back_Patio: 238
[2022-09-16 14:03:41] frigate.app                    INFO    : Capture process started for G4_Doorbell_Pro: 242
[2022-09-16 14:03:41] ws4py                          INFO    : Using epoll
[2022-09-16 14:03:45] frigate.edgetpu                INFO    : TPU found
[2022-09-16 14:04:12] ws4py                          INFO    : Managing websocket [Local => 127.0.0.1:5002 | Remote => 127.0.0.1:49792]
[2022-09-16 14:08:52] ws4py                          INFO    : Terminating websocket [Local => 127.0.0.1:5002 | Remote => 127.0.0.1:49792]
[2022-09-16 14:10:09] frigate.video                  ERROR   : Back_Patio: Unable to read frames from ffmpeg process.
[2022-09-16 14:10:09] frigate.video                  ERROR   : Back_Patio: ffmpeg process is not running. exiting capture thread...
[2022-09-16 14:10:09] frigate.video                  ERROR   : Driveway: Unable to read frames from ffmpeg process.
[2022-09-16 14:10:09] frigate.video                  ERROR   : Driveway: ffmpeg process is not running. exiting capture thread...
[2022-09-16 14:10:09] frigate.video                  ERROR   : G4_Doorbell_Pro: Unable to read frames from ffmpeg process.
[2022-09-16 14:10:09] frigate.video                  ERROR   : G4_Doorbell_Pro: ffmpeg process is not running. exiting capture thread...
[2022-09-16 14:10:13] frigate.app                    INFO    : Starting Frigate (0.10.1-83481af)
Starting migrations
[2022-09-16 14:10:13] peewee_migrate                 INFO    : Starting migrations
There is nothing to migrate
[2022-09-16 14:10:13] peewee_migrate                 INFO    : There is nothing to migrate
[2022-09-16 14:10:13] frigate.app                    INFO    : Output process started: 226
[2022-09-16 14:10:13] detector.coral                 INFO    : Starting detection process: 225
[2022-09-16 14:10:13] ws4py                          INFO    : Using epoll
[2022-09-16 14:10:13] frigate.app                    INFO    : Camera processor started for Driveway: 232
[2022-09-16 14:10:13] frigate.edgetpu                INFO    : Attempting to load TPU as usb
[2022-09-16 14:10:13] frigate.app                    INFO    : Camera processor started for Back_Patio: 236
[2022-09-16 14:10:16] frigate.edgetpu                INFO    : TPU found
[2022-09-16 14:10:13] frigate.app                    INFO    : Camera processor started for G4_Doorbell_Pro: 237
[2022-09-16 14:10:13] frigate.app                    INFO    : Capture process started for Driveway: 239
[2022-09-16 14:10:13] frigate.app                    INFO    : Capture process started for Back_Patio: 242
[2022-09-16 14:10:13] frigate.app                    INFO    : Capture process started for G4_Doorbell_Pro: 245
[2022-09-16 14:10:13] ws4py                          INFO    : Using epoll
[2022-09-16 14:10:24] ws4py                          INFO    : Managing websocket [Local => 127.0.0.1:5002 | Remote => 127.0.0.1:51126]
[2022-09-16 14:10:26] ws4py                          INFO    : Managing websocket [Local => 127.0.0.1:8082 | Remote => 127.0.0.1:36646]
[2022-09-16 14:10:32] ws4py                          INFO    : Terminating websocket [Local => 127.0.0.1:8082 | Remote => 127.0.0.1:36646]
[2022-09-16 14:10:33] ws4py                          INFO    : Managing websocket [Local => 127.0.0.1:8082 | Remote => 127.0.0.1:36660]
[2022-09-16 14:10:33] frigate.output                 WARNING : Unable to copy frame G4_Doorbell_Pro1663355432.560602 to birdseye.
[2022-09-16 14:17:04] ws4py                          INFO    : Terminating websocket [Local => 127.0.0.1:8082 | Remote => 127.0.0.1:36660]
[2022-09-16 15:02:56] ws4py                          INFO    : Terminating websocket [Local => 127.0.0.1:5002 | Remote => 127.0.0.1:51126]
[2022-09-16 15:02:56] frigate.video                  ERROR   : G4_Doorbell_Pro: Unable to read frames from ffmpeg process.
[2022-09-16 15:02:56] frigate.video                  ERROR   : Driveway: Unable to read frames from ffmpeg process.
[2022-09-16 15:02:56] frigate.video                  ERROR   : G4_Doorbell_Pro: ffmpeg process is not running. exiting capture thread...
[2022-09-16 15:02:56] frigate.video                  ERROR   : Back_Patio: Unable to read frames from ffmpeg process.
[2022-09-16 15:02:56] frigate.video                  ERROR   : Back_Patio: ffmpeg process is not running. exiting capture thread...
[2022-09-16 15:02:56] frigate.video                  ERROR   : Driveway: ffmpeg process is not running. exiting capture thread...
[2022-09-16 15:03:07] frigate.app                    INFO    : Starting Frigate (0.10.1-83481af)
Starting migrations
[2022-09-16 15:03:07] peewee_migrate                 INFO    : Starting migrations
There is nothing to migrate
[2022-09-16 15:03:07] peewee_migrate                 INFO    : There is nothing to migrate
[2022-09-16 15:03:07] detector.coral                 INFO    : Starting detection process: 225
[cont-init.d] done.
[services.d] starting services
[services.d] done.
[cont-finish.d] executing container finish scripts...
[cont-finish.d] done.
[s6-finish] waiting for services.
[s6-finish] sending all processes the TERM signal.
[s6-finish] sending all processes the KILL signal and exiting.
[s6-init] making user provided files available at /var/run/s6/etc...exited 0.
[s6-init] ensuring user provided files have correct perms...exited 0.
[fix-attrs.d] applying ownership & permissions fixes...
[fix-attrs.d] done.
[cont-init.d] executing container initialization scripts...
[cont-init.d] done.
[services.d] starting services
[services.d] done.
[cont-finish.d] executing container finish scripts...
[cont-finish.d] done.
[s6-finish] waiting for services.
[s6-finish] sending all processes the TERM signal.
[s6-finish] sending all processes the KILL signal and exiting.
[s6-init] making user provided files available at /var/run/s6/etc...exited 0.
[s6-init] ensuring user provided files have correct perms...exited 0.
[fix-attrs.d] applying ownership & permissions fixes...
[fix-attrs.d] done.
[cont-init.d] executing container initialization scripts...
[cont-init.d] done.
[services.d] starting services
[services.d] done.

FFprobe output from your camera

ffprobe version 2022-09-15-git-3f0fac9303-full_build-www.gyan.dev Copyright (c) 2007-2022 the FFmpeg developers
  built with gcc 12.1.0 (Rev2, Built by MSYS2 project)
  configuration: --enable-gpl --enable-version3 --enable-static --disable-w32threads --disable-autodetect --enable-fontconfig --enable-iconv --enable-gnutls --enable-libxml2 --enable-gmp --enable-bzlib --enable-lzma --enable-libsnappy --enable-zlib --enable-librist --enable-libsrt --enable-libssh --enable-libzmq --enable-avisynth --enable-libbluray --enable-libcaca --enable-sdl2 --enable-libdav1d --enable-libdavs2 --enable-libuavs3d --enable-libzvbi --enable-librav1e --enable-libsvtav1 --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs2 --enable-libxvid --enable-libaom --enable-libjxl --enable-libopenjpeg --enable-libvpx --enable-mediafoundation --enable-libass --enable-frei0r --enable-libfreetype --enable-libfribidi --enable-liblensfun --enable-libvidstab --enable-libvmaf --enable-libzimg --enable-amf --enable-cuda-llvm --enable-cuvid --enable-ffnvcodec --enable-nvdec --enable-nvenc --enable-d3d11va --enable-dxva2 --enable-libmfx --enable-libshaderc --enable-vulkan --enable-libplacebo --enable-opencl --enable-libcdio --enable-libgme --enable-libmodplug --enable-libopenmpt --enable-libopencore-amrwb --enable-libmp3lame --enable-libshine --enable-libtheora --enable-libtwolame --enable-libvo-amrwbenc --enable-libilbc --enable-libgsm --enable-libopencore-amrnb --enable-libopus --enable-libspeex --enable-libvorbis --enable-ladspa --enable-libbs2b --enable-libflite --enable-libmysofa --enable-librubberband --enable-libsoxr --enable-chromaprint
  libavutil      57. 36.101 / 57. 36.101
  libavcodec     59. 43.100 / 59. 43.100
  libavformat    59. 31.100 / 59. 31.100
  libavdevice    59.  8.101 / 59.  8.101
  libavfilter     8. 49.100 /  8. 49.100
  libswscale      6.  8.112 /  6.  8.112
  libswresample   4.  9.100 /  4.  9.100
  libpostproc    56.  7.100 / 56.  7.100
rtsp://192.168.1.10:7441/2V6OZFHH6UxgtPie: Invalid data found when processing input

Frigate stats

{"Back_Patio":{"camera_fps":5.0,"capture_pid":241,"detection_fps":5.7,"pid":235,"process_fps":5.1,"skipped_fps":0.0},"Driveway":{"camera_fps":5.0,"capture_pid":238,"detection_fps":0.0,"pid":233,"process_fps":5.0,"skipped_fps":0.0},"G4_Doorbell_Pro":{"camera_fps":5.0,"capture_pid":245,"detection_fps":5.2,"pid":237,"process_fps":5.1,"skipped_fps":0.0},"detection_fps":10.9,"detectors":{"coral":{"detection_start":1663364002.138628,"inference_speed":24.02,"pid":225}},"service":{"storage":{"/dev/shm":{"free":5336.8,"mount_type":"tmpfs","total":5368.7,"used":31.9},"/media/frigate/clips":{"free":31966318.2,"mount_type":"fuse.shfs","total":113992993.3,"used":82026675.1},"/media/frigate/recordings":{"free":31966318.2,"mount_type":"fuse.shfs","total":113992993.3,"used":82026675.1},"/tmp/cache":{"free":15742.1,"mount_type":"rootfs","total":16593.9,"used":851.9}},"temperatures":{},"uptime":5415,"version":"0.10.1-83481af"}}

Operating system

HassOS

Install method

HassOS Addon

Coral version

USB

Network connection

Wired

Camera make and model

Unifi G3 and G4, G4 Doorbell Pro

Any other information that may be helpful

I wasnt sure on how to say the install method, I am running this as a Virtual Machine on a Unraid Server.

Thanks everyone for their assistance on this, I’m not even sure if it’s a problem, it just seems like a lot of CPU usage for only 3 cameras and a Coral being used.

Thanks!

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:7

github_iconTop GitHub Comments

1reaction
NickM-27commented, Sep 16, 2022

I see a number of issues with your config that would increase CPU usage:

  1. You aren’t using hardware acceleration for video decoding
  2. I also see some detect resolutions that I highly doubt are the actual resolutions of the stream. In case you didn’t know, whatever resolution you enter in detect -> width / height, frigate will resize the stream to that size if it isn’t already. This of course uses more CPU than if you just leave it as the size that it is (meaning setting it to the actual size)
    detect: 
      width: 2688 # i really doubt a stream is this size, but your ffprobe didn't work so I can't say for sure
      height: 1512 # same here
0reactions
Coltonc188commented, Sep 16, 2022

Got it added, and it made a huge improvement!! The frigate container is only using about 5% idling now, compared to the 15% before.

Thanks so much for taking the time to look through this, I knew I was overlooking something ridiculous, but I had gotten to the point where I was just seeing the same thing over and over.

Thank you!

Read more comments on GitHub >

github_iconTop Results From Across the Web

I have a Coral, but my CPU usage is still high #3860 - GitHub
Common config issues causing higher than expected CPU load: We get this question pretty often. While object detection is a considerable load ...
Read more >
ELI5 Frigate CPU usage w Coral : r/homeassistant - Reddit
I got a Coral PCI and it has definitely improved the overall stability of Frigate but...if I use a hi-rez stream for "detect"...
Read more >
Creating an AWS Fargate service using the AWS CDK
This example walks you through how to create an AWS Fargate service running on an Amazon Elastic Container Service (Amazon ECS) cluster that's...
Read more >
TensorFlow models on the Edge TPU - Coral.ai
Details about how to create TensorFlow Lite models that are compatible with the Edge TPU.
Read more >
How to run tensorflow model on Coral CPU - Stack Overflow
Any model that is not Edge TPU compatible will run on the CPU by default. From the TensorFlow on Edge TPU >Model Requirements...
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