|
| 1 | +--- |
| 2 | +title: Multi-instance GPU Node pool (preview) |
| 3 | +description: Learn how to create a Multi-instance GPU Node pool and schedule tasks on it |
| 4 | +services: container-service |
| 5 | +ms.topic: article |
| 6 | +ms.date: 1/24/2022 |
| 7 | +ms.author: juda |
| 8 | +--- |
| 9 | + |
| 10 | +# Multi-instance GPU Node pool |
| 11 | + |
| 12 | +Nvidia's A100 GPU can be divided in up to seven independent instances. Each instance has their own memory and Stream Multiprocessor (SM). For more information on the Nvidia A100, follow [Nvidia A100 GPU][Nvidia A100 GPU]. |
| 13 | + |
| 14 | +This article will walk you through how to create a multi-instance GPU node pool on Azure Kubernetes Service clusters and schedule tasks. |
| 15 | + |
| 16 | +[!INCLUDE [preview features callout](./includes/preview/preview-callout.md)] |
| 17 | + |
| 18 | +## GPU Instance Profile |
| 19 | + |
| 20 | +GPU Instance Profiles define how a GPU will be partitioned. The following table shows the available GPU Instance Profile for the `Standard_ND96asr_v4`, the only instance type that supports the A100 GPU at this time. |
| 21 | + |
| 22 | + |
| 23 | +| Profile Name | Fraction of SM |Fraction of Memory | Number of Instances created | |
| 24 | +|--|--|--|--| |
| 25 | +| MIG 1g.5gb | 1/7 | 1/8 | 7 | |
| 26 | +| MIG 2g.10gb | 2/7 | 2/8 | 3 | |
| 27 | +| MIG 3g.20gb | 3/7 | 4/8 | 2 | |
| 28 | +| MIG 4g.20gb | 4/7 | 4/8 | 1 | |
| 29 | +| MIG 7g.40gb | 7/7 | 8/8 | 1 | |
| 30 | + |
| 31 | +As an example, the GPU Instance Profile of `MIG 1g.5gb` indicates that each GPU instance will have 1g SM(Computing resource) and 5gb memory. In this case, the GPU will be partitioned into seven instances. |
| 32 | + |
| 33 | +The available GPU Instance Profiles available for this instance size are `MIG1g`, `MIG2g`, `MIG3g`, `MIG4g`, `MIG7g` |
| 34 | + |
| 35 | +> [!IMPORTANT] |
| 36 | +> The applied GPU Instance Profile cannot be changed after node pool creation. |
| 37 | +
|
| 38 | + |
| 39 | +## Create an AKS cluster |
| 40 | +To get started, create a resource group and an AKS cluster. If you already have a cluster, you can skip this step. Follow the example below to the resource group name `myresourcegroup` in the `southcentralus` region: |
| 41 | + |
| 42 | +```azurecli-interactive |
| 43 | +az group create --name myresourcegroup --location southcentralus |
| 44 | +``` |
| 45 | + |
| 46 | +```azurecli-interactive |
| 47 | +az aks create \ |
| 48 | + --resource-group myresourcegroup \ |
| 49 | + --name migcluster\ |
| 50 | + --node-count 1 |
| 51 | +``` |
| 52 | + |
| 53 | +## Create a multi-instance GPU node pool |
| 54 | + |
| 55 | +You can choose to either use the `az` command line or http request to the ARM API to create the node pool |
| 56 | + |
| 57 | +### Azure CLI |
| 58 | +If you're using command line, use the `az aks nodepool add` command to create the node pool and specify the GPU instance profile through `--gpu-instance-profile` |
| 59 | +``` |
| 60 | +
|
| 61 | +az aks nodepool add \ |
| 62 | + --name mignode \ |
| 63 | + --resourcegroup myresourcegroup \ |
| 64 | + --cluster-name migcluster \ |
| 65 | + --node-size Standard_ND96asr_v4 \ |
| 66 | + --gpu-instance-profile MIG1g |
| 67 | +``` |
| 68 | + |
| 69 | +### HTTP request |
| 70 | + |
| 71 | +If you're using http request, you can place GPU instance profile in the request body: |
| 72 | +``` |
| 73 | +{ |
| 74 | + "properties": { |
| 75 | + "count": 1, |
| 76 | + "vmSize": "Standard_ND96asr_v4", |
| 77 | + "type": "VirtualMachineScaleSets", |
| 78 | + "gpuInstanceProfile": "MIG1g" |
| 79 | + } |
| 80 | +} |
| 81 | +``` |
| 82 | + |
| 83 | + |
| 84 | + |
| 85 | + |
| 86 | +## Run tasks using kubectl |
| 87 | + |
| 88 | +### MIG strategy |
| 89 | +Before you install the Nvidia plugins, you need to specify which strategy to use for GPU partitioning. |
| 90 | + |
| 91 | +The two strategies "Single" and "Mixed" won't affect how you execute CPU workloads, but how GPU resources will be displayed. |
| 92 | + |
| 93 | +- Single Strategy |
| 94 | + |
| 95 | + The single strategy treats every GPU instance as a GPU. If you're using this strategy, the GPU resources will be displayed as: |
| 96 | + |
| 97 | + ``` |
| 98 | + nvidia.com/gpu: 1 |
| 99 | + ``` |
| 100 | + |
| 101 | +- Mixed Strategy |
| 102 | + |
| 103 | + The mixed strategy will expose the GPU instances and the GPU instance profile. If you use this strategy, the GPU resource will be displayed as: |
| 104 | + |
| 105 | + ``` |
| 106 | + nvidia.com/mig1g.5gb: 1 |
| 107 | + ``` |
| 108 | + |
| 109 | +### Install the NVIDIA device plugin and GPU feature discovery |
| 110 | + |
| 111 | +Set your MIG Strategy |
| 112 | +``` |
| 113 | +export MIG_STRATEGY=single |
| 114 | +``` |
| 115 | +or |
| 116 | +``` |
| 117 | +export MIG_STRATEGY=mixed |
| 118 | +``` |
| 119 | + |
| 120 | +Install the Nvidia device plugin and GPU feature discovery using helm |
| 121 | + |
| 122 | +``` |
| 123 | +helm repo add nvdp https://nvidia.github.io/k8s-device-plugin |
| 124 | +helm repo add nvgfd https://nvidia.github.io/gpu-feature-discovery |
| 125 | +helm repo update #do not forget to update the helm repo |
| 126 | +``` |
| 127 | + |
| 128 | +``` |
| 129 | +helm install \ |
| 130 | +--version=0.7.0 \ |
| 131 | +--generate-name \ |
| 132 | +--set migStrategy=${MIG_STRATEGY} \ |
| 133 | +nvdp/nvidia-device-plugin |
| 134 | +``` |
| 135 | + |
| 136 | +``` |
| 137 | +helm install \ |
| 138 | +--version=0.2.0 \ |
| 139 | +--generate-name \ |
| 140 | +--set migStrategy=${MIG_STRATEGY} \ |
| 141 | +nvgfd/gpu-feature-discovery |
| 142 | +``` |
| 143 | + |
| 144 | + |
| 145 | +### Confirm multi-instance GPU capability |
| 146 | +As an example, if you used MIG1g as the GPU instance profile, confirm the node has multi-instance GPU capability by running: |
| 147 | +``` |
| 148 | +kubectl describe mignode |
| 149 | +``` |
| 150 | +If you're using single strategy, you'll see: |
| 151 | +``` |
| 152 | +Allocable: |
| 153 | + nvidia.com/gpu: 56 |
| 154 | +``` |
| 155 | +If you're using mixed strategy, you'll see: |
| 156 | +``` |
| 157 | +Allocable: |
| 158 | + nvidia.com/mig-1g.5gb: 56 |
| 159 | +``` |
| 160 | + |
| 161 | +### Schedule work |
| 162 | +Use the `kubectl` run command to schedule work using single strategy: |
| 163 | +``` |
| 164 | +kubectl run -it --rm \ |
| 165 | +--image=nvidia/cuda:11.0-base \ |
| 166 | +--restart=Never \ |
| 167 | +--limits=nvidia.com/mig-1g.5gb=1 \ |
| 168 | +mixed-strategy-example -- nvidia-smi -L |
| 169 | +``` |
| 170 | + |
| 171 | +Use the `kubectl` run command to schedule work using mixed strategy: |
| 172 | +``` |
| 173 | +kubectl run -it --rm \ |
| 174 | +--image=nvidia/cuda:11.0-base \ |
| 175 | +--restart=Never \ |
| 176 | +--limits=nvidia.com/gpu=1 \ |
| 177 | +single-strategy-example -- nvidia-smi -L |
| 178 | +``` |
| 179 | + |
| 180 | + |
| 181 | +## Troubleshooting |
| 182 | +- If you do not see multi-instance GPU capability after the node pool has been created, confirm the API version is not older than 2021-08-01. |
| 183 | + |
| 184 | +<!-- LINKS - internal --> |
| 185 | + |
| 186 | + |
| 187 | +<!-- LINKS - external--> |
| 188 | +[Nvidia A100 GPU]:https://www.nvidia.com/en-us/data-center/a100/ |
| 189 | + |
0 commit comments