GPUs are the most expensive resource most Kubernetes clusters will ever run, and they are easy to waste. A GPU node left running overnight with nothing scheduled, a model server holding a whole GPU at five percent utilisation, or a training job that restarts from scratch after a Spot interruption can quietly double an ML budget. This guide covers how to run GPU workloads on Amazon EKS so capacity appears when work arrives, is shared where it can be, and disappears when it is not needed.
Where GPU money is usually wasted
- GPU nodes in static node groups that stay up whether or not anything is scheduled.
- Small inference models each holding an entire GPU because nothing is configured for sharing.
- Non-GPU pods landing on GPU nodes and keeping them alive because the nodes are not tainted.
- Training on On-Demand capacity when it could run on Spot with checkpointing.
- Oversized instance types chosen for convenience instead of the model's actual memory needs.
- Large container images that make every scale-up slow, so teams keep nodes warm “just in case”.
1. Provision GPU nodes only on demand with Karpenter
A dedicated Karpenter NodePool for GPUs lets nodes appear when a pod requests nvidia.com/gpu and disappear when they are empty. The taint keeps ordinary pods off expensive nodes, and the GPU limit acts as a hard cost ceiling for the pool.
apiVersion: karpenter.sh/v1
kind: NodePool
metadata:
name: gpu
spec:
template:
spec:
requirements:
- key: karpenter.k8s.aws/instance-family
operator: In
values: ["g5", "g6"]
- key: karpenter.sh/capacity-type
operator: In
values: ["on-demand", "spot"]
taints:
- key: nvidia.com/gpu
value: "true"
effect: NoSchedule
nodeClassRef:
group: karpenter.k8s.aws
kind: EC2NodeClass
name: gpu
limits:
nvidia.com/gpu: "16" # hard ceiling for the whole pool
disruption:
consolidationPolicy: WhenEmpty
consolidateAfter: 10m
---
apiVersion: karpenter.k8s.aws/v1
kind: EC2NodeClass
metadata:
name: gpu
spec:
role: KarpenterNodeRole-prod-eks
amiSelectorTerms:
- alias: al2023@latest # resolves to the NVIDIA variant on GPU instances
blockDeviceMappings:
- deviceName: /dev/xvda
ebs:
volumeSize: 200Gi # CUDA images and model weights are large
volumeType: gp3
subnetSelectorTerms:
- tags:
karpenter.sh/discovery: prod-eks
securityGroupSelectorTerms:
- tags:
karpenter.sh/discovery: prod-eksWhenEmpty consolidation is deliberate for GPU pools: moving a running model or training job to repack nodes is usually more disruptive than it is worth, so only empty nodes are removed. Keep a separate pool—or a capacity-type requirement—for workloads that must never run on Spot.
2. Expose GPUs to Kubernetes
The NVIDIA device plugin advertises GPUs to the kubelet as the nvidia.com/gpu resource. EKS-optimised accelerated AMIs and Bottlerocket NVIDIA variants ship with the driver; the NVIDIA GPU Operator is the alternative when you need to manage drivers, the container toolkit, and monitoring components yourself. Pods then request GPUs like any other resource and tolerate the taint.
spec:
template:
spec:
tolerations:
- key: nvidia.com/gpu
operator: Exists
effect: NoSchedule
containers:
- name: model-server
image: 111122223333.dkr.ecr.ap-south-1.amazonaws.com/model-server@sha256:<digest>
resources:
requests:
cpu: "4"
memory: 16Gi
nvidia.com/gpu: 1
limits:
memory: 16Gi
nvidia.com/gpu: 1How does your cloud measure up?
Score your setup across foundation, delivery, reliability, security, and cost in 3 minutes—instant results, no email needed.
3. Share GPUs when one workload cannot fill them
Many inference services, notebooks, and development workloads use a fraction of a modern GPU. Two sharing options exist. Time-slicing lets several pods take turns on one GPU; it is simple and works on any NVIDIA GPU, but there is no memory or fault isolation between pods. Multi-Instance GPU (MIG) partitions supported data-centre GPUs such as A100 and H100 into isolated slices with dedicated memory—better isolation, but only on those instance families.
apiVersion: v1
kind: ConfigMap
metadata:
name: nvidia-device-plugin-config
namespace: kube-system
data:
config.yaml: |
version: v1
sharing:
timeSlicing:
resources:
- name: nvidia.com/gpu
replicas: 4 # each physical GPU appears as 4 schedulable GPUs4. Separate inference from training
Inference and training have opposite needs. Inference is long-running and latency-sensitive, so it belongs on On-Demand capacity with enough replicas to survive a node loss, scaled on request rate or queue depth. Training is batch work that can tolerate interruption if it checkpoints, which makes it a natural fit for Spot GPUs at a large discount.
For training on Spot, checkpoint to S3 at regular intervals and make the job resume from the latest checkpoint on start-up. Karpenter handles the two-minute interruption notice by cordoning and draining the node; the job's restart policy brings it back on new capacity. Choose the checkpoint interval by asking how much recomputation you can afford to lose.
apiVersion: batch/v1
kind: Job
metadata:
name: finetune-run-42
spec:
backoffLimit: 10 # survive several Spot interruptions
template:
spec:
restartPolicy: OnFailure
nodeSelector:
karpenter.sh/capacity-type: spot
tolerations:
- key: nvidia.com/gpu
operator: Exists
containers:
- name: train
image: 111122223333.dkr.ecr.ap-south-1.amazonaws.com/trainer@sha256:<digest>
args: ["--resume-from", "s3://ml-checkpoints/finetune-run-42/latest"]
resources:
limits:
nvidia.com/gpu: 15. Scale inference to demand—and to zero
CPU-based autoscaling is a poor signal for GPU services. Scale on what users feel: queue depth for asynchronous jobs, or requests in flight and latency for synchronous APIs. KEDA can scale a Deployment from zero based on an SQS queue or Prometheus query, and Karpenter then removes the empty GPU node. For internal or batch inference, scaling to zero outside working hours is often the single biggest saving.
apiVersion: keda.sh/v1alpha1
kind: ScaledObject
metadata:
name: batch-inference
namespace: ml
spec:
scaleTargetRef:
name: batch-inference
minReplicaCount: 0
maxReplicaCount: 8
cooldownPeriod: 600
triggers:
- type: aws-sqs-queue
authenticationRef:
name: keda-aws # TriggerAuthentication using Pod Identity
metadata:
queueURL: https://sqs.ap-south-1.amazonaws.com/111122223333/inference-requests
queueLength: "20"
awsRegion: ap-south-16. Measure GPU utilisation, not just allocation
Kubernetes only knows that a GPU is allocated, not whether it is busy. NVIDIA's DCGM exporter publishes per-GPU utilisation, memory, temperature, and power metrics to Prometheus. Alert on GPUs that are allocated but idle—that is money burning with nothing to show for it.
groups:
- name: gpu-cost
rules:
- alert: GpuAllocatedButIdle
expr: avg_over_time(DCGM_FI_DEV_GPU_UTIL[1h]) < 10
for: 30m
labels:
severity: warning
annotations:
summary: "GPU on {{ $labels.Hostname }} under 10% utilisation for an hour"7. Cut cold-start time so nobody keeps nodes warm
- Keep model weights out of the container image and load them from S3 or a shared volume, so images stay smaller.
- Use multi-stage builds and slim CUDA runtime base images rather than full development images.
- Store images in ECR in the same region as the cluster, and use VPC endpoints for ECR and S3.
- For latency-critical services, keep a minimum of one replica during business hours instead of the whole fleet warm all day.
8. Governance: quotas and visibility
Give each team or project a namespace with a ResourceQuota on nvidia.com/gpu so one experiment cannot claim the whole pool. Add per-namespace cost reporting with Kubecost or OpenCost so GPU spend is visible to the people who create it.
apiVersion: v1
kind: ResourceQuota
metadata:
name: gpu-quota
namespace: team-recsys
spec:
hard:
requests.nvidia.com/gpu: "4"GPU cost-control checklist
- Dedicated, tainted Karpenter GPU NodePool with a GPU limit and empty-node consolidation.
- Inference on On-Demand with replicas across zones; training on Spot with S3 checkpoints.
- GPU sharing (time-slicing or MIG) for small models and development workloads.
- KEDA scaling on queue depth or latency, with scale-to-zero where acceptable.
- DCGM exporter metrics and an alert for allocated-but-idle GPUs.
- Per-namespace GPU quotas and cost reporting.
- Lean images with model weights loaded separately to keep scale-up fast.
GPU platforms reward discipline more than cleverness. With capacity that follows demand and utilisation you can actually see, teams get the GPUs they need without the budget surprises. This is the approach we use when building ML platforms on our Production Kubernetes Base and Cloud Cost Sprint modules.
Key takeaways
- Separate training and inference pools; set quotas and cool-downs that match jobs.
- Treat GPU utilization and idle allocation as FinOps SLIs.
- Use spot/preemptible where checkpoints make interruption safe.
FAQ
How do we stop idle GPU burn?
Autoscaling with appropriate cool-downs, idle detection, and team quotas. Always-on GPU nodes without owners are the usual culprit.
Should training share inference nodes?
Usually no. Noisy training jobs wreck latency SLOs. Isolate pools and schedule deliberately.