RUNLOCALAIv38
->Will it run?Best GPUCompareTroubleshootStartLearnPulseModelsHardwareToolsBench
Run check
RUNLOCALAI

Independently operated catalog for local-AI hardware and software. Hand-written verdicts. Source-cited claims. Reproducible commands when we have them.

OP·Fredoline Eruo
DIR
  • Models
  • Hardware
  • Tools
  • Benchmarks
TOOLS
  • Will it run?
  • Compare hardware
  • Cost vs cloud
  • Choose my GPU
  • Prompting kits
  • Quick answers
REF
  • All buyer guides
  • Learn local AI
  • Methodology
  • Glossary
  • Errors KB
  • Trust
EDITOR
  • About
  • Author
  • How we make money
  • Editorial policy
  • Contact
LEGAL
  • Privacy
  • Terms
  • Sitemap
MAIL · MONTHLY DIGEST
Get monthly local AI changes
Monthly recap. No spam.
DISCLOSURE

Some links on this site are affiliate links (Amazon Associates and other first-class retailers). When you buy through them, we earn a small commission at no extra cost to you. Affiliate links do not influence our verdicts — there are cards we rate highly that we don't have affiliate relationships with, and cards that sell well that we refuse to recommend. Read more →

© 2026 runlocalai.coIndependently operated
RUNLOCALAI · v38
  1. >
  2. Home
  3. /Learn
  4. /How-to
  5. /How to mount GPU in Docker container
HOW-TO · SET

How to mount GPU in Docker container

intermediate·10 min·By Fredoline Eruo
Target environment
Ubuntu 24.04 · Ollama 0.4.xWindows 11 · Ollama 0.4.xmacOS 15 · Ollama 0.4.x
PREREQUISITES

Docker installed, NVIDIA Container Toolkit or AMD ROCm

What this does

Enables a Docker container to access the host GPU so AI workloads run on dedicated hardware rather than the CPU. After this guide the container will render nvidia-smi output or AMD equivalent inside the container.

Steps

  1. Install the container toolkit on the host. GPU passthrough requires the host runtime to inject GPU access into containers.

    distribution=$(. /etc/os-release;echo $ID$VERSION_ID)
    curl -fsSL https://nvidia.github.io/nvidia-docker/gpgkey | sudo gpg --dearmor -o /usr/share/keyrings/nvidia-container-toolkit-keyring.gpg
    curl -s -L https://nvidia.github.io/nvidia-docker/$distribution/nvidia-docker.list | sed 's#deb https://#deb [signed-by=/usr/share/keyrings/nvidia-container-toolkit-keyring.gpg] https://#g' | sudo tee /etc/apt/sources.list.d/nvidia-docker.list
    sudo apt-get update && sudo apt-get install -y nvidia-container-toolkit
    sudo nvidia-ctk runtime configure --runtime=docker
    sudo systemctl restart docker
    

    Expected output: nvidia-container-toolkit writes updated daemon JSON config.

  2. Launch the container with the GPU flag. The --gpus flag routes GPU access into the container environment.

    docker run --gpus all -it --rm nvidia/cuda:12.6.3-base-ubuntu24.04 nvidia-smi
    

    Expected output: Table showing GPU model, driver version, memory usage.

  3. Verify AMD GPU passthrough on supported hosts. ROCm uses different runtime flags.

    docker run --device=/dev/kfd --device=/dev/dri -it --rm rocm/rockml:latest rocm-smi
    

    Expected output: ROCm SMI table displaying GPU card and VRAM.

  • Record the local run evidence. Save the exact command, runtime or package version, model name if applicable, and observed output so the result can be reproduced later.

Verification

docker run --gpus all --rm ubuntu:24.04 nvidia-smi
# Expected: full GPU table with driver version, CUDA version, and GPU index

Common failures

  • Unknown runtime specified "nvidia" — nvidia-container-toolkit was not installed or Docker daemon was not restarted. Re-run installation steps and sudo systemctl restart docker.
  • NVIDIA-SMI has failed because it couldn't communicate with the NVIDIA driver — GPU drivers are not loaded on the host. Run nvidia-smi outside the container first.
  • Permission denied for /dev/dri — User is not in the docker group. Run sudo usermod -aG docker $USER and log back in.
  • GPU not visible inside container despite no error — GPU compute mode may be off. Run sudo nvidia-smi -pm ENABLED on the host before launching.
  • Container runs but GPU reports 0% utilization — The workload may be CPU-bound or the model is too small. Check nvidia-smi pmon for process activity.

Related guides

  • How to build custom Docker image for AI models
  • How to persist Ollama data in Docker
  • Course Local AI Fundamentals
RELATED GUIDES
SET
How to build custom Docker image for AI models
SET
How to persist Ollama data in Docker
← All how-to guidesCourses →