Update to latest PyTorch Neuron (torch-neuron) — AWS Neuron Documentation (original) (raw)

Contents

This document is relevant for: Inf1

Update to latest PyTorch Neuron (torch-neuron)#

Note

Table of contents

Develop on AWS ML accelerator instance#

The simplest environment setup for model development installs all Neuron SDK components directly on an AWS ML accelerator instance: the Neuron framework extensions, compiler, runtime, and tools. This will allow you to compile, execute, and performance tune your model, all in the same instance. This is the recommended workflow when first starting to work with Neuron device or when optimizing a model.

Note: If you are using a regular U18, U20, or AL2 AMI, follow the same setup instructions as the Base DLAMIs respectively.

Important

For successful installation or update to next releases (Neuron 1.20.0 and newer):

PyTorch 1.13.1

Ubuntu 20 DLAMI Base

Note

For a successful installation or update, execute each line of the instructions below separately or copy the contents of the code block into a script file and source its contents.

Activate Python venv

source aws_neuron_venv_pytorch_inf1/bin/activate

Install Jupyter notebook kernel

pip install ipykernel python3.9 -m ipykernel install --user --name aws_neuron_venv_pytorch_inf1 --display-name "Python (torch-neuron)" pip install jupyter notebook pip install environment_kernels

Set pip repository pointing to the Neuron repository

python -m pip config set global.extra-index-url https://pip.repos.neuron.amazonaws.com

Update PyTorch Neuron

python -m pip install --upgrade torch-neuron neuron-cc[tensorflow] "protobuf" torchvision

Amazon Linux 2 DLAMI Base

Note

For a successful installation or update, execute each line of the instructions below separately or copy the contents of the code block into a script file and source its contents.

Activate Python venv

source aws_neuron_venv_pytorch_inf1/bin/activate

Install Jupyter notebook kernel

pip install ipykernel python3.9 -m ipykernel install --user --name aws_neuron_venv_pytorch_inf1 --display-name "Python (torch-neuron)" pip install jupyter notebook pip install environment_kernels

Set pip repository pointing to the Neuron repository

python -m pip config set global.extra-index-url https://pip.repos.neuron.amazonaws.com

Update PyTorch Neuron

python -m pip install --upgrade torch-neuron neuron-cc[tensorflow] "protobuf" torchvision

Compile on compute instance#

If model compilation occurs outside the model deployment environment, you can install only the Neuron framework extensions and the compiler on any compute instance. This setup is helpful when compiling large complex models that require large amount of memory or during a CICD process where models are compiled in a separate step, prior to deployment.

PyTorch 1.13.1

Ubuntu 20 DLAMI Base

Note

For a successful installation or update, execute each line of the instructions below separately or copy the contents of the code block into a script file and source its contents.

Activate Python venv

source aws_neuron_venv_pytorch_inf1/bin/activate

Install Jupyter notebook kernel

pip install ipykernel python3.9 -m ipykernel install --user --name aws_neuron_venv_pytorch_inf1 --display-name "Python (torch-neuron)" pip install jupyter notebook pip install environment_kernels

Set pip repository pointing to the Neuron repository

python -m pip config set global.extra-index-url https://pip.repos.neuron.amazonaws.com

Update PyTorch Neuron

python -m pip install --upgrade torch-neuron neuron-cc[tensorflow] "protobuf" torchvision

Amazon Linux 2 DLAMI Base

Note

For a successful installation or update, execute each line of the instructions below separately or copy the contents of the code block into a script file and source its contents.

Activate Python venv

source aws_neuron_venv_pytorch_inf1/bin/activate

Install Jupyter notebook kernel

pip install ipykernel python3.9 -m ipykernel install --user --name aws_neuron_venv_pytorch_inf1 --display-name "Python (torch-neuron)" pip install jupyter notebook pip install environment_kernels

Set pip repository pointing to the Neuron repository

python -m pip config set global.extra-index-url https://pip.repos.neuron.amazonaws.com

Update PyTorch Neuron

python -m pip install --upgrade torch-neuron neuron-cc[tensorflow] "protobuf" torchvision

Deploy on AWS ML accelerator instance#

During deployment it can be beneficial to reduce the number of components installed in the system. For use-cases where only inference is necessary (compilation is already complete), only the framework and runtime should be installed.

Note: If you are using a regular U18, U20, or AL2 AMI, follow the same setup instructions as the Base DLAMIs respectively.

Important

For successful installation or update to next releases (Neuron 1.20.0 and newer):

PyTorch 1.13.1

Ubuntu 20 DLAMI Base

Note

For a successful installation or update, execute each line of the instructions below separately or copy the contents of the code block into a script file and source its contents.

Activate Python venv

source aws_neuron_venv_pytorch_inf1/bin/activate

Install Jupyter notebook kernel

pip install ipykernel python3.9 -m ipykernel install --user --name aws_neuron_venv_pytorch_inf1 --display-name "Python (torch-neuron)" pip install jupyter notebook pip install environment_kernels

Set pip repository pointing to the Neuron repository

python -m pip config set global.extra-index-url https://pip.repos.neuron.amazonaws.com

Update PyTorch Neuron

python -m pip install --upgrade torch-neuron torchvision

Amazon Linux 2 DLAMI Base

Note

For a successful installation or update, execute each line of the instructions below separately or copy the contents of the code block into a script file and source its contents.

Activate Python venv

source aws_neuron_venv_pytorch_inf1/bin/activate

Install Jupyter notebook kernel

pip install ipykernel python3.9 -m ipykernel install --user --name aws_neuron_venv_pytorch_inf1 --display-name "Python (torch-neuron)" pip install jupyter notebook pip install environment_kernels

Set pip repository pointing to the Neuron repository

python -m pip config set global.extra-index-url https://pip.repos.neuron.amazonaws.com

Update PyTorch Neuron

python -m pip install --upgrade torch-neuron torchvision

This document is relevant for: Inf1