Running Savant Module

Savant is a cloud-ready solution. You can easily run it in K8s, Docker and other containerized runtimes.

All pieces of Savant framework are normally run in docker containers. We provide docker compose files for all examples we have developed so far.

To get an idea how to run a Savant module, let us take a look at the docker compose from one of the Savant examples:

services:

  video-loop-source:
    image: ghcr.io/insight-platform/savant-adapters-gstreamer:latest
    restart: unless-stopped
    volumes:
      - zmq_sockets:/tmp/zmq-sockets
      - /tmp/video-loop-source-downloads:/tmp/video-loop-source-downloads
    environment:
      - LOCATION=https://eu-central-1.linodeobjects.com/savant-data/demo/deepstream_sample_720p.mp4
      - DOWNLOAD_PATH=/tmp/video-loop-source-downloads
      - ZMQ_ENDPOINT=pub+connect:ipc:///tmp/zmq-sockets/input-video.ipc
      - SOURCE_ID=nvidia-sample-processed
      - SYNC_OUTPUT=True
    entrypoint: /opt/savant/adapters/gst/sources/video_loop.sh
    depends_on:
      module:
        condition: service_healthy

  module:
    image: ghcr.io/insight-platform/savant-deepstream:latest
    restart: unless-stopped
    volumes:
      - zmq_sockets:/tmp/zmq-sockets
      - ../../cache:/cache
      - ..:/opt/savant/samples
    command: samples/nvidia_car_classification/module.yml
    environment:
      - MODEL_PATH=/cache/models/nvidia_car_classification
      - DOWNLOAD_PATH=/cache/downloads/nvidia_car_classification
      - ZMQ_SRC_ENDPOINT=sub+bind:ipc:///tmp/zmq-sockets/input-video.ipc
      - ZMQ_SINK_ENDPOINT=pub+bind:ipc:///tmp/zmq-sockets/output-video.ipc
      - METRICS_FRAME_PERIOD=1000
    deploy:
      resources:
        reservations:
          devices:
            - driver: nvidia
              count: 1
              capabilities: [ gpu ]

  always-on-sink:
    image: ghcr.io/insight-platform/savant-adapters-deepstream:latest
    restart: unless-stopped
    ports:
      - "554:554"    # RTSP
      - "1935:1935"  # RTMP
      - "888:888"    # HLS
      - "8889:8889"  # WebRTC
    volumes:
      - zmq_sockets:/tmp/zmq-sockets
      - ../assets/stub_imgs:/stub_imgs
    environment:
      - ZMQ_ENDPOINT=sub+connect:ipc:///tmp/zmq-sockets/output-video.ipc
      - SOURCE_ID=nvidia-sample-processed
      - STUB_FILE_LOCATION=/stub_imgs/smpte100_1280x720.jpeg
      - DEV_MODE=True
    command: python -m adapters.ds.sinks.always_on_rtsp
    deploy:
      resources:
        reservations:
          devices:
            - driver: nvidia
              count: 1
              capabilities: [ gpu ]

volumes:
  zmq_sockets:

The file introduces several services:

  • module: the Savant module that runs video analytics on the video streams;

  • video-loop-source: the adapter that ingests looped video stream from a file to the module;

  • always-on-sink: the adapter that receives the results of video analytics and represents them as RTSP or HLS stream.

In the following sections, we dive into the details of modules and explain what the adapters are and how do they communicate with modules.

Healthcheck

The Savant module image provides a healthcheck to indicate when the module is ready to receive video frames. You can use it to start a source adapter only when the module is ready to receive frames by adding depends_on section to the source adapter service in the docker compose file:

depends_on:
  module:
    condition: service_healthy

Also an HTTP healthcheck endpoint can be enabled by setting healthcheck_port parameter in the module configuration (HEALTHCHECK_PORT env). The healthcheck endpoint is available at http://<module_host>:<healthcheck_port>/healthcheck.

The healthcheck endpoint responses with one of the following statuses: - starting (503 Service Unavailable) - the module is starting up and is not ready to receive frames yet; - running (200 OK) - the module is running and is ready to receive frames; - stopping (503 Service Unavailable) - the module is stopping. It is not ready to receive frames anymore but can still send results to the sink; - stopped (503 Service Unavailable) - the module was stopped.