NVIDIA GPU operator
Overview
The NVIDIA GPU Operator is a Kubernetes operator that automates the deployment, configuration, and management of the NVIDIA software required to run GPU-accelerated workloads.
Getting Started
1. Setting Up Your Shoot Cluster with GPU Workers
To use NVIDIA GPUs in your shoot cluster, you need to configure worker groups with GPU-enabled machine types. At least one of the worker groups must have GPU-enabled machine types.
Steps:
- In your project, navigate to the creation of the new Cluster
- Fill in the necessary information
- Select
Machine Typewithgpucapabilities Machine Imageshould be set to the supported one with GPU capabilities -NVGPU Garden Linux- Select
Zonewhere GPU nodes are available
- Select
- Fill in the rest of the cluster creation form and hit 'Create'
- Wait for the cluster to be created and reconciled
If only a limited number of GPU is available, set Autoscaler Max. equal to Autoscaler Min. and set maxSurge: 0 and maxUnavailable: 1 due to insufficient resources.
2. Verifying GPU Availability
Check Node Labels
The Node Feature Discovery component automatically labels nodes with GPU capabilities. You can verify this by checking the node labels:
Check GPU Resources
Verify that GPU resources are advertised on your nodes:
Check NVIDIA GPU Operator Status
Verify that the NVIDIA GPU Operator components are running:
You should see various NVIDIA operator pods running:
Check NVIDIA GPU Operator Validator
The NVIDIA GPU Operator includes a built-in validator that sanity-checks driver, device plugin, and CUDA toolkit readiness. Let's verify it by inspecting the nvidia-operator-validator DaemonSet and its pod logs.
Expected output:
Verification: Running Sample GPU Applications
To verify that GPU operations are working correctly, you can run a sample CUDA application.
CUDA VectorAdd Example
This example demonstrates a simple CUDA vector addition operation to verify GPU functionality.
Create cuda-vectoradd pod
The pod starts, runs the vectorAdd command, and then exits.
View the logs from the container
Expected Output:
If you see "Test PASSED", your GPU is working correctly!
Remove the pod
Alternative: Simple nvidia-smi test
For a quicker verification, you can run a simple pod that executes nvidia-smi:
Apply and check the logs:
Expected output:
Using GPUs in Your Applications
Resource Requests
To use a GPU in your pod, specify the GPU resource and runtimeClassName in the pod specification:
Make sure you have enough resources to satisfy the requests.
Multi-Instance GPU
MIG (Multi-Instance GPU) is an NVIDIA technology that slices a single physical GPU into multiple isolated GPU instances. Each instance has dedicated compute, memory, and cache, so different workloads can run securely without resource contention. In Kubernetes, the GPU Operator's MIG Manager applies the desired layout on nodes, and GPU Feature Discovery advertises the resulting MIG resources for scheduling.
Applying MIG config
Using a different MIG config is disruptive and causes pods on the node to be restarted or even removed.
You must select the correct MIG profile for the specific GPU model; see the list on page NVIDIA Supported MIG Profiles.
Set MIG layout via label
In our example we will use MIG config all-1g.6gb. In our case this means the physical GPU will be partitioned into four isolated MIG instances.
Wait for GPU Operator to reconcile
nvidia-mig-manager DaemonSet will reconfigure MIG on each node if applicable.
MIG instances visible in cluster
Expected output:
Or we can use nvidia-smi.
Disable MIG instances
To disable MIG and revert to using the full physical GPU, change the node label to mig.config=all-disabled.