Menu

1 / 2

GPU-Aware Autoscaling for Docker Containers: From NVML to Production

DEV Community·Pavan Madduri·6 months ago
#pGt5OsF4
#docker#gpu#nvml#nvidia#scaler
Reading 0:00
15s threshold

Every GPU inference container has the same problem: Kubernetes HPA can't see the GPU. You scale on CPU and memory while your GPU sits at 95% utilization, completely invisible to the autoscaler. Or worse — your GPU is idle and you're paying $3/hour for an instance doing nothing.

I built keda-gpu-scaler to fix this. It's a KEDA external scaler that reads real GPU metrics via NVIDIA NVML and drives Kubernetes autoscaling decisions — including scale-to-zero. This post covers the Docker-specific parts: how GPU metrics flow from the NVIDIA Container Toolkit through Docker to KEDA, and how to build GPU-aware containers that actually scale.

How Docker Exposes GPUs to Containers

When you run a GPU container with Docker, three layers work together:

docker run --gpus all nvidia/cuda:12.4-base nvidia-smi

Enter fullscreen mode

Exit fullscreen mode

Docker Engine detects the --gpus flag and calls the NVIDIA Container Toolkit

The toolkit configures nvidia-container-runtime as the OCI runtime for this container

The…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.