You are viewing archived documentation for v0.100. Go to latest →

Workers Deployment

Inference workers run the BirdNET model to identify bird species from audio chunks submitted by satellites.

What Workers Do

  • BirdNET inference — classify 3-second audio chunks using TFLite and birdnetlib
  • Enhanced re-processing — extended window analysis, frequency isolation, and cross-chunk correlation for improved accuracy
  • Workers are stateless — they pull jobs from Redis (BullMQ), fetch audio from MinIO, run inference, and write results to PostgreSQL

Docker Deployment (Default)

The default deployment runs workers alongside the hub via Docker Compose. This is the simplest setup and requires no extra configuration.

Workers are included in the standard docker-compose.yml stack, one by default. To scale:

# Run 4 inference workers
docker compose up --scale worker=4 -d

Workers are stateless — add as many as needed for your detection volume. Each worker connects to the shared Redis, MinIO, and PostgreSQL services within the Docker network.

Standalone Linux Deployment

Workers can run on a separate machine (or multiple machines) outside Docker, connecting to the hub's Redis, MinIO, and PostgreSQL over the network. This is useful for distributing inference load across hardware.

Requirements

  • Python 3.11
  • libsndfile1 and ffmpeg (Debian: sudo apt install libsndfile1 ffmpeg)
  • Network access to the hub's Redis, MinIO, and PostgreSQL

Setup

# Clone the repository (replace with your Git server URL)
git clone <your-git-server>/otavi.git
cd otavi/packages/inference

python3.11 -m venv venv
source venv/bin/activate
# The exact package versions the worker's image runs, then the worker itself
pip install -r requirements.lock
pip install --no-deps .

requirements.lock pins every package, the ones pyproject.toml names and all they pull in, so every worker runs the same versions. After changing a range in pyproject.toml, pnpm worker:lock resolves them again (in the worker's base image) and rewrites the lock.

Configuration

Every setting is an OTAVI_ variable, exported or in a .env file (the worker uses pydantic-settings), with the same names as in the hub's .env:

Variable Description Default
OTAVI_REDIS_HOST, OTAVI_REDIS_PORT, OTAVI_REDIS_PASSWORD Redis localhost, 6379, none
OTAVI_DB_HOST, OTAVI_DB_PORT, OTAVI_DB_NAME, OTAVI_DB_USER, OTAVI_DB_PASSWORD PostgreSQL localhost, 5432, otavi, otavi, otavi
OTAVI_S3_ENDPOINT MinIO, as host:port localhost:9000
OTAVI_S3_ACCESS_KEY, OTAVI_S3_SECRET_KEY MinIO credentials (from the hub's .env)
OTAVI_S3_BUCKET_PREFIX Buckets <prefix>-audio, <prefix>-models otavi
OTAVI_S3_USE_SSL TLS to MinIO false
OTAVI_WORKER_MODEL_CACHE_DIR Local copy of the registry's models /tmp/otavi-models-cache

Run

source venv/bin/activate
worker

For production, set up a systemd service:

sudo tee /etc/systemd/system/otavi-worker.service << 'EOF'
[Unit]
Description=Otavi Inference Worker
After=network-online.target
Wants=network-online.target

[Service]
Type=simple
User=otavi
WorkingDirectory=/opt/otavi/packages/inference
EnvironmentFile=/opt/otavi/packages/inference/.env
ExecStart=/opt/otavi/packages/inference/venv/bin/worker
Restart=always
RestartSec=10

[Install]
WantedBy=multi-user.target
EOF

sudo systemctl enable --now otavi-worker

Windows Deployment

::: warning Coming Soon Windows standalone worker deployment is planned but not yet documented. The inference package requires Python 3.11 and numpy<2. Contributions welcome. :::

macOS Deployment

::: warning Coming Soon macOS standalone worker deployment is planned but not yet documented. The inference package requires Python 3.11 and numpy<2. Contributions welcome. :::

GPU Acceleration

By default, workers use CPU inference via TFLite. For higher throughput, GPU acceleration can be enabled:

CUDA (NVIDIA GPUs)

Install the TFLite GPU delegate or use the full TensorFlow package with CUDA support. This requires:

  • NVIDIA GPU with CUDA support
  • CUDA toolkit and cuDNN installed
  • tflite-runtime replaced with GPU-enabled build, or full tensorflow package

TFLite GPU Delegate

The TFLite GPU delegate can offload inference to the GPU with minimal configuration changes. Refer to the TFLite GPU delegate documentation for setup instructions.

Scaling

  • Docker: docker compose up --scale worker=N -d — each worker is an independent container
  • Standalone: run multiple worker processes on the same or different machines, all pointing at the same Redis queue
  • Workers automatically distribute jobs via BullMQ's built-in concurrency — no manual partitioning needed