Skip to content

How-ToGPU

How to Run Ollama in Docker With NVIDIA or AMD GPU Support

How to run Ollama in Docker on Linux using Ollama's official commands: CPU only, NVIDIA GPUs via the NVIDIA Container Toolkit, AMD GPUs with the ROCm image, Vulkan, then running a model and connecting other apps.

By , Systems & Technical Editor

3 min read

How to Run Ollama in Docker With NVIDIA or AMD GPU Support

Running Ollama in Docker keeps it in its own container, alongside other containers such as a chat front end. This guide follows Ollama's official Docker documentation.

If you'd rather install Ollama directly, see how to install Ollama on Linux. To check your graphics card is supported before you start, see how to check your GPU works with Ollama.

What you need

  • A Linux PC (or a Linux server) with Docker installed

  • For GPU acceleration: a supported NVIDIA or AMD graphics card and its driver

  • Enough disk space for models, which are stored in a Docker volume

Ollama's Docker guide gives Linux commands. On Windows, for running Linux AI tools with GPU access, see how to set up WSL2 for GPU local AI.

Option 1: CPU only

The simplest command starts Ollama without GPU access:

docker run -d -v ollama:/root/.ollama -p 11434:11434 --name ollama ollama/ollama

Here -v ollama:/root/.ollama mounts a Docker volume called ollama at /root/.ollama inside the container, and -p 11434:11434 publishes Ollama's API port.

Option 2: NVIDIA GPU

Ollama says you first need the NVIDIA Container Toolkit. On Debian or Ubuntu-based systems, Ollama's guide configures NVIDIA's repository, then installs the package:

sudo apt-get update
sudo apt-get install -y nvidia-container-toolkit

Ollama also gives Yum/Dnf steps for other distributions. Next, configure Docker to use the NVIDIA runtime and restart Docker:

sudo nvidia-ctk runtime configure --runtime=docker
sudo systemctl restart docker

Then start the container with all GPUs:

docker run -d --gpus=all -v ollama:/root/.ollama -p 11434:11434 --name ollama ollama/ollama

Ollama notes that on NVIDIA JetPack systems, it can't detect the JetPack version automatically, so you pass JETSON_JETPACK=5 or JETSON_JETPACK=6 to the container.

Option 3: AMD GPU (ROCm)

For AMD graphics cards, Ollama's guide uses the rocm image tag and passes the GPU devices into the container:

docker run -d --device /dev/kfd --device /dev/dri -v ollama:/root/.ollama -p 11434:11434 --name ollama ollama/ollama:rocm

Option 4: Vulkan

Ollama says Vulkan is bundled into the standard ollama/ollama image and enabled by default when the container can access the GPU devices:

docker run -d --device /dev/kfd --device /dev/dri -v ollama:/root/.ollama -p 11434:11434 --name ollama ollama/ollama

Use OLLAMA_VULKAN=0 to turn Vulkan off, or GGML_VK_VISIBLE_DEVICES to choose specific Vulkan devices. For how the different back ends compare, see CUDA vs ROCm vs Vulkan for local AI.

Step 5: Run a model

With the container running, use docker exec to run Ollama's own command inside it. Ollama's example is:

docker exec -it ollama ollama run llama3.2

The first run downloads the model into the volume. More models are listed in the Ollama library. To check whether the model is actually using your graphics card, see how to check Ollama is using your GPU.

Using the API and other apps

Because port 11434 is published, apps on the same PC can reach Ollama at http://localhost:11434, just as with a native install. That includes front ends such as Open WebUI; see how to install Open WebUI with Ollama, and for code, how to use Ollama's OpenAI-compatible API. If you want other devices on your network to use it, see how to share Ollama on your local network, and think about security before exposing the port.

Updating

Ollama's Docker page doesn't cover updates. With standard Docker commands, you can pull the latest image, then stop and remove the container and recreate it with the same docker run command, which mounts the same ollama volume:

docker pull ollama/ollama
docker stop ollama
docker rm ollama

Our verdict

Docker is a tidy way to run Ollama on Linux: one command for CPU, the NVIDIA Container Toolkit plus --gpus=all for NVIDIA cards, and the rocm image for AMD. Use the named volume from Ollama's commands, and check the GPU is being used before you blame the container for slow answers.

The bottom line

Docker is a tidy way to run Ollama on Linux: one command for CPU, the NVIDIA Container Toolkit plus `--gpus=all` for NVIDIA cards, and the `rocm` image for AMD. Use the named volume from Ollama's commands, and check the GPU is being used before you blame the container for slow answers.

Sources

  1. 01Ollama: Docker

About the author

Marcus Thorne

Systems & Technical Editor

Marcus writes Forge PC's step-by-step build, troubleshooting and system optimisation guides. His background spans Windows kernel and power-state diagnostics, UEFI/BIOS configuration, NVMe storage arrays, ATX 3.1 power delivery and running local AI and LLM workloads on consumer graphics cards.

More from Marcus Thorne

Read next

How to Run LM Studio Headless With llmster (No GUI Needed)

How-To

How to Run LM Studio Headless With llmster (No GUI Needed)

How to run LM Studio as a background service without its window: install the llmster daemon, start it with lms daemon up, load models and start the server, or run the desktop app's server on login, plus JIT loading.

Marcus Thorne3 min

How to Use Text-to-Speech in Ollama With the Phonon Model

How-To

How to Use Text-to-Speech in Ollama With the Phonon Model

How to use Ollama's text-to-speech feature with the Phonon model: update to v0.40.9 or later, pick a voice, read a chat model's answers aloud, save WAV files and call the OpenAI-compatible speech API.

Marcus Thorne3 min

How to Update the Intel NPU Driver on a Core Ultra PC

How-To

How to Update the Intel NPU Driver on a Core Ultra PC

How to update the Intel NPU (AI Boost) driver on a Core Ultra PC: which processors and Windows 11 versions Intel supports, how to check your version, installing 32.0.100.5600 and rolling back if an AI app misbehaves.

Marcus Thorne2 min