# 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 ](/reference/how-to-use-kubeconfig-on-linux.md)operating system, and if you are using the [Windows ](/reference/how-to-use-kubeconfig-on-windows.md)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.

```bash
nano gpu-pod.yaml
```

Copy the code below.

{% code lineNumbers="true" %}

```yaml
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
```

{% endcode %}

{% hint style="info" %}
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
  {% endhint %}

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.

```bash
kubectl apply -f gpu-pod.yaml
```

```
apiVersion: kubevirt.io/v1
kind: VirtualMachine
metadata:
  name: vm-gpu-2
spec:
  dataVolumeTemplates:
  - metadata:
      name: vm-gpu-2-dv
    spec:
      source:
        http:
          url: "https://cloud-images.ubuntu.com/noble/current/noble-server-cloudimg-amd64.img"
      storage:
        accessModes:
        - ReadWriteMany
        resources:
          requests:
            storage: 500Gi
        storageClassName: storage-nvme-c1
  running: true
  template:
    spec:
      architecture: amd64
      domain:
        devices:
          disks:
          - disk:
              bus: virtio
            name: containerdisk
          - disk:
              bus: virtio
            name: cloudinitdisk
          gpus:
          - deviceName: nvidia.com/NVIDIA_L40S-48Q
            name: gpu1
          interfaces:
          - masquerade: {}
            name: defaultnetwork
        machine:
          type: q35
        resources:
          limits:
            cpu: "16"
            memory: 32Gi
          requests:
            cpu: "16"
            memory: 32Gi
      networks:
      - name: defaultnetwork
        pod: {}
      volumes:
      - dataVolume:
          name: vm-gpu-2-dv
        name: containerdisk
      - cloudInitNoCloud:
          userData: |-
            #cloud-config
            #password: fedora
            #chpasswd: { expire: False }
            #cloud-config
            chpasswd:
              list: |
                ubuntu:ubuntu
                root:'3_7Te99XuBa
              expire: False
        name: cloudinitdisk
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.cloudeka.ai/reference/how-to-add-gpu-in-kubernetes.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
