← Back to Guides
InsightFace ServerDockerFace RecognitionCUDASelf-hosted

Deploy InsightFace Server with Docker

Deploy InsightFace Server on CPU or CUDA with Docker, install a licensed model, run your first exact 1:N search, and secure persistent data.

10 min read
InsightFace Server dashboard showing service, model, database, and runtime status
Use Dashboard and System to confirm every dependency is ready before enrollment.

What you will build

InsightFace Server packages face detection, comparison, enrollment, exact 1:N Person search, a multilingual Web UI, a REST API, SQLite, and local inference into one self-hosted service. Images, embeddings, models, and indexes can remain inside infrastructure you control.

This quickstart takes a complete InsightFace repository checkout from model installation to a working search. It also covers the boundaries that matter before a real deployment: model authorization, authentication, HTTPS, persistent data, safe shutdown, and fail-fast CUDA diagnostics.

The Server is a privacy-focused alternative for common face-recognition workflows, not an AWS Rekognition-compatible replacement. It does not implement AWS IAM, SigV4, Region semantics, built-in TLS, user accounts, or RBAC.

Before you start

  • A complete InsightFace repository checkout on a Linux x86_64 host with Docker Engine and Docker Compose.
  • For CUDA 12: a supported NVIDIA GPU, NVIDIA Driver, and NVIDIA Container Toolkit. The host does not need the CUDA Toolkit, cuDNN, ONNX Runtime, Python, or OpenCV.
  • Network access while pulling the container and installing a model. Normal Server startup can remain offline after the package is installed.
  • Authorization to process biometric data and a documented policy for consent, access, retention, deletion, backup, and incident response.

1. Choose CPU or CUDA and install the model

Run commands from the root of a complete InsightFace checkout and choose one Compose stack. CPU is the simplest evaluation path and publishes port 18097. CUDA publishes port 18098 and requires a compatible NVIDIA Driver plus NVIDIA Container Toolkit; do not install host CUDA or cuDNN for this container.

The commands below deliberately use the non-interactive --accept-license option and immediately verify buffalo_l. Use it only after your organization has reviewed and accepted the displayed model terms. The same installer also supports buffalo_m, buffalo_sc, and antelopev2.

  • Turing, Ampere, Ada, and Hopper deployments require Driver R535 or newer; Blackwell and RTX 50-series deployments require 570.26 or newer. A stable R580-or-newer driver is recommended for new deployments.
  • Public images contain no models, customer data, API keys, or production configuration.
  • Do not mix the CPU and CUDA Compose files for one deployment; their images, ports, providers, and named data volumes are intentionally separate.
CPU: pull, accept the model license, install, and verify
mkdir -p server/.models
docker compose -f server/deploy/compose.cpu.yml pull
docker compose -f server/deploy/compose.cpu.yml \
  run --rm models install buffalo_l --accept-license
docker compose -f server/deploy/compose.cpu.yml \
  run --rm models verify buffalo_l
CUDA 12: pull, accept the model license, install, and verify
mkdir -p server/.models
docker compose -f server/deploy/compose.cuda12.yml pull
docker compose -f server/deploy/compose.cuda12.yml \
  run --rm models install buffalo_l --accept-license
docker compose -f server/deploy/compose.cuda12.yml \
  run --rm models verify buffalo_l

2. Understand the model license boundary

The Server source code and Python SDK are MIT-licensed, but model files and weights are not covered by that MIT license. Public InsightFace model packages, including buffalo_l, are generally limited to non-commercial academic research unless InsightFace has issued a separate commercial authorization; self-hosting the Server does not grant commercial model rights.

Installation writes manifest.json and a signed MODEL.LICENSE into server/.models. Verification checks package identity, the signed license, validity dates, and current authorization. The license identifies the model and permitted use; it is a compliance credential, not DRM and not a checksum of the model files.

  • Without --accept-license, the installer prints the terms and exits without downloading.
  • Keep the model directory, manifest, and license files together, and mount /models read-only during normal operation.
  • Contact InsightFace before commercial use or when your deployment scope is not covered by the public-model terms.

3. Start the service and confirm readiness

Start only the stack you installed. Open http://SERVER:18097/ for CPU or http://SERVER:18098/ for CUDA. The health request confirms that the HTTP service is responding; before enrolling data, also inspect Dashboard or System and confirm that the service, database, model, and execution provider are ready.

A CUDA deployment must report CUDAExecutionProvider. Startup validates the GPU, Driver, CUDA/cuDNN/ONNX Runtime versions, real detector and recognizer sessions, provider placement, and warm-up inference. It terminates on failure instead of silently falling back to CPU.

Start CPU and check health
docker compose -f server/deploy/compose.cpu.yml up -d
curl -fsS http://127.0.0.1:18097/v1/health
Start CUDA 12 and check health
docker compose -f server/deploy/compose.cuda12.yml up -d
curl -fsS http://127.0.0.1:18098/v1/health

4. Complete the first Collection → Person → Search workflow

InsightFace Server Collections screen for creating and managing searchable face collections
Create a model-bound Collection before registering People and FaceSamples.

In Collections, create a stable ID such as employees. Choose a search profile advertised by System, set capacity for your memory budget, and begin with the default raw-cosine threshold of 0.4. A Collection is pinned to its model identity, digest, embedding dimension, preprocessing version, and detection profile contract.

In People, select the Collection and register one Person with one or more clear JPEG, PNG, or WebP photos. Standard review is a useful starting point because it checks that exactly one usable face meets size, confidence, sharpness, brightness, and pose rules. Batch enrollment can partially succeed, so inspect each rejection reason rather than resubmitting the entire batch blindly.

In Search, select the same Collection and upload a different photo of that Person. Results are sorted by raw cosine similarity, and a Person's score is the best score among their FaceSamples. Similarity is not a probability. A successful no-match is an empty list, not a Server error.

  • Original uploads are not retained by default. Optional face storage saves a resized 112×112 bounding-box JPEG crop, not the original image or the aligned recognition input.
  • Accepted samples are committed to SQLite and added to the in-memory exact index before a successful response returns. The index is rebuilt from SQLite after restart.
  • If you use Detect or Compare first, no detected face is a valid empty result for Detect; Compare returns 422 face_not_found when either side has no usable face.

5. Secure the service before network exposure

The supplied Compose files default to authentication disabled for isolated evaluation. Before any other user or network can reach the service, enable authentication and set one long, random API key in the deployment secret environment. Restart the chosen stack with those values; the Web UI can keep the key in memory for the current browser tab.

Terminate HTTPS at a trusted reverse proxy, expose only required origins instead of broad CORS, add edge rate/body/time limits, and restrict access to Docker, /data, /models, and backups. Never log images, embeddings, RTSP credentials, or API keys. Treat every stored face artifact as biometric data.

  • Phase one has one undifferentiated API key; it is not a multi-tenant authorization system and provides no built-in user accounts or RBAC.
  • Starting the same data volume later with a different INSIGHTFACE_API_KEY intentionally rotates the active key.
  • The Server does not provide built-in TLS or a legal-compliance layer; deployment controls and lawful processing remain the operator's responsibility.
CPU: enable authentication before startup
export INSIGHTFACE_AUTH_ENABLED=true
export INSIGHTFACE_API_KEY='replace-with-a-long-random-secret'
docker compose -f server/deploy/compose.cpu.yml up -d
CUDA 12: enable authentication before startup
export INSIGHTFACE_AUTH_ENABLED=true
export INSIGHTFACE_API_KEY='replace-with-a-long-random-secret'
docker compose -f server/deploy/compose.cuda12.yml up -d

6. Preserve data, back up, and stop safely

SQLite in /data is the durable source of truth, while the exact-search indexes in memory are disposable. The Compose stack mounts the model directory read-only and keeps /data in a named volume. Back up the SQLite database and any configured crop storage together while writes are stopped, or use a SQLite-safe snapshot method.

Use the complete down command for the stack you started. Plain down removes containers and the network but preserves the named database volume. Never append -v: docker compose down -v permanently deletes that named data volume.

  • Before an upgrade, take a safe snapshot, retain /models and its license files, and test the new image against a copy of the data first.
  • After restart or upgrade, check migrations, /v1/health, the model contract, and one known search.
  • Deleting a FaceSample removes its embedding and optional crop; deleting a non-empty Collection requires explicit force confirmation.
Stop the CPU stack without deleting its volume
docker compose -f server/deploy/compose.cpu.yml down
Stop the CUDA stack without deleting its volume
docker compose -f server/deploy/compose.cuda12.yml down

7. Diagnose startup and request failures

Start with the health endpoint, then inspect System and the selected Compose stack's container status and logs. On CUDA, a startup failure is intentional if the Driver, GPU, model sessions, CUDAExecutionProvider, provider audit, or warm-up check fails; there is no silent CPU fallback.

Every response carries x-request-id, and error bodies expose a request_id. Preserve that identifier with the relevant log window when reporting a problem. A 401 unauthorized usually means the current tab has no key or the key was rotated; 409 collection_model_mismatch means the Collection belongs to another model contract; 422 face_not_found means no usable face was selected.

  • Confirm CPUExecutionProvider or CUDAExecutionProvider on System matches the Compose file you selected.
  • Check that server/.models contains the verified package and signed license, and that /models is mounted read-only.
  • For CUDA, fix the host Driver, GPU visibility, or NVIDIA Container Toolkit issue rather than expecting a CPU fallback.
CPU health, status, and recent logs
curl -fsS http://127.0.0.1:18097/v1/health
docker compose -f server/deploy/compose.cpu.yml ps
docker compose -f server/deploy/compose.cpu.yml logs --tail=200 server
CUDA 12 health, status, and recent logs
curl -fsS http://127.0.0.1:18098/v1/health
docker compose -f server/deploy/compose.cuda12.yml ps
docker compose -f server/deploy/compose.cuda12.yml logs --tail=200 server

Need help with production deployment?

Contact InsightFace for model licensing, runtime optimization, and deployment support for your target hardware.

Submit Enterprise Inquiry