Prerequisites
1
Install Docker
Follow the official Docker installation guide for your platform.
2
Install NVIDIA Container Toolkit
Required for GPU access in containers:Verify installation:
Building the Docker Image
1
Clone the repository
2
Build the image
Build with default settings:Or customize build arguments:
3
Verify the build
Check that the image was created:Expected output:
Running the Container
Basic Server Deployment
Launch an API server with GPU access:The
--host 0.0.0.0 flag is required for the server to be accessible outside the container.Interactive Shell Mode
Run in interactive shell mode:Custom Port Mapping
Map to a different host port:http://localhost:8000
Using Volume Mounts
Persistent Cache Directories
Use Docker volumes to cache downloaded models and compiled kernels:Using Host Directories
Alternatively, mount specific host directories:Multi-GPU Deployment
All Available GPUs
Specific GPUs
Select specific GPU devices:Production Deployment
Docker Compose
Create adocker-compose.yml:
Health Checks
Add a health check to the Dockerfile or docker-compose.yml:Resource Limits
Set memory and CPU limits:Environment Variables
Pass environment variables to configure the container:Available Environment Variables
string
Comma-separated GPU indices to use
string
HuggingFace authentication token for gated models
boolean
Set to
1 to disable overlap schedulingTroubleshooting
GPU Not Detected
GPU Not Detected
Verify NVIDIA Container Toolkit is installed:If this fails, reinstall the NVIDIA Container Toolkit.
Permission Denied
Permission Denied
The container runs as a non-root user (UID 1001). Ensure mounted volumes have correct permissions:
Out of Memory
Out of Memory
Increase Docker’s memory limit:
Model Download Fails
Model Download Fails
- Check network connectivity
- Try using
--model-source modelscope - For gated models, provide
HF_TOKENenvironment variable
Windows (WSL2) Deployment
For Windows users with WSL2:1
Install WSL2 and Docker Desktop
- Install WSL2
- Install Docker Desktop with WSL2 backend
2
Build and run in WSL2
Open WSL2 terminal and follow the standard Linux instructions:
3
Access from Windows
The server will be accessible at
http://localhost:1919 from Windows browsers and applications.