GPU sharing in practice: MIG, MPS and time-slicing compared, and a noisy neighbour measured
Three ways to put more than one workload on a GPU, compared for memory, compute and fault isolation, granularity, overhead and which GPUs support them. How each works underneath, how to configure each on Kubernetes with the NVIDIA device plugin and GPU Operator, what it means for LLM engines that preallocate memory, and a script that measures how much a noisy neighbour slows your workload under each mode.
By Sandip Maity, Applied AI Engineer
Key takeaways
- Time-slicing shares a GPU by taking turns. Nothing is isolated: memory, faults and performance are all shared, and one crash can take every workload with it.
- MPS runs kernels from several processes at the same time through one server, with per-client limits on memory and on the share of SMs. Throughput is good; fault isolation is weaker than MIG.
- MIG cuts a data-centre GPU into up to seven hardware partitions with their own SMs, memory and L2 cache. It is the only mode with hard isolation, at the cost of fixed sizes and a reconfiguration to change them.
- Kubernetes does not see GPU memory. Under time-slicing and MPS, size each engine's memory explicitly, because LLM engines reserve most of the GPU at startup by default.
- Measure the neighbour effect on your own workload: p99 latency under contention is the number that matters, and it differs a lot between modes.
Goal: choose the right way to share a GPU between workloads, configure it on Kubernetes, and measure what sharing costs your own workload.
You need: GPUs on Kubernetes and scheduling, node pools and multi-tenancy. For the measurement, one NVIDIA GPU (any for time-slicing and MPS; an A100, H100 or similar for MIG) and PyTorch. The script is production/noisy_neighbour.py in the companion repository.
Honest limits. The configuration in this lesson follows the NVIDIA device plugin's documentation at v0.20.2 and NVIDIA's MIG and MPS documentation; check the versions you run. We ran the measurement script only in its CPU self-check mode, so this page shows no GPU numbers and makes no claim about how large the effects are on your hardware. That is what the measurement section is for.
#Why share a GPU at all
A small model, a development notebook, an embedding service or a low-traffic tenant often uses a small fraction of a large GPU. Giving each its own GPU wastes most of it. Sharing raises utilisation, but every way of sharing trades something away: isolation, flexibility or simplicity.
#The three modes
| Time-slicing | MPS (Multi-Process Service) | MIG (Multi-Instance GPU) | |
|---|---|---|---|
| How it works | Processes take turns; the GPU switches between their contexts | One server context runs kernels from several client processes at the same time | The GPU is split in hardware into instances with their own SMs, memory and L2 |
| Memory isolation | None: any process can allocate all of it | Per-client limit (CUDA_MPS_PINNED_DEVICE_MEM_LIMIT) |
Hard: each instance has its own memory |
| Compute isolation | None: turns are shared, contention adds latency | Soft: share of SMs per client (CUDA_MPS_ACTIVE_THREAD_PERCENTAGE); bandwidth and L2 still shared |
Hard: own SMs, memory bandwidth and L2 slices |
| Fault isolation | None: the device plugin's documentation warns that if one workload crashes, they all do | Weaker than MIG: a fatal fault in one client can affect others on the GPU | Per instance |
| Granularity | Any number of replicas | Any number of clients | Fixed profiles, up to 7 instances |
| Concurrent kernels from different processes | No (turns) | Yes | Yes (separate hardware) |
| GPUs | Any | Volta and newer | Data-centre GPUs from A100 on (A30, A100, H100, H200 and Blackwell data-centre parts); not the T4, A10, L4 or consumer cards |
| Changing it | Device plugin config | Device plugin config, MPS daemon | Repartition the GPU (no workloads on it) |
#Time-slicing
Each process has its own CUDA context, and the GPU gives each a slice of time in turn. When only one process is busy, it gets the whole GPU. When several are busy, each waits for the others' turns, so latency grows with the number of busy neighbours, and nothing stops one process from allocating all the memory.
#MPS
A server process holds one context on the GPU, and client processes submit their work through it, so kernels from different clients can run on different SMs at the same time instead of taking turns. Since Volta, each client has its own address space, and the server can limit each client's memory and the percentage of SMs its kernels may use. Clients still share memory bandwidth and L2 cache, so a bandwidth-hungry neighbour still slows you, and fault isolation is weaker than MIG.
#MIG
MIG divides a supported GPU into instances, each with its own compute slices, memory slices, memory controllers and L2 cache. Profiles are named <compute slices>g.<memory>gb; on an A100 80GB, examples include 1g.10gb, 2g.20gb, 3g.40gb and 7g.80gb, and up to seven instances fit. List what your GPU supports with nvidia-smi mig -lgip. To a process, an instance looks like a smaller GPU. You cannot resize an instance while it is in use, so MIG suits stable, planned layouts.
Sharing mode
Neighbour
Memory
None
Compute
None
Bandwidth and L2
None
Faults
None
The two processes take turns on the whole GPU. When the neighbour is busy, your kernels wait for its slice to end: latency jumps, and nothing stops it from taking all the memory.
A picture of the mechanism, not a measurement: bar height is the share of the GPU each process holds in each moment. Measure the effect on your own workload with the lesson's noisy-neighbour script.
The rest is Pro
Keep reading this full lab
Pro unlocks this full lab, every advanced lesson, the hands-on labs and completion certificates.
One year
$25
365 days, no auto-renewal
Lifetime Best value
$75
pay once, keep it forever
7-day refund, no questions asked. One payment, no auto-renewal.Compare plansHave a licence key?
Not ready? Keep learning free
- Kubernetes for LLM engineers: the mental model16 min
- Deploying vLLM on Kubernetes: a production manifest, line by line19 min
Free lessons from Kubernetes for GPU Inference, no sign-up. Or follow the free roadmap →
Not ready? Take the free 5-day email course
One short email a day for five days, each built on a free lesson, then the occasional new lesson or offer. Unsubscribe in one click.
Still to come in this lab
- Configuring each on Kubernetes
- What sharing means for LLM engines
- Measuring a noisy neighbour
- Choosing
- What you can now do
- Common mistakes
- Exercise
- Going deeper
You will be able to answer
- Two vLLM servers are placed on one GPU with time-slicing and default settings. The second fails at startup with out-of-memory. Why?
- With the device plugin's time-slicing config at 4 replicas, a pod requests nvidia.com/gpu: 2. What does it get?
- Which mode keeps a memory-bandwidth-hungry neighbour from affecting your p99 latency the most?
- When is MPS a better choice than MIG?