This document is relevant for: Inf2, Trn1, Trn1n

Select a Different Framework or Platform for Setup

Tensorflow Neuron (“tensorflow-neuronx”) Setup on Amazon Linux 2 with DLAMI Base#

Note

Please make sure to upgrade from python 3.7 to python 3.8 to use Neuron SDK on Amazon Linux 2. Starting from Neuron Release 2.13, python 3.7 is no longer supported as mentioned here. Also, we do not have support for torch-neuronx 2.1.2 on Amaznon Linux 2.

Get Started with Latest Release of Tensorflow Neuron (tensorflow-neuronx)#

This section provide links that will assist you to quickly start with a fresh installation of TensorFlow Setup Guide for Inf2 & Trn1.

Launch the Instance
  • Please follow the instructions at launch an Amazon EC2 Instance to launch an instance. When choosing the instance type at the EC2 console. please make sure to select the correct instance type.

  • To get more information about instance sizes and pricing see: Trn1 web page, Inf2 web page

  • Check for the latest version of the DLAMI Base AMI and copy the AMI name that starts with “Deep Learning Base Neuron AMI (Amazon Linux 2) <latest_date>” from “AMI Name:” section

  • Search for the copied AMI name in the AMI Search , you should see a matching AMI with the AMI name in Community AMIs. Select the AMI and use it to launch the instance.

  • When launching a Trn1, please adjust your primary EBS volume size to a minimum of 512GB.

  • After launching the instance, follow the instructions in Connect to your instance to connect to the instance

Install Drivers and Tools
# Configure Linux for Neuron repository updates
sudo tee /etc/yum.repos.d/neuron.repo > /dev/null <<EOF
[neuron]
name=Neuron YUM Repository
baseurl=https://yum.repos.neuron.amazonaws.com
enabled=1
metadata_expire=0
EOF
sudo rpm --import https://yum.repos.neuron.amazonaws.com/GPG-PUB-KEY-AMAZON-AWS-NEURON.PUB

# Update OS packages 
sudo yum update -y

# Install OS headers 
sudo yum install kernel-devel-$(uname -r) kernel-headers-$(uname -r) -y

# Install git 
sudo yum install git -y

# install Neuron Driver
sudo yum install aws-neuronx-dkms-2.* -y

# Install Neuron Runtime 
sudo yum install aws-neuronx-collectives-2.* -y
sudo yum install aws-neuronx-runtime-lib-2.* -y

# Install Neuron Tools 
sudo yum install aws-neuronx-tools-2.* -y

# Add PATH
export PATH=/opt/aws/neuron/bin:$PATH
Install EFA (Applicable only for Trn1\Trn1n)
# Install EFA Driver (only required for multi-instance training)
curl -O https://efa-installer.amazonaws.com/aws-efa-installer-latest.tar.gz 
wget https://efa-installer.amazonaws.com/aws-efa-installer.key && gpg --import aws-efa-installer.key 
cat aws-efa-installer.key | gpg --fingerprint 
wget https://efa-installer.amazonaws.com/aws-efa-installer-latest.tar.gz.sig && gpg --verify ./aws-efa-installer-latest.tar.gz.sig 
tar -xvf aws-efa-installer-latest.tar.gz 
cd aws-efa-installer && sudo bash efa_installer.sh --yes 
cd 
sudo rm -rf aws-efa-installer-latest.tar.gz aws-efa-installer
Install TensorFlow Neuron (tensorflow-neuronx)
# Install Python venv 
sudo yum install -y python3.8-venv gcc-c++ 

# Create Python venv
python3.8 -m venv aws_neuron_venv_tensorflow 

# Activate Python venv 
source aws_neuron_venv_tensorflow/bin/activate 
python -m pip install -U pip 

# Install Jupyter notebook kernel
pip install ipykernel 
python3.8 -m ipykernel install --user --name aws_neuron_venv_tensorflow --display-name "Python (tensorflow-neuronx)"
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

# Install wget, awscli 
python -m pip install wget 
python -m pip install awscli 

# Install Neuron Compiler and Framework
python -m pip install neuronx-cc==2.* tensorflow-neuronx
Visit TensorFlow Neuron(tensorflow-neuronx) for Inference section

Update to latest TensorFlow Neuron (tensorflow-neuronx)#

If you already have a previous Neuron release installed, this section provide links that will assist you to update to latest Neuron release.

Note

  • Instructions in this page only apply to setting up Neuron components on Linux host running Ubuntu or Amazon Linux AMI.

  • When launching a Trn1, please adjust your primary EBS volume size to a minimum of 512GB.

# Activate Python venv 
source aws_neuron_venv_tensorflow/bin/activate 

# Install Jupyter notebook kernel
pip install ipykernel 
python3.8 -m ipykernel install --user --name aws_neuron_venv_tensorflow --display-name "Python (tensorflow-neuronx)"
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

# Install wget, awscli 
python -m pip install wget 
python -m pip install awscli 

# Update Neuron Compiler and Framework
python -m pip install --upgrade neuronx-cc==2.* tensorflow-neuronx

Note

  • Instructions in this page only apply to setting up Neuron components on Linux host running Ubuntu or Amazon Linux AMI.

  • When launching a Trn1, please adjust your primary EBS volume size to a minimum of 512GB.

# Activate Python venv 
source aws_neuron_venv_tensorflow/bin/activate 

# Install Jupyter notebook kernel
pip install ipykernel 
python3.8 -m ipykernel install --user --name aws_neuron_venv_tensorflow --display-name "Python (tensorflow-neuronx)"
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

# Install wget, awscli 
python -m pip install wget 
python -m pip install awscli 

# Update Neuron Compiler and Framework
python -m pip install --upgrade neuronx-cc==2.* tensorflow-neuronx==2.9.3.2.1.0

Note

  • Instructions in this page only apply to setting up Neuron components on Linux host running Ubuntu or Amazon Linux AMI.

  • When launching a Trn1, please adjust your primary EBS volume size to a minimum of 512GB.

# Activate Python venv 
source aws_neuron_venv_tensorflow/bin/activate 

# Install Jupyter notebook kernel
pip install ipykernel 
python3.8 -m ipykernel install --user --name aws_neuron_venv_tensorflow --display-name "Python (tensorflow-neuronx)"
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

# Install wget, awscli 
python -m pip install wget 
python -m pip install awscli 

# Update Neuron Compiler and Framework
python -m pip install --upgrade neuronx-cc==2.* tensorflow-neuronx==2.8.4.2.1.0

Install Previous TensorFlow Neuron Releases for Amazon Linux (tensorflow-neuronx)#

This section will assist you to install previous Neuron releases.

# Install Python venv 
sudo yum install -y python3.8-venv gcc-c++ 

# Create Python venv
python3.8 -m venv aws_neuron_venv_tensorflow 

# Activate Python venv 
source aws_neuron_venv_tensorflow/bin/activate 
python -m pip install -U pip 

# Install Jupyter notebook kernel
pip install ipykernel 
python3.8 -m ipykernel install --user --name aws_neuron_venv_tensorflow --display-name "Python (tensorflow-neuronx)"
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

# Install wget, awscli 
python -m pip install wget 
python -m pip install awscli 

# Install Neuron Compiler and Framework
python -m pip install neuronx-cc==2.12.68.0 tensorflow-neuronx==2.10.1.2.1.0
# Install Python venv 
sudo yum install -y python3.8-venv gcc-c++ 

# Create Python venv
python3.8 -m venv aws_neuron_venv_tensorflow 

# Activate Python venv 
source aws_neuron_venv_tensorflow/bin/activate 
python -m pip install -U pip 

# Install Jupyter notebook kernel
pip install ipykernel 
python3.8 -m ipykernel install --user --name aws_neuron_venv_tensorflow --display-name "Python (tensorflow-neuronx)"
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

# Install wget, awscli 
python -m pip install wget 
python -m pip install awscli 

# Install Neuron Compiler and Framework
python -m pip install neuronx-cc==2.12.54.0 tensorflow-neuronx==2.10.1.2.1.0
# Install Python venv 
sudo yum install -y python3.8-venv gcc-c++ 

# Create Python venv
python3.8 -m venv aws_neuron_venv_tensorflow 

# Activate Python venv 
source aws_neuron_venv_tensorflow/bin/activate 
python -m pip install -U pip 

# Install Jupyter notebook kernel
pip install ipykernel 
python3.8 -m ipykernel install --user --name aws_neuron_venv_tensorflow --display-name "Python (tensorflow-neuronx)"
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

# Install wget, awscli 
python -m pip install wget 
python -m pip install awscli 

# Install Neuron Compiler and Framework
python -m pip install neuronx-cc==2.11.0.34 tensorflow-neuronx==2.10.1.2.1.0

This document is relevant for: Inf2, Trn1, Trn1n