Applies to: AKS on Azure Stack HCI 22H2, AKS on Windows Server
Graphical Processing Units (GPU) are used for compute-intensive workloads such as machine learning, deep learning, and more. This article describes how to use GPUs for compute-intensive workloads in AKS enabled by Azure Arc.
Before you begin
If you are updating AKS from a preview version older than October 2022 that is running GPU-enabled node pools, make sure you remove all workload clusters running GPUs before you begin. Follow the steps in this section.
Step 1: Uninstall the Nvidia host driver
On each host machine, navigate to Control Panel > Add or Remove programs, uninstall the NVIDIA host driver, then reboot the machine. After the machine reboots, confirm that the driver was successfully uninstalled. Open an elevated PowerShell terminal and run the following command:
You should see the GPU devices appear in an error state as shown in this example output:
Error 3D Video Controller PCI\VEN_10DE&DEV_1EB8&SUBSYS_12A210DE&REV_A1\4&32EEF88F&0&0000
Error 3D Video Controller PCI\VEN_10DE&DEV_1EB8&SUBSYS_12A210DE&REV_A1\4&3569C1D3&0&0000
Step 2: Dismount the host driver from the host
When you uninstall the host driver, the physical GPU goes into an error state. You must dismount all the GPU devices from the host.
For each GPU (3D Video Controller) device, run the following commands in PowerShell. Copy the instance ID; for example, PCI\VEN_10DE&DEV_1EB8&SUBSYS_12A210DE&REV_A1\4&32EEF88F&0&0000 from the previous command output:
$id1 = "<Copy and paste GPU instance id into this string>"
$lp1 = (Get-PnpDeviceProperty -KeyName DEVPKEY_Device_LocationPaths -InstanceId $id1).Data[0]
Disable-PnpDevice -InstanceId $id1 -Confirm:$false
Dismount-VMHostAssignableDevice -LocationPath $lp1 -Force
To confirm that the GPUs were correctly dismounted from the host, run the following command. You should put GPUs in an Unknown state:
Unknown 3D Video Controller PCI\VEN_10DE&DEV_1EB8&SUBSYS_12A210DE&REV_A1\4&32EEF88F&0&0000
Unknown 3D Video Controller PCI\VEN_10DE&DEV_1EB8&SUBSYS_12A210DE&REV_A1\4&3569C1D3&0&0000
Step 3: Download and install the NVIDIA mitigation driver
The software might include components developed and owned by NVIDIA Corporation or its licensors. The use of these components is governed by the NVIDIA end user license agreement.
See the NVIDIA data center documentation to download the NVIDIA mitigation driver. After downloading the driver, expand the archive and install the mitigation driver on each host machine.
To install the mitigation driver, navigate to the folder containing the extracted files, right-click the nvidia_azure_stack_T4_base.inf file, and select Install. Check that you have the correct driver; AKS currently supports only the NVIDIA Tesla T4 GPU.
You can also install using the command line by navigating to the folder and running the following commands to install the mitigation driver:
After installing the workload cluster, run the following command to get your Kubeconfig:
Get-AksHciCredential -Name gpucluster
Confirm you can schedule GPUs
With your GPU node pool created, confirm that you can schedule GPUs in Kubernetes. First, list the nodes in your cluster using the kubectl get nodes command:
kubectl get nodes
NAME STATUS ROLES AGE VERSION
moc-l9qz36vtxzj Ready control-plane,master 6m14s v1.22.6
moc-lhbkqoncefu Ready <none> 3m19s v1.22.6
moc-li87udi8l9s Ready <none> 3m5s v1.22.6
Now use the kubectl describe node command to confirm that the GPUs can be scheduled. Under the Capacity section, the GPU should appear as nvidia.com/gpu: 1.
kubectl describe <node> | findstr "gpu"
The output should display the GPU(s) from the worker node and look something like this:
Once you complete the previous steps, create a new YAML file for testing; for example, gpupod.yaml. Copy and paste the following YAML into the new file named gpupod.yaml, then save it:
Run the following command to deploy the sample application:
kubectl apply -f gpupod.yaml
Verify that the pod started, completed running, and the GPU is assigned:
kubectl describe pod cuda-vector-add | findstr 'gpu'
The previous command should show one GPU assigned:
nvidia.com/gpu: 1
nvidia.com/gpu: 1
Check the log file of the pod to see if the test passed:
kubectl logs cuda-vector-add
The following is example output from the previous command:
[Vector addition of 50000 elements]
Copy input data from the host memory to the CUDA device
CUDA kernel launch with 196 blocks of 256 threads
Copy output data from the CUDA device to the host memory
Test PASSED
Done
If you receive a version mismatch error when calling into drivers, such as "CUDA driver version is insufficient for CUDA runtime version," review the NVIDIA driver matrix compatibility chart.
FAQ
What happens during upgrade of a GPU-enabled node pool?
Upgrading GPU-enabled node pools follows the same rolling upgrade pattern that's used for regular node pools. For GPU-enabled node pools in a new VM to be successfully created on the physical host machine, it requires one or more physical GPUs to be available for successful device assignment. This availability ensures that your applications can continue running when Kubernetes schedules pods on this upgraded node.
Before you upgrade:
Plan for downtime during the upgrade.
Have one extra GPU per physical host if you are running the Standard_NK6 or 2 extra GPUs if you are running Standard_NK12. If you are running at full capacity and don't have an extra GPU, we recommend scaling down your node pool to a single node before the upgrade, then scaling up after upgrade succeeds.
What happens if I don't have extra physical GPUs on my physical machine during an upgrade?
If an upgrade is triggered on a cluster without extra GPU resources to facilitate the rolling upgrade, the upgrade process hangs until a GPU is available. If you run at full capacity and don't have an extra GPU, we recommend scaling down your node pool to a single node before the upgrade, then scaling up after the upgrade succeeds.