Docker
En esta página
Docker#
Prerequisites#
- Docker must be installed and running on your system.
- Create a folder to store big models & intermediate files (ex. /llama/models)
Images#
We have three Docker images available for this project:
ghcr.io/ggml-org/llama.cpp:full: This image includes both thellama-cliandllama-completionexecutables and the tools to convert LLaMA models into ggml and convert into 4-bit quantization. (platforms:linux/amd64,linux/arm64,linux/s390x)ghcr.io/ggml-org/llama.cpp:light: This image only includes thellama-cliandllama-completionexecutables. (platforms:linux/amd64,linux/arm64,linux/s390x)ghcr.io/ggml-org/llama.cpp:server: This image only includes thellama-serverexecutable. (platforms:linux/amd64,linux/arm64,linux/s390x)
Additionally, there the following images, similar to the above:
ghcr.io/ggml-org/llama.cpp:full-cuda: Same asfullbut compiled with CUDA 12 support. (platforms:linux/amd64,linux/arm64)ghcr.io/ggml-org/llama.cpp:full-cuda13: Same asfullbut compiled with CUDA 13 support. (platforms:linux/amd64,linux/arm64)ghcr.io/ggml-org/llama.cpp:light-cuda: Same aslightbut compiled with CUDA 12 support. (platforms:linux/amd64,linux/arm64)ghcr.io/ggml-org/llama.cpp:light-cuda13: Same aslightbut compiled with CUDA 13 support. (platforms:linux/amd64,linux/arm64)ghcr.io/ggml-org/llama.cpp:server-cuda: Same asserverbut compiled with CUDA 12 support. (platforms:linux/amd64,linux/arm64)ghcr.io/ggml-org/llama.cpp:server-cuda13: Same asserverbut compiled with CUDA 13 support. (platforms:linux/amd64,linux/arm64)ghcr.io/ggml-org/llama.cpp:full-rocm: Same asfullbut compiled with ROCm support. (platforms:linux/amd64)ghcr.io/ggml-org/llama.cpp:light-rocm: Same aslightbut compiled with ROCm support. (platforms:linux/amd64)ghcr.io/ggml-org/llama.cpp:server-rocm: Same asserverbut compiled with ROCm support. (platforms:linux/amd64)ghcr.io/ggml-org/llama.cpp:full-musa: Same asfullbut compiled with MUSA support. (platforms:linux/amd64)ghcr.io/ggml-org/llama.cpp:light-musa: Same aslightbut compiled with MUSA support. (platforms:linux/amd64)ghcr.io/ggml-org/llama.cpp:server-musa: Same asserverbut compiled with MUSA support. (platforms:linux/amd64)ghcr.io/ggml-org/llama.cpp:full-intel: Same asfullbut compiled with SYCL support. (platforms:linux/amd64)ghcr.io/ggml-org/llama.cpp:light-intel: Same aslightbut compiled with SYCL support. (platforms:linux/amd64)ghcr.io/ggml-org/llama.cpp:server-intel: Same asserverbut compiled with SYCL support. (platforms:linux/amd64)ghcr.io/ggml-org/llama.cpp:full-vulkan: Same asfullbut compiled with Vulkan support. (platforms:linux/amd64,linux/arm64)ghcr.io/ggml-org/llama.cpp:light-vulkan: Same aslightbut compiled with Vulkan support. (platforms:linux/amd64,linux/arm64)ghcr.io/ggml-org/llama.cpp:server-vulkan: Same asserverbut compiled with Vulkan support. (platforms:linux/amd64,linux/arm64)ghcr.io/ggml-org/llama.cpp:full-openvino: Same asfullbut compiled with OpenVino support. (platforms:linux/amd64)ghcr.io/ggml-org/llama.cpp:light-openvino: Same aslightbut compiled with OpenVino support. (platforms:linux/amd64)ghcr.io/ggml-org/llama.cpp:server-openvino: Same asserverbut compiled with OpenVino support. (platforms:linux/amd64)ghcr.io/ggml-org/llama.cpp:full-s390x: Identical tofull, an alias for thes390xplatform. (platforms:linux/s390x)ghcr.io/ggml-org/llama.cpp:light-s390x: Identical tolight, an alias for thes390xplatform. (platforms:linux/s390x)ghcr.io/ggml-org/llama.cpp:server-s390x: Identical toserver, an alias for thes390xplatform. (platforms:linux/s390x)
The GPU enabled images are not currently tested by CI beyond being built. They are not built with any variation from the ones in the Dockerfiles defined in .devops/ and the GitHub Action defined in .github/workflows/docker.yml. If you need different settings (for example, a different CUDA, ROCm or MUSA library, you'll need to build the images locally for now).
Usage#
The easiest way to download the models, convert them to ggml and optimize them is with the --all-in-one command which includes the full docker image.
Replace /path/to/models below with the actual path where you downloaded the models.
docker run -v /path/to/models:/models ghcr.io/ggml-org/llama.cpp:full --all-in-one "/models/" 7B
On completion, you are ready to play!
docker run -v /path/to/models:/models ghcr.io/ggml-org/llama.cpp:full --run -m /models/7B/ggml-model-q4_0.gguf
docker run -v /path/to/models:/models ghcr.io/ggml-org/llama.cpp:full --run-legacy -m /models/32B/ggml-model-q8_0.gguf -no-cnv -p "Building a mobile app can be done in 15 steps:" -n 512
or with a light image:
docker run -v /path/to/models:/models --entrypoint /app/llama-cli ghcr.io/ggml-org/llama.cpp:light -m /models/7B/ggml-model-q4_0.gguf
docker run -v /path/to/models:/models --entrypoint /app/llama-completion ghcr.io/ggml-org/llama.cpp:light -m /models/32B/ggml-model-q8_0.gguf -no-cnv -p "Building a mobile app can be done in 15 steps:" -n 512
or with a server image:
docker run -v /path/to/models:/models -p 8080:8080 ghcr.io/ggml-org/llama.cpp:server -m /models/7B/ggml-model-q4_0.gguf --port 8080 --host 0.0.0.0 -n 512
In the above examples, --entrypoint /app/llama-cli is specified for clarity, but you can safely omit it since it's the default entrypoint in the container.
Docker With CUDA#
Assuming one has the nvidia-container-toolkit properly installed on Linux, or is using a GPU enabled cloud, cuBLAS should be accessible inside the container.
Building Docker locally#
docker build -t local/llama.cpp:full-cuda --target full -f .devops/cuda.Dockerfile .
docker build -t local/llama.cpp:light-cuda --target light -f .devops/cuda.Dockerfile .
docker build -t local/llama.cpp:server-cuda --target server -f .devops/cuda.Dockerfile .
You may want to pass in some different ARGS, depending on the CUDA environment supported by your container host, as well as the GPU architecture.
The defaults are:
CUDA_VERSIONset to12.8.1CUDA_DOCKER_ARCHset to the cmake build default, which includes all the supported architectures
The resulting images, are essentially the same as the non-CUDA images:
local/llama.cpp:full-cuda: This image includes both thellama-cliandllama-completionexecutables and the tools to convert LLaMA models into ggml and convert into 4-bit quantization.local/llama.cpp:light-cuda: This image only includes thellama-cliandllama-completionexecutables.local/llama.cpp:server-cuda: This image only includes thellama-serverexecutable.
Usage#
After building locally, Usage is similar to the non-CUDA examples, but you'll need to add the --gpus flag. You will also want to use the --n-gpu-layers flag.
docker run --gpus all -v /path/to/models:/models local/llama.cpp:full-cuda --run -m /models/7B/ggml-model-q4_0.gguf -p "Building a website can be done in 10 simple steps:" -n 512 --n-gpu-layers 1
docker run --gpus all -v /path/to/models:/models local/llama.cpp:light-cuda -m /models/7B/ggml-model-q4_0.gguf -p "Building a website can be done in 10 simple steps:" -n 512 --n-gpu-layers 1
docker run --gpus all -v /path/to/models:/models local/llama.cpp:server-cuda -m /models/7B/ggml-model-q4_0.gguf --port 8080 --host 0.0.0.0 -n 512 --n-gpu-layers 1
Docker With MUSA#
Assuming one has the mt-container-toolkit properly installed on Linux, muBLAS should be accessible inside the container.
Building Docker locally#
docker build -t local/llama.cpp:full-musa --target full -f .devops/musa.Dockerfile .
docker build -t local/llama.cpp:light-musa --target light -f .devops/musa.Dockerfile .
docker build -t local/llama.cpp:server-musa --target server -f .devops/musa.Dockerfile .
You may want to pass in some different ARGS, depending on the MUSA environment supported by your container host, as well as the GPU architecture.
The defaults are:
MUSA_VERSIONset torc4.3.0
The resulting images, are essentially the same as the non-MUSA images:
local/llama.cpp:full-musa: This image includes both thellama-cliandllama-completionexecutables and the tools to convert LLaMA models into ggml and convert into 4-bit quantization.local/llama.cpp:light-musa: This image only includes thellama-cliandllama-completionexecutables.local/llama.cpp:server-musa: This image only includes thellama-serverexecutable.
Usage#
After building locally, Usage is similar to the non-MUSA examples, but you'll need to set mthreads as default Docker runtime. This can be done by executing (cd /usr/bin/musa && sudo ./docker setup $PWD) and verifying the changes by executing docker info | grep mthreads on the host machine. You will also want to use the --n-gpu-layers flag.
docker run -v /path/to/models:/models local/llama.cpp:full-musa --run -m /models/7B/ggml-model-q4_0.gguf -p "Building a website can be done in 10 simple steps:" -n 512 --n-gpu-layers 1
docker run -v /path/to/models:/models local/llama.cpp:light-musa -m /models/7B/ggml-model-q4_0.gguf -p "Building a website can be done in 10 simple steps:" -n 512 --n-gpu-layers 1
docker run -v /path/to/models:/models local/llama.cpp:server-musa -m /models/7B/ggml-model-q4_0.gguf --port 8080 --host 0.0.0.0 -n 512 --n-gpu-layers 1
Docker With SYCL#
Building Docker locally#
docker build -t local/llama.cpp:full-intel --target full -f .devops/intel.Dockerfile .
docker build -t local/llama.cpp:light-intel --target light -f .devops/intel.Dockerfile .
docker build -t local/llama.cpp:server-intel --target server -f .devops/intel.Dockerfile .
You may want to pass in some different ARGS, depending on the SYCL environment supported by your container host, as well as the GPU architecture.
Refer to .devops/intel.Dockerfile for the available ARGS and their defaults.
The resulting images, are essentially the same as the non-SYCL images:
local/llama.cpp:full-intel: This image includes both thellama-cliandllama-completionexecutables and the tools to convert LLaMA models into ggml and convert into 4-bit quantization.local/llama.cpp:light-intel: This image only includes thellama-cliandllama-completionexecutables.local/llama.cpp:server-intel: This image only includes thellama-serverexecutable.
Usage#
After building locally, usage is similar to the non-SYCL examples, but you'll need to add the --device flag.
# First, find all the DRI cards
ls -la /dev/dri
# Then, pick the card that you want to use (here for e.g. /dev/dri/card0).
docker run --device /dev/dri/renderD128:/dev/dri/renderD128 --device /dev/dri/card0:/dev/dri/card0 -v /path/to/models:/models local/llama.cpp:full-intel -m /models/7B/ggml-model-q4_0.gguf -p "Building a website can be done in 10 simple steps:" -n 512 --n-gpu-layers 99
docker run --device /dev/dri/renderD128:/dev/dri/renderD128 --device /dev/dri/card0:/dev/dri/card0 -v /path/to/models:/models local/llama.cpp:light-intel -m /models/7B/ggml-model-q4_0.gguf -p "Building a website can be done in 10 simple steps:" -n 512 --n-gpu-layers 99
docker run --device /dev/dri/renderD128:/dev/dri/renderD128 --device /dev/dri/card0:/dev/dri/card0 -v /path/to/models:/models local/llama.cpp:server-intel -m /models/7B/ggml-model-q4_0.gguf --port 8080 --host 0.0.0.0 -n 512 --n-gpu-layers 99
Notes: - Docker has been tested successfully on native Linux. WSL support has not been verified yet. - You may need to install Intel GPU driver on the host machine (Please refer to the Linux configuration for details).