SageMaker PyTorch Estimators and Models
With PyTorch Estimators and Models, you can train and host PyTorch models on Amazon SageMaker.
Supported versions of PyTorch:
We recommend that you use the latest supported version, because that's where we focus most of our development efforts.
You can visit the PyTorch repository at https://github.com/pytorch/pytorch.
For information about using PyTorch with the SageMaker Python SDK, see https://sagemaker.readthedocs.io/en/stable/using_pytorch.html.
PyTorch Training Examples
Amazon provides several example Jupyter notebooks that demonstrate end-to-end training on Amazon SageMaker using PyTorch. Please refer to:
These are also available in SageMaker Notebook Instance hosted Jupyter notebooks under the sample notebooks folder.
SageMaker PyTorch Docker Containers
When training and deploying training scripts, SageMaker runs your Python script in a Docker container with several libraries installed. When creating the Estimator and calling deploy to create the SageMaker Endpoint, you can control the environment your script runs in.
SageMaker runs PyTorch Estimator scripts in either Python 2 or Python 3. You can select the Python version by
py_version keyword arg to the PyTorch Estimator constructor. Setting this to py3 (the default) will cause your
training script to be run on Python 3.5. Setting this to py2 will cause your training script to be run on Python 2.7
This Python version applies to both the Training Job, created by fit, and the Endpoint, created by deploy.
The PyTorch Docker images have the following dependencies installed:
|Dependencies||pytorch 0.4.0||pytorch 1.0.0||pytorch 1.1.0|
|CUDA (GPU image only)||9.0||9.0||10.1|
|Python||2.7 or 3.5||2.7 or 3.6||2.7 or 3.6|
The Docker images extend Ubuntu 16.04.
If you need to install other dependencies you can put them into requirements.txt file and put it in the source directory
source_dir) you provide to the PyTorch Estimator.
You can select version of PyTorch by passing a
framework_version keyword arg to the PyTorch Estimator constructor.
Currently supported versions are listed in the above table. You can also set
framework_version to only specify major and
minor version, which will cause your training script to be run on the latest supported patch version of that minor
Alternatively, you can build your own image by following the instructions in the SageMaker Chainer containers
repository, and passing
image_name to the Chainer Estimator constructor.
You can visit the SageMaker PyTorch containers repository.