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:- Builds the OpenVINO base image
- Creates a
cvatproject in Nuclio - Discovers all
function.yamlfiles - Builds Docker images for each function
- Deploys functions to the local Nuclio platform
Option 2: Deploy All GPU Functions
Deploy GPU-optimized versions (requires NVIDIA GPU and drivers):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 afunction.yaml file:
Key Configuration Parameters
Metadata Annotations
name: Display name in CVAT UItype: Function type (detector, interactor, tracker, reid)spec: Label schema with supported output typesversion: Function version for compatibility
Spec Settings
runtime: Python version for the functionhandler: Entry point (typicallymain:handler)eventTimeout: Maximum execution time per requestnumWorkers: Number of concurrent workersmaxRequestBodySize: Maximum request payload size
Environment Variables
Configure CVAT connection when deploying:Connecting to CVAT
Configure Nuclio Settings
In your CVAT deployment, configure Nuclio connection indocker-compose.yml:
Invoke Methods
Direct Invocation (default):- Calls functions directly via HTTP port
- Lower latency, fewer network hops
- Requires functions accessible from CVAT container
- 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
Test Function Invocation
Test a function directly:Check CVAT Integration
- Open CVAT UI
- Create or open a task
- Navigate to annotation view
- Check “Tools” menu for available AI models
- Verify functions appear under “Magic” or “Automatic annotation”
Troubleshooting
Function Not Appearing in CVAT
Check Nuclio function status:Function Build Failures
Increase Docker memory:- Some models (especially Mask R-CNN) require 4GB+ RAM
- Adjust Docker Desktop settings or system resources
Function Timeout Issues
Increase timeout in function.yaml:Network Connection Errors
Verify network: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:- Install NVIDIA Container Toolkit:
- Deploy GPU functions:
- Verify GPU access:
Updating Functions
Update Existing Function
Update All Functions
Best Practices
- Start Small: Deploy only the functions you need initially
- Monitor Resources: Track memory and CPU usage during operation
- Use CPU for Batch: CPU functions work well for background annotation jobs
- Use GPU for Interactive: GPU accelerates real-time interactor tools
- Version Control: Track function.yaml changes for reproducibility
- Test Locally: Verify functions work before deploying to production
- Network Isolation: Use dedicated networks for security
- Regular Updates: Keep base images and dependencies updated
Next Steps
Custom Models
Create your own serverless functions
Overview
Learn more about serverless function types