Skip to main content

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 executables

Server

Only llama-server for API deployment

CPU Images

Platforms: linux/amd64, linux/arm64, linux/s390x

GPU Images

Platform: linux/amd64
GPU-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

Access the API at http://localhost:8080

All-in-One Conversion

The full image includes model conversion tools:

GPU Acceleration

NVIDIA GPU (CUDA)

Requires nvidia-container-toolkit installed.

AMD GPU (ROCm)

Docker Compose

Create a docker-compose.yml file:
docker-compose.yml
Run with:

Building Locally

Build CPU Image

Build CUDA Image

CUDA_VERSION: CUDA version to use (default: 12.4.0)CUDA_DOCKER_ARCH: Target GPU architectures (default: all)Specify specific architectures for smaller images:

Production Deployment

Health Check

Add health checks to your Docker configuration:

Resource Limits

Environment Variables

Kubernetes Deployment

k8s-deployment.yaml

Troubleshooting

  • Ensure nvidia-container-toolkit is installed and configured
  • Check nvidia-smi works inside container:
  • Verify --gpus all flag is set
  • 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
  • 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