tlanigan
tlanigan

Reputation: 959

How do I invoke a Amazon SageMaker endpoint with the Python SDK

I'm trying to use this very simple command:

import boto3 client = boto3.client('sagemaker-runtime')

listed in the documentation

but i'm getting this error:

UnknownServiceError: Unknown service: 'sagemaker-runtime'. Valid service names are: acm, etc..

My goal is to be able to invoke the endpoint that I've created in Amazon SageMaker.

I'm doing this from a Jupyter notebook in Sagemaker, so I feel like this should work no problem. How do I get it to run here, and outside of the Sagemaker environment?

Upvotes: 2

Views: 4408

Answers (3)

CHOI
CHOI

Reputation: 162

In case you use Jupyter Notebook, create cell at the top and execute below.

!pip install boto3 --upgrade

In my case, to upgrade boto3 in terminal didn't work.

Upvotes: 0

Michael Frasco
Michael Frasco

Reputation: 414

The documentation is incorrect. This is how you get the client with the SageMaker Python SDK.

import boto3
client = boto3.client('runtime.sagemaker')

I've done this successfully. And, as John said, be sure to update your versions of boto3 and awscli.

Upvotes: 4

John Rotenstein
John Rotenstein

Reputation: 269091

Amazon SageMaker is a very new service (December 2017).

You will need to update your boto library to use it:

sudo pip install boto --upgrade
sudo pip install boto3 --upgrade
sudo pip install awscli --upgrade

Upvotes: 5

Related Questions