AWS
NIM LLM and VLM supports deployment on Amazon Web Services (AWS) through two approaches:
- EKS (Amazon Elastic Kubernetes Service): Self-managed Kubernetes deployment using Helm charts with GPU-accelerated nodes.
- SageMaker: Fully managed ML platform with managed real-time inference endpoints that use S3 for model storage.
Deploy on Amazon EKS
This guide walks through deploying NIM LLM and VLM on Amazon Elastic Kubernetes Service (EKS) with GPU-accelerated nodes.
To deploy NIM LLM and VLM on Amazon EKS, complete the following steps.
Prerequisites
Before you start, complete the following prerequisites:
- Create or use an AWS account with permissions to create EKS clusters, EC2 GPU instances, and associated networking and IAM resources.
- Confirm sufficient GPU instance quota in your target region. Verify in the AWS Console under Service Quotas > Amazon EC2 > “Running On-Demand [instance-type] instances”.
- Obtain an NGC account and API key.
- Install the following CLI tools:
Configure AWS Credentials
Set up a named AWS CLI profile and confirm that it works before you create infrastructure.
Create a Named Profile
Use a named profile so the AWS CLI and related tools use the expected account and region.
-
Create the AWS credentials directory, and open the credentials file:
-
Add your profile to
~/.aws/credentials: -
Set your profile and default region:
-
Verify that the profile works:
Check GPU Instance Quota
Confirm that your target region has enough GPU quota before you create the cluster.
-
Set the AWS region:
-
List the relevant GPU quotas:
Use the quota output to confirm the instance families you plan to use:
- G-series (
g5.xlarge,g5.12xlarge, and so on) requires quota codeL-DB2E81BA. - P-series (
p4d.24xlarge,p5.48xlarge) requires quota codeL-417A185B.
Set Up the EKS Cluster
Create the control plane first, then add GPU-enabled worker nodes and the supporting storage and GPU components.
Set Environment Variables
Start by defining the values that the EKS setup commands use.
Create the Cluster
Follow these steps to create the EKS control plane and verify connectivity:
-
Create the EKS control plane (without any node group). Refer to the AWS EKS documentation for additional cluster creation options.
-
After the cluster is ready, verify connectivity:
To update kubeconfig for an existing cluster, run:
Add a GPU Node Group
Add a GPU-capable managed node group after the EKS control plane is ready.
-
Create the GPU node group:
-
After the node group is ready, verify that the node joined the cluster:
The following command options determine the key characteristics of the GPU node group:
--node-type: Select a value based on your GPU requirements.--nodes 1: Number of GPU instances to launch.--node-ami-family AmazonLinux2: Uses the GPU-optimized AMI with pre-installed NVIDIA drivers.--node-volume-size 200: Provides 200 GB of disk space for model storage and container images.
Install the NVIDIA GPU Operator
The GPU Operator manages the device plugin, container runtime, and other NVIDIA components that are required for GPU scheduling. Refer to the GPU Operator documentation for details.
Install the GPU Operator after the node group is available.
-
Add the NVIDIA Helm repository, and update your local chart index:
-
Install the GPU Operator:
-
Verify that the GPU Operator pods are ready:
-
Verify that the nodes advertise GPU capacity:
Associate the IAM OIDC Provider
The Amazon EBS CSI driver uses IAM Roles for Service Accounts (IRSA), which requires an IAM OIDC provider associated with the cluster. Associate it before you create the driver’s IAM service account.
This command is idempotent: if the provider is already associated, eksctl reports that and makes no change.
Install the Amazon EBS CSI Driver
The Amazon EBS CSI driver is required for dynamic PersistentVolumeClaim provisioning.
-
Create an IAM service account using the
--override-existing-serviceaccountsflag to keep re-runs idempotent: -
Get your AWS account ID:
-
Install the addon:
The previous step creates the
ebs-csi-controller-saServiceAccount and labels itapp.kubernetes.io/managed-by: eksctl. The Amazon EBS CSI managed addon installs its own copy of that ServiceAccount. Without--force, the addon refuses to reconcile the conflicting label, fails with aConfigurationConflicterror, and remains in theCREATE_FAILEDstate. The--forceflag applies the addon with theOVERWRITEconflict-resolution mode so that the addon adopts the existing ServiceAccount, which allows the controller to start and theebs.csi.aws.comdriver to register. If the addon fails, the EBS CSI controller has no pods, andPersistentVolumeClaimresources stay in thePendingstate. -
Verify the installation:
Verify the Cluster Is Ready
Run the following checks to confirm that the cluster is ready for deployment.
-
Confirm that the nodes are present:
-
Confirm that the nodes advertise GPU capacity:
-
Confirm that the Amazon EBS CSI Driver pods are running:
-
Confirm that the GPU Operator pods are running:
Deploy NIM
After the cluster is ready, create the namespace, configure secrets and storage, and install the Helm chart.
Create the Namespace and Secrets
Create the Kubernetes namespace and the secrets that the deployment uses.
-
Set the deployment variables:
-
Create the namespace:
-
Create the NGC registry secret:
-
Create the NGC API key secret:
If your model requires a gated Hugging Face repository, create an additional secret with your Hugging Face token:
Create a Model Cache PVC
Create a persistent volume claim so model artifacts can be reused across pod restarts.
gp3 is also a valid storageClassName.
Create a Helm Values File
<NIM_LLM_MODEL_SPECIFIC_IMAGE> is the NIM image for your model from the Support Matrix for NIMs. The image determines whether the deployment uses vLLM or SGLang. The EKS deployment steps in this section apply to either inference engine.
Save the following as custom-values-eks.yaml:
livenessProbe.timeoutSeconds defaults to 1 in the chart. The liveness endpoint itself (/v1/health/live) is served directly by nginx and returns 200 without touching the backend, so the endpoint response is effectively instant. The 10-second override guards against transient kubelet-to-pod network latency (bin-packed nodes, CNI hiccups) that could otherwise trip a 1-second budget and cause a spurious restart during model load. Skip the override if your cluster’s baseline latency profile is stable. Readiness and startup probes use /v1/health/ready and already ship with 30-second timeouts.
startupProbe (60/30s/30s / failureThreshold=120, ~60 min budget) and readinessProbe (60/30s/30s / failureThreshold=6) already ship with timings sized for slow-starting deployments (large checkpoints, multi-node) on either inference engine, so no override is required for those two.
The example above deploys a single-GPU model on a g5.xlarge instance. For larger models requiring multiple GPUs, use an instance type with sufficient GPUs (for example, p4d.24xlarge for 8x A100) and set resources.limits.nvidia.com/gpu to the corresponding GPU count in your values file.
Replace <profile-hash> with a valid profile ID for your chosen model and GPU.
To list available profiles, refer to Model Profiles and Selection.
Install the Helm Chart
Download the NIM Helm chart, and then install it.
-
Download the chart package:
-
Install the chart:
Monitor and Verify the Deployment
Use the following steps to monitor the rollout and verify that the service is reachable.
-
Watch the pod status:
-
Stream the NIM logs:
-
Get the service endpoint:
-
After
EXTERNAL-IPis populated, setEXTERNAL_IP:
If the LoadBalancer external IP is not available, use port-forwarding instead:
-
Check the readiness endpoint:
After the LoadBalancer hostname resolves, an AWS Elastic Load Balancer (ELB) takes about 30 seconds to 2 minutes to register the (already ready) pod as a healthy target. Running
curlon the endpoint once during this window can return a transientcurlexit code (7connection refused,28timeout, or52empty reply) or an ELB-generatedHTTP 502,503, or504. These are expected during target registration. Poll the readiness endpoint with retries until it returnsHTTP 200rather than treating a single failedcurlexecution as a deployment error. -
List the available models:
-
Send a test chat completion request:
Replace the example
modelvalue with the name returned by/v1/models. Do not rely on a mismatched name producing an error: vLLM rejects an unknown model name, while SGLang can serve the loaded model without reporting a mismatch.
Remove the EKS Deployment
To remove the EKS deployment resources when you no longer need them, complete the following steps:
-
Remove the Helm release:
-
Delete the persistent volume claim and namespace:
-
Delete the EKS cluster. For additional options, refer to the AWS documentation.
Deploy on Amazon SageMaker
This guide covers deploying NIM LLM and VLM on Amazon SageMaker using managed real-time inference endpoints. Model artifacts are typically stored in S3, but if your SageMaker endpoint has outbound internet access (for example, through a NAT gateway or public subnet), NIM can also download models directly from NGC or Hugging Face at startup. Refer to Model Storage Options for details.
To deploy NIM LLM and VLM on Amazon SageMaker, complete the following steps.
Native SageMaker Protocol Support
NIM implements the SageMaker BYOC (Bring Your Own Container) protocol natively. When SageMaker mode is active, NIM:
- Listens on port 8080 (the port SageMaker expects).
- Responds to
GET /ping— the health check SageMaker calls before marking an endpointInService. - Accepts
POST /invocations— the inference path SageMaker routes all requests to.
Activation — Set NIM_SAGEMAKER_MODE=1 in the SageMaker model Environment for every real-time endpoint. A standard single-model endpoint can omit SAGEMAKER_MULTI_MODEL, SAGEMAKER_REGION, and SAGEMAKER_BIND_TO_PORT, so auto-detection does not run when those variables are absent and NIM stays on port 8000. Use NIM_SAGEMAKER_MODE=0 only to suppress SageMaker mode.
SageMaker-Injected Environment Variables
The following environment variables are not NIM configuration variables. Their availability depends on the SageMaker endpoint configuration; standard single-model endpoints can omit all three. When they are present, NIM uses them as signals for auto-detection; you do not need to set them yourself.
If any of these variables is detected and NIM_SAGEMAKER_MODE is not explicitly set, NIM enables SageMaker mode automatically. Set NIM_SAGEMAKER_MODE=0 to suppress this behavior.
The request body for POST /invocations is identical to POST /v1/chat/completions — NIM transparently rewrites the path internally.
Prerequisites
Before you start, complete the following prerequisites:
- Create or use an AWS account with permissions to create SageMaker endpoints, ECR repositories, and S3 buckets.
- Obtain an NGC API key if you use an NGC-based NIM image or mirror models to S3.
- Obtain a Hugging Face access token if you download models directly from Hugging Face.
- Install the following tools:
- AWS CLI v2
- Docker (for building and pushing the NIM image to ECR)
Your SageMaker execution role must have access to the S3 bucket where model artifacts are stored, and to ECR if you push the container image to your own registry. For more information about IAM roles, refer to SageMaker execution roles.
Model Storage Options
NIM on SageMaker supports the same model sources as other platforms. S3 is the most common choice, but if the SageMaker endpoint has outbound internet access (for example, through a NAT gateway or public subnet), NIM can also download directly from NGC or Hugging Face at startup.
Authentication to S3 is handled by the SageMaker execution role; you do not need to pass S3 credentials inside the container. However, for any S3-based source (NIM_REPOSITORY_OVERRIDE=s3://... or NIM_MODEL_PATH=s3://...), you must pass AWS_REGION and AWS_DEFAULT_REGION as container environment variables. The in-container AWS SDK requires a region, and SageMaker does not inject one. For Hugging Face direct downloads, pass HF_TOKEN as a container environment variable. For NGC downloads, pass NGC_API_KEY.
Build and Push the NIM Image to ECR
SageMaker runs your container from an image in Amazon ECR. Build your NIM image (or use an NGC image as the base), then push it to an ECR repository in your account.
-
Set the AWS region, repository name, and account ID:
-
Log in to Amazon ECR:
-
Create the ECR repository if it does not already exist:
-
Define the source image and target ECR URI.
${NIM_LLM_MODEL_SPECIFIC_IMAGE}is the NIM image for your model from the Support Matrix for NIMs. The image determines whether the deployment uses vLLM or SGLang. The SageMaker deployment steps in this section apply to either inference engine. -
Pull, tag, and push the image:
Create the SageMaker Model
Create a SageMaker model resource that references your ECR image and sets NIM_SAGEMAKER_MODE=1 plus the environment variables NIM needs at runtime.
Mirror an NGC Model to S3
For an NGC NIM image deployed to a VPC-isolated endpoint (no outbound internet), mirror the model artifacts into your own S3 bucket first, then point NIM at the bucket using NIM_REPOSITORY_OVERRIDE. The image ships a mirror s3 command that reads its manifest and copies the model files to S3.
-
Set the bucket and create it if it does not exist:
In
us-east-1, omit--create-bucket-configurationbecause that region does not accept aLocationConstraint. -
Run the mirror command from the NIM image. This step runs in your own environment rather than under the SageMaker execution role, so the container needs AWS credentials to write to S3: the
-e AWS_ACCESS_KEY_ID,-e AWS_SECRET_ACCESS_KEY, and-e AWS_SESSION_TOKENlines forward credentials from your host shell, which is required when you run this from a workstation or instance that has no attached IAM role. Also passAWS_REGIONandAWS_DEFAULT_REGIONso the in-container AWS SDK can resolve the bucket region: -
Confirm the bucket now has objects:
After the mirror finishes, create the model with NIM_REPOSITORY_OVERRIDE=s3://$S3_BUCKET as shown next.
Use an NGC Model Mirrored to S3
If you have mirrored an NGC model to S3, use the NIM_REPOSITORY_OVERRIDE environment variable to specify the location.
Replace ${YOUR_S3_BUCKET} with your S3 bucket name (for example, my-nim-models) and ${YOUR_NGC_API_KEY} with your NGC API key. Keep NGC_API_KEY secret and never commit it to version control.
-
Set the required environment variables:
-
Create the SageMaker model:
When NIM_REPOSITORY_OVERRIDE (or NIM_MODEL_PATH) points to S3, NIM uses the AWS SDK inside the container to download model artifacts. The SDK requires a region, and SageMaker does not inject one automatically. Pass both AWS_REGION and AWS_DEFAULT_REGION in the container Environment (set to the same region as your S3 bucket and endpoint), or the container fails at startup with no region selected and the endpoint never reaches InService.
NIM_SERVED_MODEL_NAME must match the model name baked into the image at build time (the com.nvidia.nim.model docker label). A mismatch causes a model-profile lookup failure at startup. The same value must be used as the "model" field in the /invocations request body below.
Use a Custom Model in S3
If you are serving your own model from S3, use the NIM_MODEL_PATH environment variable to specify the location.
Replace ${YOUR_S3_BUCKET} with your S3 bucket name (for example, my-nim-models). The bucket must exist in the target region and your SageMaker execution role must have read access to it.
-
Set the required environment variables:
-
Create the SageMaker model:
Use a Hugging Face Model Directly
Use this option to download a gated or public Hugging Face model at endpoint startup. The SageMaker subnet must allow outbound internet access.
-
Find the model page on Hugging Face (for example, Llama-3.1-8B-Instruct). Accept the model’s license before deploying.
-
Set the required environment variables. Replace
${YOUR_HF_TOKEN}with your Hugging Face access token: -
Create the SageMaker model:
Pass HF_TOKEN in the container Environment so NIM can authenticate to Hugging Face for gated models. Also pass AWS_REGION and AWS_DEFAULT_REGION: NIM’s in-container AWS SDK resolves its region from these variables and ignores the SAGEMAKER_REGION value that the SageMaker host agent injects, so omitting them can break any S3 access the runtime performs.
This option requires outbound internet access from the SageMaker endpoint subnet. If your VPC does not have a NAT gateway or internet gateway, the download will fail at startup. For VPC-isolated deployments, use one of the S3-based options instead.
Use the same ENDPOINT_NAME for the model, endpoint config, and endpoint so they are linked.
Create Endpoint Config and Endpoint
Create an endpoint configuration, create the endpoint, and then wait for it to become ready.
-
Set the instance type:
-
Create the endpoint configuration:
On GPU instance families such as
ml.g5, specify a valid SageMaker Inference AMI withInferenceAmiVersion. If you omit this field, SageMaker selects its current default GPU AMI, which may ship an NVIDIA driver (for example, driver 580 inal2023-ami-sagemaker-inference-gpu-4-1) that fails to start the container onml.g5. The endpoint then fails withCannotStartContainerErrorand no CloudWatch log group is created, because the failure happens in the host’s NVIDIA driver and container toolkit before NIM produces any logs. Valid values forml.g5areal2-ami-sagemaker-inference-gpu-3-1(driver 550, CUDA 12.4),al2-ami-sagemaker-inference-gpu-2-1, andal2-ami-sagemaker-inference-gpu-2(driver 535, CUDA 12.2). Refer to Inference AMI versions. -
Create the endpoint:
-
Check the endpoint status until it is
InService(this can take several minutes):
Verify the Deployment
SageMaker calls GET /ping on port 8080 to determine readiness and routes all inference traffic to POST /invocations. Both endpoints are implemented natively by NIM when NIM_SAGEMAKER_MODE=1 is set.
Check Endpoint Status
Wait for the endpoint to reach InService. SageMaker polls GET /ping internally during startup and only marks the endpoint ready when it returns 200:
Expected output when ready:
Run an Inference Request
Send a chat completion request through POST /invocations. The request body is the same OpenAI-compatible JSON as other NIM deployments — NIM rewrites the path to /v1/chat/completions internally:
-
Invoke the endpoint:
-
Format the response:
Expected response shape:
For AWS CLI v2, --body is a blob parameter. Use
--cli-binary-format raw-in-base64-out when sending raw JSON inline,
otherwise the endpoint receives a malformed request body.
POST /invocations is a direct pass-through to /v1/chat/completions. Any valid OpenAI chat completion body works, including streaming ("stream": true).
Some AWS CLI installations do not expose
invoke-endpoint-with-response-stream under aws sagemaker-runtime.
If that subcommand is unavailable, verify non-streaming invoke-endpoint
first and use a newer CLI build or an SDK-based client for streaming tests.
Remove the SageMaker Resources
Delete the SageMaker resources when you no longer need them so you avoid ongoing charges.
To remove the SageMaker resources, complete the following steps:
-
Delete the endpoint:
-
After the endpoint deletion finishes, delete the endpoint configuration:
-
Delete the model:
-
Optional: Remove the ECR image and S3 model data if you no longer need them.
Next Steps
Refer to the following AWS documentation for more information:
- AWS Elastic Kubernetes Service (EKS) Documentation
- AWS SageMaker Documentation
- Model Download — Mirror NGC models to S3 or serve from
NIM_MODEL_PATH - Model Profiles and Selection — Choose a profile for your GPU instance