Docker Deployment
Docker provides an easy way to run llama.cpp without building from source, with support for CPU and various GPU backends.Prerequisites
- Docker must be installed and running on your system
- Create a folder to store models and intermediate files (e.g.,
/llama/models)
Available Images
llama.cpp provides pre-built Docker images in three variants:Full
Complete toolset including CLI, conversion tools, and quantization
Light
Only
llama-cli and llama-completion executablesServer
Only
llama-server for API deploymentCPU Images
linux/amd64, linux/arm64, linux/s390x
GPU Images
- CUDA (NVIDIA)
- ROCm (AMD)
- SYCL (Intel)
- Vulkan
- MUSA (Moore Threads)
linux/amd64GPU-enabled images are not currently tested by CI beyond being built. If you need different settings (e.g., different CUDA version), you’ll need to build locally.
Quick Start
Run CLI Interactive
Run Server
http://localhost:8080
All-in-One Conversion
Thefull image includes model conversion tools:
GPU Acceleration
NVIDIA GPU (CUDA)
Requires nvidia-container-toolkit installed.AMD GPU (ROCm)
Docker Compose
Create adocker-compose.yml file:
docker-compose.yml
Building Locally
Build CPU Image
Build CUDA Image
Build Arguments
Build Arguments
CUDA_VERSION: CUDA version to use (default:
12.4.0)CUDA_DOCKER_ARCH: Target GPU architectures (default: all)Specify specific architectures for smaller images:ROCm Build
ROCm Build
Vulkan Build
Vulkan Build
Production Deployment
Health Check
Add health checks to your Docker configuration:Resource Limits
Environment Variables
Kubernetes Deployment
Example Kubernetes Deployment
Example Kubernetes Deployment
k8s-deployment.yaml
Troubleshooting
GPU not detected in container
GPU not detected in container
- Ensure nvidia-container-toolkit is installed and configured
- Check
nvidia-smiworks inside container: - Verify
--gpus allflag is set
Out of memory errors
Out of memory errors
- Reduce context size:
-c 2048 - Reduce GPU layers:
--n-gpu-layers 16 - Use smaller quantization: Q4_K_M instead of Q8_0
- Increase Docker memory limits
Permission denied errors
Permission denied errors
- Check volume mount paths exist and are readable
- Run with user permissions:
Next Steps
Server Configuration
Learn about server options and configuration
REST API
Use the OpenAI-compatible API

