> This page is for NVIDIA AI Enterprise: Cloud Deployment Guide.

> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.nvidia.com/ai-enterprise/deployment/llms.txt.

## Overview

*New in version 3.1.*

Amazon EKS is a managed Kubernetes service to run Kubernetes in the AWS cloud. NVIDIA AI Enterprise, the end-to-end software of the NVIDIA AI platform, is supported to run on EKS. In the cloud, Amazon EKS automatically manages the availability and scalability of the Kubernetes control plane nodes responsible for scheduling containers, managing application availability, storing cluster data, and other key tasks. This guide provides details for deploying and running NVIDIA AI Enterprise on EKS clusters with GPU Accelerated nodes.

> **Note**
>
> The [NVIDIA Terraform Modules](https://github.com/NVIDIA/nvidia-terraform-modules) offer an easy way to deploy Managed Kubernetes clusters that can be supported by NVIDIA AI Enterprise when used with supported OS and GPU Operator versions.

## Prerequisites

* [NVIDIA Enterprise License](https://docs.nvidia.com/ai-enterprise/planning-resource/licensing-guide/latest/licensing.html) via BYOL or a Private Offer

* Install the [AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html)

* Install the [EKS CLI](https://docs.aws.amazon.com/eks/latest/userguide/eksctl.html)

* [Install Helm](https://helm.sh/docs/intro/install/#from-script)

* [AWS IAM role](https://docs.aws.amazon.com/eks/latest/userguide/service_IAM_role.html) to create EKS Cluster with the following permissions:

  * Administrator Access
  * AmazonEKSClusterPolicy

    ![](/ai-enterprise/deployment/_fern-files/_img/5f30ecf9d4cfe7b75baba2cb0302fccd61977ea5be78d21f1477e4bf83af5ad1.webp)

* AWS EKS Cluster [Prerequisites](https://docs.aws.amazon.com/eks/latest/userguide/create-cluster.html)

> **Warning**
>
> Please note that release versions will differ within your local environment. As of this document's publication, eksctl version 0.133.0 was used and validated. Please refer to [Getting started with Amazon EKS](https://docs.aws.amazon.com/eks/latest/userguide/getting-started.html) for release note history as well as any topics not covered within this document's scope.

## Create a EKS Cluster

### AWS configuration

First we will get AWS credentials from the AWS console as per below, click on Access keys and proceed further

![](/ai-enterprise/deployment/_fern-files/_img/d6063ff44c7bfd9dd1fd8b2f0e5c1434bb04497769b197c689734acdf09197de.webp)

Select Command Line Interface and proceed to Next

![](/ai-enterprise/deployment/_fern-files/_img/a809573c511f7074fdec40d4a188a3f5a5e339bd3f42328f24c275bbbfb88fa5.webp)

Download the *.csv file* for future reference and configure the credentials on your system with AWS CLI.

![](/ai-enterprise/deployment/_fern-files/_img/32e4265d3040836919f053217578f5946a6e3362a8fd12a55f2ed953b06e390c.webp)

```bash
aws configure
```

Below is an example output:

```bash
AWS Access Key ID [None]:
AWS Secret Access Key [None]:
Default region name [None]:
Default output format [None]:
```

> **Warning**
>
> Depending on your organizations security practices you may need to use Temporary security credentials. Further details for using AWS STS can be found in the [Temporary security credentials in IAM documentation](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_temp.html).

Create a `cluster-config.yaml` as per below with details mentioned.

> **Warning**
>
> Replace the `ami` and `amiFamily` with the appropriate values from here: [https://cloud-images.ubuntu.com/aws-eks/](https://cloud-images.ubuntu.com/aws-eks/)

```bash

apiVersion: eksctl.io/v1alpha5
kind: ClusterConfig
metadata:
  name: <eks-cluster-name>
  region: us-west-1
  version: "1.25"
nodeGroups:
- name: gpu-nodegroup
  # grab AMI ID for Ubuntu EKS AMI here: https://cloud-images.ubuntu.com/aws-eks/
  # using AMI ID for us-west-1 region: ami-00687acd80b7a620a
  ami: ami-00687acd80b7a620a
  amiFamily: Ubuntu2004
  instanceType: g4dn.xlarge
  minSize: 1
  maxSize: 1
  volumeSize: 100
  desiredCapacity: 1
  overrideBootstrapCommand: |
      #!/bin/bash
      source /var/lib/cloud/scripts/eksctl/bootstrap.helper.sh
      /etc/eks/bootstrap.sh ${CLUSTER_NAME} --container-runtime containerd  --use-max-pods false  --kubelet-extra-args "--max-pods=60" "--node-labels=${NODE_LABELS}"
```

Choose the region and update the AMI accordingly with respect to the region. Ensure that `<eks-cluster-name>` that the user provides is identical in both sections of the .yaml file. Choose the AMI that's designed for the EKS cluster, you can get the AMI's information from [here](https://cloud-images.ubuntu.com/aws-eks/).

Run the below command to create a EKS cluster.

```bash
eksctl create cluster -f cluster-config.yaml --install-nvidia-plugin=false
```

> **Note**
>
> The creation of the cluster will take some time to complete.

Run the below command to verify the node information

```bash
kubectl get nodes -o wide
```

Example output result:

```bash
NAME                                           STATUS   ROLES    AGE     VERSION   INTERNAL-IP      EXTERNAL-IP    OS-IMAGE             KERNEL-VERSION    CONTAINER-RUNTIME
eks-<eks-cluster-name>-db9e3df9-r0jf           Ready    <none>   5m15s   v1.25.6   192.168.50.108   13.57.187.63   Ubuntu 20.04.6 LTS   5.15.0-1033-aws   containerd://1.6.12
```

## Deploy the GPU Operator

Now that the cluster and appropriate resources are created, the NVIDIA GPU Operator can be installed

> **Warning**
>
> The commands below serve as an example and will be similar, albeit slightly different, to the latest version of the GPU Operator. Please refer to the latest [GPU Operator release notes](https://docs.nvidia.com/datacenter/cloud-native/gpu-operator/latest/release-notes.html) for more information.

First we will access our NGC API Key.

Log into your [NGC account](https://ngc.nvidia.com/signin) and generate a new API Key or locate your existing API key. Please refer to the [Accessing NGC](/ai-enterprise/deployment/cloud/appendix-ngc#ngc-containter-registry-login) section of the Appendix.

Generate an API key for accessing the catalog

Next you must generate an API Key that will give you access to the NGC Catalog.

Navigate to the user account icon in the top right corner and select **Setup**.

![](/ai-enterprise/deployment/_fern-files/_img/12c9b9140d147547c1f928cbf64d1d7ba0326517c96ed76385fdf0c9151a2047.webp)

![](/ai-enterprise/deployment/_fern-files/_img/cd27f67617ac34b7ceea5aac47370a90a4db2d06a57cda123442ad8e85879d78.webp)

Select **Get API key** to open the Setup > API Key page.

Select **Generate API Key** to generate your API key.

Select **Confirm** to generate the key, and copy it from the bottom of the page.
NGC does not save your key, so store it in a secure place.

![](/ai-enterprise/deployment/_fern-files/_img/e3c0384c0d89273151ce6b476e2d1a26d2ce93088ee5125f8debcaa7f0be9ba9.webp)

> **Note**
>
> Generating a new API Key invalidates the previously generated key.

Add the Helm repo and update with the below commands.

```bash
helm repo add nvidia https://helm.ngc.nvidia.com/nvaie --username='$oauthtoken' --password=<YOUR API KEY>
helm repo update
```

Create a NGC Secret with your NGC API key on "gpu-operator" namespace as per below.

```bash
$ kubectl create ns gpu-operator

$ kubectl create secret docker-registry ngc-secret  \
--docker-server=nvcr.io/nvaie --docker-username=\$oauthtoken \
    --docker-password=<NGC-API-KEY> \
--docker-email=<NGC-email> -n gpu-operator
```

Create an empty gridd.conf file, then create a configmap with NVIDIA vGPU Licence token file as per below

```bash
kubectl create configmap licensing-config   -n gpu-operator --from-file=./client_configuration_token.tok --from-file=./gridd.conf
```

> **Note**
>
> The configmap will look for the file client_configuration_token.tok, if your token is in different form such as `client_configuration_token_date_xx_xx.tok`, then please run the below command:
>
> ```bash
>
> mv client_configuration_token_date_xx_xx.tok client_configuration_token.tok
> ```

Install the GPU Operator from the NGC Catalog with a License token and the NVIDIA AI Enterprise driver repo.

> **Warning**
>
> If using K8s release prior to 1.25, then deploy GPU operator with PSP option enabled via the parameter option `--psp.enabled=true`. If using K8s release greater than or equal to 1.25, then deploy GPU operator without PSP option enabled

```bash
helm install gpu-operator nvidia/gpu-operator-3-0 --set driver.repository=nvcr.io/nvaie,driver.licensingConfig.configMapName=licensing-config --namespace gpu-operator
```

> **Warning**
>
> Ensure that you have the correct role. Please refer to the [AWS IAM Role](https://docs.aws.amazon.com/eks/latest/userguide/service_IAM_role.html) documentation if you lack the required permissions.

Once installed, please wait at least 5 minutes and verify that all the pods are either running or completed as per below.

```bash
kubectl get pods -n gpu-operator
NAME                                                          READY   STATUS      RESTARTS   AGE
gpu-feature-discovery-fzgv9                                   1/1     Running     0          6m1s
gpu-operator-69f476f875-w4hwr                                 1/1     Running     0          6m29s
gpu-operator-node-feature-discovery-master-84c7c7c6cf-hxlk4   1/1     Running     0          6m29s
gpu-operator-node-feature-discovery-worker-86bbx              1/1     Running     0          6m29s
nvidia-container-toolkit-daemonset-c7k5p                      1/1     Running     0          6m
nvidia-cuda-validator-qjcsf                                   0/1     Completed   0          59s
nvidia-dcgm-exporter-9tggn                                    1/1     Running     0          6m
nvidia-device-plugin-daemonset-tpx9z                          1/1     Running     0          6m
nvidia-device-plugin-validator-gz85d                          0/1     Completed   0          44s
nvidia-driver-daemonset-jwzx8                                 1/1     Running     0          6m9s
nvidia-operator-validator-qj57n                               1/1     Running     0          6m
```

## Verify the GPU Operator Installation

Verify the NVIDIA GPU Driver loaded with below command.

```bash
kubectl exec -it nvidia-driver-daemonset-jwzx8 -n gpu-operator -- nvidia-smi
```

```bash
Defaulted container "nvidia-driver-ctr" out of: nvidia-driver-ctr, k8s-driver-manager (init)
Tue Feb 14 22:24:31 2023
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 520.60.13    Driver Version: 520.60.13    CUDA Version: 12.0     |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|                               |                      |               MIG M. |
|===============================+======================+======================|
|   0  Tesla T4            On   | 00000000:00:04.0 Off |                    0 |
| N/A   51C    P8    17W /  70W |      0MiB / 15360MiB |      0%      Default |
|                               |                      |                  N/A |
+-------------------------------+----------------------+----------------------+

+-----------------------------------------------------------------------------+
| Processes:                                                                  |
|  GPU   GI   CI        PID   Type   Process name                  GPU Memory |
|        ID   ID                                                   Usage      |
|=============================================================================|
|  No running processes found                                                 |
+-----------------------------------------------------------------------------+
```

> **Note**
>
> `nvidia-driver-daemonset-xxxxx` will be different within your own environment for the above command to verify the NVIDIA vGPU Driver.

Verify the NVIDIA vGPU license information with below command

```bash
kubectl exec -it nvidia-driver-daemonset-jwzx8 -n gpu-operator -- nvidia-smi -q
```

Inspect the validator pod logs to ensure the GPUs are exposed and utilized.

```bash
Kubectl logs nvidia-cuda-validator-vkr14 -n nvidia-gpu-operator
Kubectl logs nvidia-device-plugin-validator-lsmnc -n nvidia-gpu-operator
```

## Run Sample NVIDIA AI Enterprise Container

> **Warning**
>
> Container images will be similar, albeit slightly different when using the latest image. Please refer to [Pulling and Running NVIDIA AI Enterprise Containers](/ai-enterprise/deployment/cloud/appendix-ngc) to find the latest images on [NGC](https://catalog.ngc.nvidia.com/).

Create a docker-registry secret. This will be used in a custom yaml to pull containers from the NGC Catalog.

```bash
kubectl create secret docker-registry regcred --docker-server=nvcr.io/nvaie --docker-username=\$oauthtoken --docker-password=<YOUR_NGC_KEY> --docker-email=<your_email_id> -n default
```

Create a custom yaml file to deploy an NVIDIA AI Enterprise Container and run sample training code.

```bash
nano pytoch-mnist.yaml
```

Paste the below contents into the file and save

```yaml
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: pytorch-mnist
  labels:
    app: pytorch-mnist
spec:
  replicas: 1
  selector:
    matchLabels:
      app: pytorch-mnist
  template:
    metadata:
      labels:
        app: pytorch-mnist
    spec:
      containers:
        - name: pytorch-container
          image: nvcr.io/nvaie/pytorch-2-0:22.02-nvaie-2.0-py3
          command:
            - python
          args:
            - /workspace/examples/upstream/mnist/main.py
          resources:
            requests:
              nvidia.com/gpu: 1
            limits:
              nvidia.com/gpu: 1
      imagePullSecrets:
        - name: regcred
```

Check the status of the pod.

```bash
kubectl get pods
```

View the output of the sample mnist training job.

```bash
kubectl logs -l app=pytorch-mnist
```

The output will look similar to this.

```bash
~$ kubectl logs -l app=pytorch-mnist
Train Epoch: 7 [55680/60000 (93%)]      Loss: 0.040756
Train Epoch: 7 [56320/60000 (94%)]      Loss: 0.028230
Train Epoch: 7 [56960/60000 (95%)]      Loss: 0.019917
Train Epoch: 7 [57600/60000 (96%)]      Loss: 0.005957
Train Epoch: 7 [58240/60000 (97%)]      Loss: 0.003768
Train Epoch: 7 [58880/60000 (98%)]      Loss: 0.277371
Train Epoch: 7 [59520/60000 (99%)]      Loss: 0.115487

Test set: Average loss: 0.0270, Accuracy: 9913/10000 (99%)
```

## Delete the EKS Cluster

Run the below command to delete the EKS cluster.

```bash
eksctl delete cluster -f cluster_config.yaml
```