Skip to main content
SageMaker

SageMaker Python SDK

Latest Version Conda-Forge Version Supported Python Versions Code style: black Documentation Status CI Health

SageMaker Python SDK is an open source library for training and deploying machine learning models on Amazon SageMaker.

With the SDK, you can train and deploy models using popular deep learning frameworks Apache MXNet and TensorFlow. You can also train and deploy models with Amazon algorithms, which are scalable implementations of core machine learning algorithms that are optimized for SageMaker and GPU training. If you have your own algorithms built into SageMaker compatible Docker containers, you can train and host models using these as well.

For detailed documentation, including the API reference, see Read the Docs.

Version Lifecycle

The SageMaker Python SDK follows the AWS SDKs and Tools maintenance policy. Version 3 became generally available on 2025-11-19 and is the actively developed major version. Version 2 is in maintenance mode: it receives critical bug fixes and security updates only, and will not receive new features, API updates, or new region support.

We recommend all users migrate to v3. See the migration guide.

The following table shows the lifecycle phases for version 2 of the SageMaker Python SDK:

Phase

Start Date

End Date

General Availability

2020-08-04

N/A

Maintenance mode

2026-07-06

2027-07-05

End-of-Support

2027-07-06

N/A

  • General Availability – the SDK is fully supported, with regular releases for new services, API updates, and bug and security fixes.

  • Maintenance mode – AWS limits releases to critical bug fixes and security issues only. No new APIs, features, or region support.

  • End-of-Support – the SDK no longer receives updates or releases. Previously published versions remain available on PyPI and the source remains on GitHub.

To pin to v2 during migration: pip install "sagemaker<3". To upgrade to v3: pip install --upgrade sagemaker.

Table of Contents

  1. Version Lifecycle

  2. Installing SageMaker Python SDK

  3. Using the SageMaker Python SDK

  4. Using MXNet

  5. Using TensorFlow

  6. Using Chainer

  7. Using PyTorch

  8. Using Scikit-learn

  9. Using XGBoost

  10. SageMaker Reinforcement Learning Estimators

  11. SageMaker SparkML Serving

  12. Amazon SageMaker Built-in Algorithm Estimators

  13. Using SageMaker AlgorithmEstimators

  14. Consuming SageMaker Model Packages

  15. BYO Docker Containers with SageMaker Estimators

  16. SageMaker Automatic Model Tuning

  17. SageMaker Batch Transform

  18. Secure Training and Inference with VPC

  19. BYO Model

  20. Inference Pipelines

  21. Amazon SageMaker Operators in Apache Airflow

  22. SageMaker Autopilot

  23. Model Monitoring

  24. SageMaker Debugger

  25. SageMaker Processing

Installing the SageMaker Python SDK

The SageMaker Python SDK is built to PyPI and the latest version of the SageMaker Python SDK can be installed with pip as follows

pip install sagemaker==<Latest version from pyPI from https://pypi.org/project/sagemaker/>

You can install from source by cloning this repository and running a pip install command in the root directory of the repository:

git clone https://github.com/aws/sagemaker-python-sdk.git
cd sagemaker-python-sdk
pip install .

Supported Operating Systems

SageMaker Python SDK supports Unix/Linux and Mac.

Supported Python Versions

SageMaker Python SDK is tested on:

  • Python 3.9

  • Python 3.10

  • Python 3.11

  • Python 3.12

Telemetry

The sagemaker library has telemetry enabled to help us better understand user needs, diagnose issues, and deliver new features. This telemetry tracks the usage of various SageMaker functions.

If you prefer to opt out of telemetry, you can easily do so by setting the TelemetryOptOut parameter to true in the SDK defaults configuration. For detailed instructions, please visit Configuring and using defaults with the SageMaker Python SDK.

AWS Permissions

As a managed service, Amazon SageMaker performs operations on your behalf on the AWS hardware that is managed by Amazon SageMaker. Amazon SageMaker can perform only operations that the user permits. You can read more about which permissions are necessary in the AWS Documentation.

The SageMaker Python SDK should not require any additional permissions aside from what is required for using SageMaker. However, if you are using an IAM role with a path in it, you should grant permission for iam:GetRole.

Licensing

SageMaker Python SDK is licensed under the Apache 2.0 License. It is copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. The license is available at: http://aws.amazon.com/apache2.0/

Running tests

SageMaker Python SDK has unit tests and integration tests.

You can install the libraries needed to run the tests by running pip install --upgrade .[test] or, for Zsh users: pip install --upgrade .\[test\]

Unit tests

We run unit tests with tox, which is a program that lets you run unit tests for multiple Python versions, and also make sure the code fits our style guidelines. We run tox with all of our supported Python versions, so to run unit tests with the same configuration we do, you need to have interpreters for those Python versions installed.

To run the unit tests with tox, run:

tox tests/unit

Integration tests

To run the integration tests, the following prerequisites must be met

  1. AWS account credentials are available in the environment for the boto3 client to use.

  2. The AWS account has an IAM role named SageMakerRole. It should have the AmazonSageMakerFullAccess policy attached as well as a policy with the necessary permissions to use Elastic Inference.

  3. To run remote_function tests, dummy ecr repo should be created. It can be created by running -

    aws ecr create-repository --repository-name remote-function-dummy-container

We recommend selectively running just those integration tests you’d like to run. You can filter by individual test function names with:

tox -- -k 'test_i_care_about'

You can also run all of the integration tests by running the following command, which runs them in sequence, which may take a while:

tox -- tests/integ

You can also run them in parallel:

tox -- -n auto tests/integ

Git Hooks

to enable all git hooks in the .githooks directory, run these commands in the repository directory:

find .git/hooks -type l -exec rm {} \;
find .githooks -type f -exec ln -sf ../../{} .git/hooks/ \;

To enable an individual git hook, simply move it from the .githooks/ directory to the .git/hooks/ directory.

Building Sphinx docs

Setup a Python environment, and install the dependencies listed in doc/requirements.txt:

# conda
conda create -n sagemaker python=3.12
conda activate sagemaker
conda install sphinx=5.1.1 sphinx_rtd_theme=0.5.0

# pip
pip install -r doc/requirements.txt

Clone/fork the repo, and install your local version:

pip install --upgrade .

Then cd into the sagemaker-python-sdk/doc directory and run:

make html

You can edit the templates for any of the pages in the docs by editing the .rst files in the doc directory and then running make html again.

Preview the site with a Python web server:

cd _build/html
python -m http.server 8000

View the website by visiting http://localhost:8000

SageMaker SparkML Serving

With SageMaker SparkML Serving, you can now perform predictions against a SparkML Model in SageMaker. In order to host a SparkML model in SageMaker, it should be serialized with MLeap library.

For more information on MLeap, see https://github.com/combust/mleap .

Supported major version of Spark: 3.3 (MLeap version - 0.20.0)

Here is an example on how to create an instance of SparkMLModel class and use deploy() method to create an endpoint which can be used to perform prediction against your trained SparkML Model.

sparkml_model = SparkMLModel(model_data='s3://path/to/model.tar.gz', env={'SAGEMAKER_SPARKML_SCHEMA': schema})
model_name = 'sparkml-model'
endpoint_name = 'sparkml-endpoint'
predictor = sparkml_model.deploy(initial_instance_count=1, instance_type='ml.c4.xlarge', endpoint_name=endpoint_name)

Once the model is deployed, we can invoke the endpoint with a CSV payload like this:

payload = 'field_1,field_2,field_3,field_4,field_5'
predictor.predict(payload)

For more information about the different content-type and Accept formats as well as the structure of the schema that SageMaker SparkML Serving recognizes, please see SageMaker SparkML Serving Container.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sagemaker-2.257.6.tar.gz (1.3 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sagemaker-2.257.6-py3-none-any.whl (1.7 MB view details)

Uploaded Python 3

File details

Details for the file sagemaker-2.257.6.tar.gz.

File metadata

  • Download URL: sagemaker-2.257.6.tar.gz
  • Upload date:
  • Size: 1.3 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for sagemaker-2.257.6.tar.gz
Algorithm Hash digest
SHA256 811db7196574ad30444d59ee4b57bf21c9fbf29f54317319a22f42221f58fdee
MD5 762ebe47207b5455da5f4996f541d7d8
BLAKE2b-256 287f6bdefbdd01aa07b91a898d26c7b983c8d55428c15b10e8491b6b81755975

See more details on using hashes here.

File details

Details for the file sagemaker-2.257.6-py3-none-any.whl.

File metadata

  • Download URL: sagemaker-2.257.6-py3-none-any.whl
  • Upload date:
  • Size: 1.7 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for sagemaker-2.257.6-py3-none-any.whl
Algorithm Hash digest
SHA256 4719aadcaf64554e4c5c5a65f056edac18e2d8e867b4110386300cb955376c3d
MD5 6f58a4802e4af37727165edf84427153
BLAKE2b-256 95fca022a83055e5b4504ddaf4452ed0e579e4cfd468154549ed41866031dfdd

See more details on using hashes here.

Release history Release notifications | RSS feed

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page