Page cover

How to add GPU in Kubernetes

After you have successfully completed the kubeconfig configuration. If not, you can follow the steps in this link if you are using the Linux operating system, and if you are using the Windows operating system. For the next step you can add a GPU to Kubernetes. Run the following syntax to create a file that will store the GPU configuration.

nano gpu-pod.yaml

Copy the code below.

apiVersion: v1
kind: Pod
metadata:
  name: gpu-pod
spec:
  containers:
  - name: gpu-container
    image: nvidia/cuda:11.0-base
    resources:
      limits:
        nvidia.com/gpu: 1  # Request one GPU
  affinity:
    nodeAffinity:
      requiredDuringSchedulingIgnoredDuringExecution:
        nodeSelectorTerms:
        - matchExpressions:
          - key: gpu.nvidia.com/class
            operator: In
            values:
            - H100

Can replace H100 in the last line with the following type.

  • NVIDIA-H100-80GB-HBM3

  • NVIDIA-H100-80GB-HBM3-MIG-1g.10gb

  • NVIDIA-H100-80GB-HBM3-MIG-1g.20gb

  • NVIDIA-H100-80GB-HBM3-MIG-1g.40gb

  • NVIDIA-L40

Save the file and exit the text editor. If you're using nano, press CTRL+X, then Y to confirm, and press Enter. Deploy the YAML file using kubectl by executing the syntax below.

Last updated