Skip to main content

Prerequisites

Before deploying serverless functions, ensure you have:
  • CVAT self-hosted installation running
  • Docker installed and running
  • Nuclio CLI (nuctl) installed
  • Access to the CVAT serverless functions repository
  • Sufficient system resources (4GB+ RAM recommended for model loading)

Installation

Install Nuclio CLI

Clone Serverless Functions

The serverless functions are included in the CVAT repository:

Deployment Options

Option 1: Deploy All CPU Functions

Deploy all available functions optimized for CPU:
This script:
  1. Builds the OpenVINO base image
  2. Creates a cvat project in Nuclio
  3. Discovers all function.yaml files
  4. Builds Docker images for each function
  5. Deploys functions to the local Nuclio platform

Option 2: Deploy All GPU Functions

Deploy GPU-optimized versions (requires NVIDIA GPU and drivers):
This uses function-gpu.yaml files instead of standard function.yaml files.

Option 3: Deploy Individual Functions

Deploy specific functions manually:

Configuration

Function YAML Structure

Each function is defined by a function.yaml file:

Key Configuration Parameters

Metadata Annotations

  • name: Display name in CVAT UI
  • type: Function type (detector, interactor, tracker, reid)
  • spec: Label schema with supported output types
  • version: Function version for compatibility

Spec Settings

  • runtime: Python version for the function
  • handler: Entry point (typically main:handler)
  • eventTimeout: Maximum execution time per request
  • numWorkers: Number of concurrent workers
  • maxRequestBodySize: Maximum request payload size

Environment Variables

Configure CVAT connection when deploying:

Connecting to CVAT

Configure Nuclio Settings

In your CVAT deployment, configure Nuclio connection in docker-compose.yml:

Invoke Methods

Direct Invocation (default):
  • Calls functions directly via HTTP port
  • Lower latency, fewer network hops
  • Requires functions accessible from CVAT container
Dashboard Invocation:
  • Routes through Nuclio dashboard API
  • Better for complex networking scenarios
  • Slightly higher latency

Network Configuration

Ensure CVAT and Nuclio containers share a network:

Verification

List Deployed Functions

Expected output:

Test Function Invocation

Test a function directly:

Check CVAT Integration

  1. Open CVAT UI
  2. Create or open a task
  3. Navigate to annotation view
  4. Check “Tools” menu for available AI models
  5. Verify functions appear under “Magic” or “Automatic annotation”

Troubleshooting

Function Not Appearing in CVAT

Check Nuclio function status:
Verify CVAT environment variables:
Check CVAT logs:

Function Build Failures

Increase Docker memory:
  • Some models (especially Mask R-CNN) require 4GB+ RAM
  • Adjust Docker Desktop settings or system resources
Check base image:
Rebuild base image:

Function Timeout Issues

Increase timeout in function.yaml:
Update CVAT timeout:

Network Connection Errors

Verify network:
Check function accessibility:
Update invoke method:

Resource Management

Memory Requirements

Typical memory usage per function:
  • YOLO v7 (ONNX): ~500MB
  • Mask R-CNN (OpenVINO): ~2GB
  • SAM (PyTorch): ~2.5GB
  • Detectron2 models: ~1-3GB

GPU Support

For GPU acceleration:
  1. Install NVIDIA Container Toolkit:
  1. Deploy GPU functions:
  1. Verify GPU access:

Updating Functions

Update Existing Function

Update All Functions

Best Practices

  1. Start Small: Deploy only the functions you need initially
  2. Monitor Resources: Track memory and CPU usage during operation
  3. Use CPU for Batch: CPU functions work well for background annotation jobs
  4. Use GPU for Interactive: GPU accelerates real-time interactor tools
  5. Version Control: Track function.yaml changes for reproducibility
  6. Test Locally: Verify functions work before deploying to production
  7. Network Isolation: Use dedicated networks for security
  8. Regular Updates: Keep base images and dependencies updated

Next Steps

Custom Models

Create your own serverless functions

Overview

Learn more about serverless function types