frigate icon indicating copy to clipboard operation
frigate copied to clipboard

nginx error 12: Cannot allocate memory

Open FM-17 opened this issue 3 years ago • 12 comments

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

  • OS: Mendel Linux (Debian 8)
  • Install method: Docker Compose
  • Coral Version: Coral Dev Board
  • Network Setup: Ethernet

Camera Info:

  • Manufacturer: TP-Link
  • Model: Tapo C100 (also tested with C200)
  • Resolution: Using 640x360 stream
  • FPS: 5

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"
}

FM-17 avatar Sep 05 '21 00:09 FM-17

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.

blakeblackshear avatar Sep 05 '21 02:09 blakeblackshear

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

FM-17 avatar Sep 05 '21 02:09 FM-17

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

blakeblackshear avatar Sep 05 '21 03:09 blakeblackshear

Sounds good, I'll take a look.

FM-17 avatar Sep 05 '21 03:09 FM-17

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[bot] avatar Oct 05 '21 04:10 stale[bot]

+1

travipross avatar Oct 06 '21 03:10 travipross

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

ozett avatar Nov 09 '21 22:11 ozett

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

nickrout avatar Jan 31 '22 01:01 nickrout

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

ozett avatar Jan 31 '22 07:01 ozett

Thanks.

nickrout avatar Jan 31 '22 21:01 nickrout

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.

addrum avatar Jan 31 '23 23:01 addrum

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

velkrosmaak avatar Mar 04 '23 01:03 velkrosmaak