Amazon SageMaker
Deploy Kumo Tabular NIM as an Amazon SageMaker AI endpoint and send a prediction using Python. This recipe builds a derived image that adds SageMaker health and prediction routes to the original NIM. It runs one model on one GPU per endpoint.
Before you start
- A Bash shell, Docker with the Buildx plugin capable of building
linux/amd64images, AWS CLI v2, Python 3, and sufficient Docker storage to pull and build the NIM image. The build machine does not need a GPU or an x86-64 CPU. Docker Desktop supports cross-platform builds on macOS and Windows. On Windows, run these Bash commands in WSL2 with Docker Desktop integration enabled. - An NGC account and an NGC personal API key with access to the model image.
- An AWS identity with permission to manage SageMaker endpoints and ECR images, invoke the endpoint, and pass a SageMaker execution role using
iam:PassRole. - An existing SageMaker execution role that trusts
sagemaker.amazonaws.comand can pull your ECR image and write CloudWatch logs. - SageMaker endpoint quota and available capacity for one
ml.g6e.2xlargeinstance in your Region. This instance has one 48 GB L40S GPU.
1. Sign in and choose names
Sign in using your organization’s AWS CLI authentication method.
Replace the execution role ARN below with the role supplied by your administrator.
Choose a new endpoint name for each deployment.
Run the shell commands in the same terminal.
For a named AWS profile, set export AWS_PROFILE=YOUR_PROFILE first.
Check that the AWS command shows the intended account. Paste your NGC API key at Docker’s password prompt.
2. Build the SageMaker image
Create an empty directory and save the following three files in it.
The proxy forwards SageMaker health checks to /v1/health/ready and prediction requests to /v1/predictions.
The original NIM and proxy run inside a single container.
Dockerfile
Caddyfile
start.sh
Build the image and upload it to Amazon ECR.
If the ECR repository already exists, omit create-repository below.
The build explicitly publishes a Docker image manifest compatible with SageMaker.
3. Create the endpoint
Register the image and create one instance:
The waiter returns successfully when the endpoint is InService.
Image download and model initialization can take several minutes.
If the waiter times out, inspect the endpoint before retrying or deleting it:
For quota or capacity failures, request quota or retry when the instance is available.
For container startup errors, inspect CloudWatch logs under /aws/sagemaker/Endpoints/<endpoint-name>.
4. Make a prediction
Create a Python environment and install the AWS SDK.
The crt extra enables AWS console login credentials, including aws login:
Save the following synthetic request as request.json.
It supplies four labeled context rows and predicts a label for one new row.
Example request.json
Save this as predict.py and run python predict.py in the same terminal:
The response contains a predictions array with one prediction and class probabilities.
This small example verifies inference, not model accuracy on your data.
AWS credentials authenticate the request; an NGC key is not used for inference.
This recipe supports complete prediction requests through boto3.
It does not expose model discovery or cached-session APIs.
The existing SDM client HTTP examples cannot connect to this endpoint by substituting a SageMaker URL.
For data preparation and modeling examples, see the public Kumo Tabular notebook, which uses a direct NIM HTTP connection.
Synchronous requests and responses must each fit within 6 MiB, and inference must finish within 60 seconds. See SageMaker invocation limits.
5. Delete the deployment
Endpoints incur charges while running, including when idle. Delete this endpoint and its configuration when finished:
The execution role, ECR repository, CloudWatch logs, and local image remain available for reuse. Remove them separately when no longer needed.