3.4 Virtualizing GPUs
MIG, time-slicing and vGPU: how each shares a GPU and what isolation it gives.
Key points
NVIDIA says MIG lets supported GPUs be securely partitioned into up to seven separate GPU instances. MIG mode is not enabled by default. An administrator enables it, then creates instances from profiles such as 1g.10gb on H100. A profile name gives the instance's share of compute (1g = one compute slice) and its memory size (10gb).
What NVIDIA says (3)
“allows GPUs (starting with NVIDIA Ampere architecture) to be securely partitioned into up to seven separate GPU Instances for CUDA applications”
“By default, MIG mode is not enabled on the GPU.”
“Table 11 GPU Instance Profiles on H100”
A virtual machine (VM) is a software-defined computer that runs on a hypervisor. NVIDIA vGPU software is installed on a physical GPU in a server and creates virtual GPUs that can be shared across multiple VMs. NVIDIA says this raises GPU utilization while keeping management and security centralized.
What NVIDIA says (2)
“NVIDIA virtual GPU software enables multiple virtual machines (VMs) to have simultaneous, direct access to a single physical GPU”
“Installed on a physical GPU in a cloud or enterprise data center server, NVIDIA vGPU software creates virtual GPUs that can be shared across multiple virtual machines, scaling GPU utilization and enhancing ROI while centralizing manageability and security for enterprise IT.”
Multi-Instance GPU (MIG) partitions one physical GPU into separate GPU instances. NVIDIA says each instance gets dedicated compute and memory resources. Each instance's processors have isolated paths through the whole memory system. MIG also provides fault isolation between clients such as VMs, containers or processes.
What NVIDIA says (2)
“The Multi-Instance GPU (MIG) User Guide explains how to partition supported NVIDIA GPUs into multiple isolated instances, each with dedicated compute and memory resources.”
“MIG can partition available GPU compute resources (including streaming multiprocessors or SMs, and GPU engines such as copy engines or decoders), to provide a defined quality of service (QoS) with fault isolation for different clients such as VMs, containers or processes.”
Time-slicing lets workloads on an oversubscribed GPU take turns. Oversubscribed means more workloads than GPUs. NVIDIA says that, unlike MIG, there is no memory or fault isolation between the shared replicas. Time-slicing trades MIG's isolation for the ability to share a GPU among more users.
What NVIDIA says (2)
“GPU time-slicing enables workloads that are scheduled on oversubscribed GPUs to interleave with one another.”
“Time-slicing trades the memory and fault-isolation that is provided by MIG for the ability to share a GPU by a larger number of users.”
MIG (Multi-Instance GPU) divides a GPU into slices. The MIG user guide says a GPU memory slice is roughly one eighth of the GPU's memory resources, including capacity and bandwidth, and an SM slice is roughly one seventh of the SMs available in MIG mode. A GPU slice combines one of each.
What NVIDIA says (3)
“A GPU memory slice is roughly one eighth of the total GPU memory resources, including both capacity and bandwidth.”
“A GPU SM slice is roughly one seventh of the total number of SMs available in the GPU when configured in MIG mode.”
“GPU Slice A GPU slice is the smallest fraction of the GPU that combines a single GPU memory slice and a single GPU SM slice.”
A GPU instance (GI) combines GPU slices and engines such as copy engines and video decoders. The MIG user guide says everything within a GI shares all of its memory slices and other engines, but its SM slices can be divided into compute instances. So CIs in one GI get separate compute but share memory, which gives less isolation than separate GIs.
What NVIDIA says (2)
“GPU Instance A GPU Instance (GI) is a combination of GPU slices and GPU engines (DMAs, NVDECs, and so on).”
“Anything within a GPU instance always shares all the GPU memory slices and other GPU engines, but it’s SM slices can be further subdivided into compute instances (CI).”
MIG device names give the GPU instance's compute slice count and its total memory in GB. On A100-SXM4-40GB, 3g.20gb is a 3-slice instance with 20 GB. The MIG guide says on the 80 GB model profile names change with the memory proportion, for example 3g.40gb.
What NVIDIA says (2)
“The following table highlights a naming convention to refer to a MIG device by its GPU Instance’s compute slice count and its total memory in GB (rather than just its memory slice count).”
“For A100-SXM4-80GB, the profile names will change according to the memory proportion - for example, 1g.10gb , 2g.20gb , 3g.40gb , 4g.40gb , 7g.80gb , respectively.”
MIG and vGPU can be combined. The MIG user guide lists supported configurations: bare metal (including containers), GPU pass-through to Linux guests, and vGPU on supported hypervisors. It says MIG allows multiple vGPUs, and therefore VMs, to run in parallel on a single MIG-supported GPU while preserving vGPU's isolation guarantees.
What NVIDIA says (2)
“MIG allows multiple vGPUs (and thereby VMs) to run in parallel on a single MIG-supported GPU, while preserving the isolation guarantees that vGPU provides.”
“Supported configurations include: Bare-metal, including containers GPU pass-through virtualization to Linux guests on top of supported hypervisors vGPU on top of supported hypervisors”
Each workload type needs different host software: the data center driver for containers, vfio-pci for pass-through, and the vGPU Manager for vGPU. The GPU Operator documentation says you set the node label nvidia.com/gpu.workload.config to container, vm-passthrough or vm-vgpu, and that a node can run one type but not a combination.
What NVIDIA says (3)
“This is configured by adding a nvidia.com/gpu.workload.config label to the worker node with the value of container , vm-passthrough , or vm-vgpu depending on if you are planning to use vGPU or not.”
“Assumptions, constraints, and dependencies # A GPU worker node can run GPU workloads of a particular type, such as containers, virtual machines with GPU Passthrough, or virtual machines with vGPU, but not a combination of any of them.”
“For example, the datacenter driver is needed for containers, the vfio-pci driver is needed for GPU passthrough, and the NVIDIA vGPU Manager is needed for creating vGPU devices.”
Time-slicing advertises one GPU as several replicas, and CUDA interleaves the workloads. The GPU Operator documentation says requesting more than one replica does not give proportionally more access: in this example, all three pods get an equal share of compute time. The failRequestsGreaterThanOne option can reject such requests so users are not misled.
What NVIDIA says (2)
“failRequestsGreaterThanOne boolean The purpose of this field is to enforce awareness that requesting more than one GPU replica does not result in receiving more proportional access to the GPU.”
“For example, if 4 GPU replicas are available and two pods request 1 GPU each and a third pod requests 2 GPUs, the applications in the three pods have an equal share of GPU compute time.”
The device plugin offers two sharing methods. With time-slicing, workloads interleave but are not isolated: each can access the GPU memory and they share a fault domain, so if one crashes, they all do. MPS (Multi-Process Service) partitions memory and compute and enforces limits per workload. The documentation says the two are mutually exclusive, and the same method applies to all GPUs on a node.
What NVIDIA says (3)
“However, nothing special is done to isolate workloads that are granted replicas from the same underlying GPU, and each workload has access to the GPU memory and runs in the same fault-domain as of all the others (meaning if one workload crashes, they all do).”
“In contrast to time-slicing, MPS does space partitioning and allows memory and compute resources to be explicitly partitioned and enforces these limits per workload.”
“Note Time-slicing and MPS are mutually exclusive.”
The device plugin's MIG_STRATEGY can be none, single or mixed. With mixed, the plugin advertises extra resources named nvidia.com/mig-<slice_count>g.<memory_size>gb, and a pod requests one of them in its spec to get a specific MIG device.
What NVIDIA says (2)
“Configuration Option Details MIG_STRATEGY : the desired strategy for exposing MIG devices on GPUs that support it [none | single | mixed] (default 'none') The MIG_STRATEGY option configures the daemonset to be able to expose Multi-Instance GPUs (MIG) on GPUs that support them.”
“Note: With a MIG_STRATEGY of mixed, you will have additional resources available to you of the form nvidia.com/mig-<slice_count>g.<memory_size>gb that you can set in your pod spec to get access to a specific MIG device.”
MIG devices need access control so one container cannot use another's slice. The MIG deployment considerations say the /proc mechanism is deprecated as of driver 450.51.06, and recommend the /dev based interface for controlling access to MIG devices through cgroups. The nvidia-capabilities abstraction controls which actions are allowed through the driver.
What NVIDIA says (2)
“The /proc mechanism for system-level interfaces is deprecated as of 450.51.06 and it is recommended to use the /dev based system-level interface for controlling access mechanisms of MIG devices through cgroups.”
“Note Also note the device nodes and nvidia-capabilities for exposing the MIG devices.”
Key terms
- Multi-Instance GPU: Splitting one GPU into up to seven isolated instances, each with its own compute and memory.
- Time-slicing: Sharing a GPU by letting workloads take turns, without the memory and fault isolation of MIG.
- Virtual GPU: NVIDIA software that creates virtual GPUs shared across virtual machines.
- Streaming multiprocessor: The GPU compute unit that runs threads; a GPU has many SMs, and MIG divides them between instances.
Try it
Sample question
Up to how many separate GPU instances can MIG create on one supported GPU, and what must you do first?
Show the answer
Answer: Up to seven. First enable MIG mode on the GPU (it is off by default).
NVIDIA says MIG lets supported GPUs be securely partitioned into up to seven separate GPU instances. MIG mode is not enabled by default. An administrator enables it, then creates instances from profiles such as 1g.10gb on H100. A profile name gives the instance's share of compute (1g = one compute slice) and its memory size (10gb).
What NVIDIA says (3)
“allows GPUs (starting with NVIDIA Ampere architecture) to be securely partitioned into up to seven separate GPU Instances for CUDA applications”
“By default, MIG mode is not enabled on the GPU.”
“Table 11 GPU Instance Profiles on H100”