// Module included in the following assemblies:
//
// * hosted_control_planes/hcp-manage/hcp-manage-virt.adoc

:_mod-docs-content-type: PROCEDURE
[id="hcp-virt-attach-nvidia-gpus-np-api_{context}"]
= Attaching NVIDIA GPU devices by using the NodePool resource

[role="_abstract"]
You can attach one or more NVIDIA graphics processing unit (GPU) devices to node pools by configuring the `nodepool.spec.platform.kubevirt.hostDevices` field in the `NodePool` resource.

:FeatureName: Attaching NVIDIA GPU devices to node pools
include::snippets/technology-preview.adoc[]

.Procedure

* To attach a single GPU device, configure the `NodePool` resource by using the following example configuration:
+
[source,yaml]
----
apiVersion: hypershift.openshift.io/v1beta1
kind: NodePool
metadata:
  name: <hosted_cluster_name>
  namespace: <hosted_cluster_namespace>
spec:
  arch: amd64
  clusterName: <hosted_cluster_name>
  management:
    autoRepair: false
    upgradeType: Replace
  nodeDrainTimeout: 0s
  nodeVolumeDetachTimeout: 0s
  platform:
    kubevirt:
      attachDefaultNetwork: true
      compute:
        cores: <cpu>
        memory: <memory>
      hostDevices:
      - count: <count>
        deviceName: <gpu_device_name>
      networkInterfaceMultiqueue: Enable
      rootVolume:
        persistent:
          size: 32Gi
        type: Persistent
    type: KubeVirt
  replicas: <worker_node_count>
----
+
** `<hosted_cluster_name>` specifies the name of your hosted cluster; for example, `my-hosted-cluster`.
** `<hosted_cluster_namespace>` specifies the name of the hosted cluster namespace; for example, `my-hc-namespace`.
** `<cpu>` specifies a value for CPU; for example, `2`.
** `<memory>` specifies a value for memory; for example, `16Gi`.
** `<count>` specifies the number of GPU devices you want to attach to each virtual machine (VM) in node pools. For example, if you attach 2 GPU devices to 3 node pool replicas, all 3 VMs in the node pool are attached to the 2 GPU devices. The default count is `1`. The `hostDevices` field defines a list of different types of GPU devices that you can attach to node pools.
** `<gpu_device_name>` specifies the GPU device name; for example,`nvidia-a100`.
** `<worker_node_count>` specifies the worker count; for example, `3`.

* To attach multiple GPU devices, configure the `NodePool` resource by using the following example configuration:
+
[source,yaml]
----
apiVersion: hypershift.openshift.io/v1beta1
kind: NodePool
metadata:
  name: <hosted_cluster_name>
  namespace: <hosted_cluster_namespace>
spec:
  arch: amd64
  clusterName: <hosted_cluster_name>
  management:
    autoRepair: false
    upgradeType: Replace
  nodeDrainTimeout: 0s
  nodeVolumeDetachTimeout: 0s
  platform:
    kubevirt:
      attachDefaultNetwork: true
      compute:
        cores: <cpu>
        memory: <memory>
      hostDevices:
      - count: <count>
        deviceName: <gpu_device_name>
      - count: <count>
        deviceName: <gpu_device_name>
      - count: <count>
        deviceName: <gpu_device_name>
      - count: <count>
        deviceName: <gpu_device_name>
      networkInterfaceMultiqueue: Enable
      rootVolume:
        persistent:
          size: 32Gi
        type: Persistent
    type: KubeVirt
  replicas: <worker_node_count>
----
+
** `<hosted_cluster_name>` specifies the name of your hosted cluster; for example, `my-hosted-cluster`.
** `<hosted_cluster_namespace>` specifies the name of the hosted cluster namespace; for example, `my-hc-namespace`.
** `<cpu>` specifies a value for CPU; for example, `2`.
** `<memory>` specifies a value for memory; for example, `16Gi`.
** `<count>` specifies the number of GPU devices you want to attach to each VM in node pools. For example, if you attach 2 GPU devices to 3 node pool replicas, all 3 VMs in the node pool are attached to the 2 GPU devices. The default count is `1`. The `hostDevices` field defines a list of different types of GPU devices that you can attach to node pools.
** `<gpu_device_name>` specifies the GPU device name; for example,`nvidia-a100`.
** `<worker_node_count>` specifies the worker count; for example, `3`.
