Deployed Lab

Module 3 · GPUs and Kubernetes for AI · Chapter 10 · Free

Scheduling and sharing GPUs: MIG, time-slicing and quotas

17 min1 clickable picture1 hands-on lab1 predict, 2 quick quizzes, 5-question final quiz5-min video review
In 30 seconds

The picture: a GPU is a workshop. Wall off rooms, take turns on the bench, or hand over the building.

What this chapter gives you
The cold open

Copperline is a made up B2B SaaS company. Its data science team and its support copilot share one GPU cluster informally: no quotas, no rules, just goodwill.

Priya Nair, the staff platform engineer, decides sharing needs mechanism, not manners.

The plan for this chapter
  1. Why whole GPU allocation wastes small workloads.
  2. MIG: hardware partitions with real isolation.
  3. Time-slicing and MPS: turns and shared contexts.
  4. Choosing per workload: isolation versus utilisation.
  5. Quotas, priority and preemption in Kubernetes.
  6. A worked 80 GB plan, then the matching lab.

Next: why one workload per GPU is so expensive.

Step 1: A whole GPU per small workload wastes the card

Kubernetes treats a GPU as indivisible. A pod requests one GPU and gets the entire card, however little it uses.

Think of renting a whole warehouse for one bicycle. Where the picture breaks down:

Next: the strongest split, partitions cut in hardware.

Step 2: MIG, hardware partitions with real isolation

MIG, Multi-Instance GPU, is a well known feature on supported NVIDIA cards. It partitions one GPU into separate instances, each with dedicated memory and compute.

In Kubernetes, the device plugin advertises each partition as its own resource, so a pod requests a partition the way it once requested a card.

Next: the looser mechanisms: turns and a shared context.

Step 3: Time-slicing and MPS, sharing without walls

Time-slicing lets several pods share one GPU by taking turns. The device plugin advertises the same GPU several times over, using a replica count an operator sets in its config.

MPS, the Multi-Process Service, sits between the two. Several processes share one GPU context at once, rather than taking turns.

Think of a kitchen. MIG is separate flats. Time-slicing is one kitchen used in turns. MPS is one kitchen, several cooks at once. Where the picture breaks down:

Next: the four options side by side.

Step 4: Choose by workload

One line: isolation buys predictable latency and safe tenants, and costs utilisation. Utilisation buys density, and costs the noisy neighbour page.

Predict first:

Time-slicing shares one memory pool with no isolation. The notebook's growth leaves too little for the copilot, whose requests then fail. Kubernetes does not preempt a running pod just because GPU memory ran out.

Next: the cluster level controls above any single card.

Step 5: Quotas, priority and preemption

Sharing decides what happens on one card. Quotas decide who may claim cards.

# Illustrative: cap a namespace and rank serving above batch
apiVersion: v1
kind: ResourceQuota
metadata:
  name: gpu-quota
  namespace: data-science
spec:
  hard:
    requests.nvidia.com/gpu: "2"
---
apiVersion: scheduling.k8s.io/v1
kind: PriorityClass
metadata:
  name: serving-high
value: 100000
preemptionPolicy: PreemptLowerPriority

Priya caps data science at two GPUs, gives the copilot the high priority class, and training the low one. The 2 p.m. run now queues or yields.

Next: the picture, one card shared three ways.

Step 6: The picture, one GPU shared three ways

Press Next to walk a GPU request through the scheduler.

One GPU shared three ways A scheduler checks quota, then places pods onto a MIG partition, a time-sliced share, or a whole GPU, with priority deciding who yields. Podrequests GPU Schedulerquota, priority MIG partitionisolated slice Time-slicedshared turns Whole GPUall of one card
  1. A pod requests a GPU resource: a whole card, a MIG partition, or a shared slot.
  2. The quota caps the team's claims. Priority decides who wins when the cluster is full.
  3. The copilot lands on a MIG partition: hardware isolation, steady latency.
  4. Notebooks share a card in turns. Density is high, with no memory walls between them.
  5. The fine-tune takes a whole card at low priority, and yields by preemption when serving needs room.

Next: one card, three workloads, two plans, arithmetic shown.

Step 7: Worked example, one 80 GB card, three workloads

All figures here are illustrative. One 80 GB card, like an H100 SXM, hosts three workloads: the copilot (24 GB), an embeddings batch job (9 GB), and a dev notebook (7 GB). Total real use: 24 + 9 + 7 = 40 GB.

1. Whole GPU each. Three workloads claim three cards: 3 × 80 = 240 GB claimed for 40 GB used.

2. The MIG plan. Partition the card into slices of 40, 20 and 20 GB: 40 + 20 + 20 = 80 GB. The copilot takes the 40 GB slice, stranding 40 - 24 = 16 GB. Embeddings strand 20 - 9 = 11 GB. The notebook strands 20 - 7 = 13 GB. Total stranded: 16 + 11 + 13 = 40 GB, but every workload is hardware isolated.

3. The time-slicing plan. All three share one pool: 40 GB used, 80 - 40 = 40 GB free for bursts. Nothing is stranded.

4. The risk difference. Under time-slicing, if the notebook grows by 45 GB, it wants 7 + 45 = 52 GB, leaving 80 - 52 - 24 - 9 = -5 GB: someone fails. Under MIG, the notebook hits its own 20 GB wall and fails alone.

5. Priya's call. The copilot goes on MIG. The notebook and embeddings time-slice a second card, where a failure is a retry, not an incident.

Same workloads. The plans differ in where the waste sits and who feels a failure.

Next: the lab: you make the call for six workloads.

Step 8: Hands-on lab, match the workload to the mechanism

Why: teams get asked "can we just share a GPU?" weekly. The answer depends on isolation, trust and failure cost.

Lab: Copperline's three workloads share one GPU cluster on goodwill, and the cold open shows how that ends at 2 p.m. This lab runs in your browser and needs JavaScript enabled.

What to notice

Next: a field note, then the mix-ups.

Field note, November 2026

In production practice, GPU sharing is often adopted in stages: whole cards first, then time-slicing for dev, then MIG where isolation justifies fixed partitions. Treat that as a pattern, not a rule. The step teams most regret skipping is the quota: an uncapped cluster is claimed by whoever submits first.

Mix-ups to avoid

Chapter quiz

Five questions. Score 70% to pass.

Review this chapter in 5 minutes

Watch the whole chapter recapped: MIG hardware partitions, time-slicing and MPS, quotas and priority, and a worked 80 GB sharing plan.

Decision rule: if a workload is untrusted or latency sensitive, isolate it with MIG or a whole GPU; if it is trusted and can retry, share it.

Review

Glossary

MIG
Multi-Instance GPU: hardware partitions of one GPU, each with isolated memory and compute.
Time-slicing
Several pods share one GPU by taking turns, with no memory isolation. Example: eight notebooks on one card.
MPS
Multi-Process Service: processes share one GPU context at once, with weaker isolation than MIG.
Device plugin
The Kubernetes component that advertises GPU resources to the scheduler.
Resource quota
A per namespace cap on total resources, including GPU count. Example: at most two GPUs.
Limit range
Per pod defaults and maximums inside a namespace. Example: no pod may request over one GPU.
Priority class
A ranking the scheduler uses when capacity is scarce. Example: serving-high over batch-low.
Preemption
Evicting lower priority pods so higher priority pods can be placed.
Noisy neighbour
A co-located workload whose resource use harms yours. Example: a notebook filling shared GPU memory.
Stranded capacity
Resource claimed but unused by its owner and unusable by others. Example: 68 GB idle in a whole GPU allocation.

Next: "Kubernetes for AI workloads: operators, node pools and gang scheduling".