Time-Slicing Lets Pods Share a GPU but Not Isolate Its Memory

In progress Kubernetes

By default, the NVIDIA device plugin advertises one nvidia.com/gpu per physical card, and the pod that gets it holds the whole card, busy or idle. Time-slicing changes only what the plugin advertises: with replicas: 4, one card shows up as four nvidia.com/gpu, and up to four pods can each be scheduled with one. The GPU then switches between their processes in turn. Nothing else is divided: every pod sees all the card's memory, a pod can use all of it and make the others fail, and a fault in one process can affect the rest.

What the Configuration Says

The plugin reads a small config file (with the Helm chart, a named entry under config.map):

version: v1
sharing:
  timeSlicing:
    renameByDefault: false
    failRequestsGreaterThanOne: true
    resources:
      - name: nvidia.com/gpu
        replicas: 4
  • replicas: how many units each card is advertised as. The scheduler counts units, not load or memory.
  • renameByDefault: true advertises the shares under a new name, nvidia.com/gpu.shared, so a pod has to opt in to a shared card. false keeps nvidia.com/gpu, so existing manifests get a share without changing.
  • failRequestsGreaterThanOne: a pod asking for two shares wouldn't get twice the memory or a guaranteed half of the time, only block another pod. true rejects such requests instead of granting something that looks bigger than it is.

Size by Memory, Not by Count

Since the scheduler only counts shares, it will happily place four pods that each expect most of an 8 GB card. Decide the number of replicas from the memory the workloads really need (a video transcoder needs a few hundred MB, a 7B model several GB), and treat the count as an upper bound, not as a guarantee. When the workloads need isolation, the options are MIG (cards from the A100 on, so not Pascal or consumer cards) or separate cards; MPS limits memory per client but needs a card and driver that support it.

References

Review cards

Flashcard A node with one GPU and time-slicing `replicas: 4` advertises `nvidia.com/gpu: 4`. What is actually divided between the four pods?

Only scheduling units and turns on the GPU. Memory isn't divided: every pod sees the whole card and can use all of it, and there is no fault isolation.

Flashcard Why set `failRequestsGreaterThanOne: true` with time-slicing?

Two shares give a pod neither more memory nor a guaranteed bigger slice of time, only block another pod. Rejecting the request is more honest than granting it.

Flashcard What does `renameByDefault: false` change for existing GPU manifests?

The shares keep the name nvidia.com/gpu, so pods that already request it get a share without any change. With true they're advertised as nvidia.com/gpu.shared and pods must opt in.