blakeblackshear / frigate

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

nginx error 12: Cannot allocate memory #1706

Open FM-17 opened 3 years ago

FM-17 commented 3 years ago

Describe the bug Frigate 9.0+ is failing to start due to an nginx related memory error on my Google Coral Dev Board. Frigate 8.4 runs fine. This is my first attempt at frigate so I apologize if this was caused by a minor oversight.

Version of frigate frigate:0.9.0-rc2-aarch64

Config file

mqtt:
  host: <ANON_HOST_IP>
  port: 1883
  topic_prefix: frigate
detectors:
  coral:
    type: edgetpu
    device: ''
cameras:
  front_door:
    ffmpeg:
      inputs:
        - path: rtsp://{FRIGATE_RTSP_USER}:{FRIGATE_RTSP_PASSWORD}@{FRIGATE_RTSP_IP}:554/stream2
          roles:
            - detect
            - record
    detect:
      width: 640
      height: 360
      fps: 5
      enabled: True
      max_disappeared: 25
    motion:
      mask: 0,0,238,0,236,25,0,25
    record:
      enabled: False
      retain_days: 0
      events:
        enabled: True
        pre_capture: 5
        post_capture: 5
        objects:
          - person
        required_zones: []
        retain:
          default: 10
          objects:
            person: 15
    rtmp:
      enabled: False
    live:
      height: 360
      quality: 8
    objects:
      track:
        - person

Frigate container logs

fm@coral:~/home$ docker-compose up
Starting frigate ... done
Attaching to frigate
frigate    | [s6-init] making user provided files available at /var/run/s6/etc...exited 0.
frigate    | [s6-init] ensuring user provided files have correct perms...exited 0.
frigate    | [fix-attrs.d] applying ownership & permissions fixes...
frigate    | [fix-attrs.d] done.
frigate    | [cont-init.d] executing container initialization scripts...
frigate    | [cont-init.d] done.
frigate    | [services.d] starting services
frigate    | [services.d] done.
frigate    | nginx: [alert] mmap(MAP_ANON|MAP_SHARED, 536870912) failed (12: Cannot allocate memory)
frigate    | nginx: [alert] munmap(FFFFFFFFFFFFFFFF, 536870912) failed (22: Invalid argument)
frigate    | [cont-finish.d] executing container finish scripts...
frigate    | [cont-finish.d] done.
frigate    | [s6-finish] waiting for services.
frigate    | [s6-finish] sending all processes the TERM signal.
frigate    | [s6-finish] sending all processes the KILL signal and exiting.

FFprobe from camera

 ffprobe rtsp://{FRIGATE_RTSP_USER}:{FRIGATE_RTSP_PASSWORD}@{FRIGATE_RTSP_IP}:554/stream2
ffprobe version 3.4.8-0ubuntu0.2 Copyright (c) 2007-2020 the FFmpeg developers
  built with gcc 7 (Ubuntu 7.5.0-3ubuntu1~18.04)
  configuration: --prefix=/usr --extra-version=0ubuntu0.2 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --enable-gpl --disable-stripping --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librubberband --enable-librsvg --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-omx --enable-openal --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libopencv --enable-libx264 --enable-shared
  libavutil      55. 78.100 / 55. 78.100
  libavcodec     57.107.100 / 57.107.100
  libavformat    57. 83.100 / 57. 83.100
  libavdevice    57. 10.100 / 57. 10.100
  libavfilter     6.107.100 /  6.107.100
  libavresample   3.  7.  0 /  3.  7.  0
  libswscale      4.  8.100 /  4.  8.100
  libswresample   2.  9.100 /  2.  9.100
  libpostproc    54.  7.100 / 54.  7.100
Input #0, rtsp, from 'rtsp://{FRIGATE_RTSP_USER}:{FRIGATE_RTSP_PASSWORD}@{FRIGATE_RTSP_IP}:554/stream2':
  Metadata:
    title           : Session streamed by "TP-LINK RTSP Server"
    comment         : stream2
  Duration: N/A, start: 0.000000, bitrate: N/A
    Stream #0:0: Video: h264 (High), yuvj420p(pc, bt709, progressive), 640x360, 15 fps, 15 tbr, 90k tbn, 30 tbc
    Stream #0:1: Audio: pcm_alaw, 8000 Hz, 1 channels, s16, 64 kb/s

Computer Hardware

Camera Info:

Additional context I am starting Frigate from a docker container using the following docker-compose config:

version: "3.9"
services:
  frigate:
    container_name: frigate
    image: blakeblackshear/frigate:0.9.0-rc2-aarch64
    privileged: true 
    restart: unless-stopped
    volumes:
      - /etc/localtime:/etc/localtime:ro
      - $FRIGATE_DATA_PATH/config.yml:/config/config.yml:ro
      - $FRIGATE_MEDIA_PATH:/media/frigate
    ports:
      - "5000:5000"
      - "1935:1935" # RTMP feeds
      - "1883:1883"
    environment:
      FRIGATE_RTSP_PASSWORD: $FRIGATE_RTSP_PASSWORD
      FRIGATE_RTSP_USER: $FRIGATE_RTSP_USER

My /etc/docker/daemon.json file is as follows:

{
    "default-shm-size": "256M"
}
blakeblackshear commented 3 years ago

It's probably some kind of issue with the custom nginx build that is not compatible with the Coral Dev board. This happened once for another dependency. It's virtually impossible for me to track down without having a dev board.

FM-17 commented 3 years ago

Right on, is there anything I can do to lend a hand, given that I have a dev board?

blakeblackshear commented 3 years ago

My best guess is that something needs to change here: https://github.com/blakeblackshear/frigate/blob/release-0.9.0/docker/Dockerfile.nginx

FM-17 commented 3 years ago

Sounds good, I'll take a look.

stale[bot] commented 2 years ago

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.

travipross commented 2 years ago

+1

ozett commented 2 years ago

maybe the memory is allocated by VOD on the coral-dev-board since 0.9x. and maybe it oculd be configured to give up that allocation

nickrout commented 2 years ago

Does anyone know if this has been fixed? I am keen to try frigate, but the only corals I can find are dev boards. GRRR global chip shortage

ozett commented 2 years ago

up to now unchanged, i guess. latest 10-beta 6 seems still to have a unchanged high vod value in the sourccode...

https://github.com/blakeblackshear/frigate/blob/db1255aa7fe242491d3a5f1a148a2f255b78b42b/docker/rootfs/usr/local/nginx/conf/nginx.conf#L60

nickrout commented 2 years ago

Thanks.

addrum commented 1 year ago

I'm also hitting this but with a USB Coral on the latest stable frigate.

[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.
nginx: [alert] mmap(MAP_ANON|MAP_SHARED, 536870912) failed (12: Cannot allocate memory)
nginx: [alert] munmap(FFFFFFFFFFFFFFFF, 536870912) failed (22: Invalid argument)
[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.
velkrosmaak commented 1 year ago

I'm getting the exact same trying to do this without a Coral, only CPU.