This document is relevant for: Inf1

Get Started with Apache MXNet (Incubating) Neuron#

This page provide links that will assist you to quickly start with MXNet Neuron (supporting inference only).

Launch Inf1 Instance
  • Please follow the instructions at launch an Amazon EC2 Instance to Launch an Inf1 instance, when choosing the instance type at the EC2 console. Please make sure to select the correct instance type. To get more information about Inf1 instances sizes and pricing see Inf1 web page.

  • Select your Amazon Machine Image (AMI) of choice, please note that Neuron support Amazon Linux 2 AMI(HVM) - Kernel 5.10

  • 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

################################################################################################################
# Remove older versions of Neuron
################################################################################################################
sudo yum remove aws-neuron-dkms -y
sudo yum remove aws-neuronx-dkms -y
sudo yum remove aws-neuron-tools -y
sudo yum remove aws-neuronx-tools -y

################################################################################################################
# To install or update to Neuron versions 2.5 and newer from previous releases:
# - DO NOT skip 'aws-neuronx-dkms' install or upgrade step, you MUST install or upgrade to latest Neuron driver
################################################################################################################

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

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

####################################################################################
# Warning: If Linux kernel is updated as a result of OS package update
#          Neuron driver (aws-neuronx-dkms) should be re-installed after reboot
####################################################################################

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

export PATH=/opt/aws/neuron/bin:$PATH
Install MXNet Neuron
# Install Python venv and activate Python virtual environment to install
# Neuron pip packages.
sudo yum install -y python3.7-venv gcc-c++
python3.7 -m venv mxnet_venv
source mxnet_venv/bin/activate
pip install -U pip


# Install Jupyter notebook kernel
pip install ipykernel
python3.7 -m ipykernel install --user --name mxnet_venv --display-name "Python (Neuron MXNet)"
pip install jupyter notebook
pip install environment_kernels


# Set Pip repository  to point to the Neuron repository
pip config set global.extra-index-url https://pip.repos.neuron.amazonaws.com

#Install Neuron MXNet
wget https://aws-mx-pypi.s3.us-west-2.amazonaws.com/1.8.0/aws_mx-1.8.0.2-py2.py3-none-manylinux2014_x86_64.whl
pip install aws_mx-1.8.0.2-py2.py3-none-manylinux2014_x86_64.whl
pip install mx_neuron neuron-cc
Run Tutorial
Visit MXNet Neuron section for more

This document is relevant for: Inf1