Get started with Inferentia and Trainium on EC2 using the Hugging Face Neuron Deep Learning Amazon Machine Image (AMI). A short walkthrough of how to deploy an EC2 image with all the Neuron drivers and libraries already installed.
If you are getting started with AWS Inferentia or AWS Trainium, an easy way to deploy an EC2 instance is using an existing Amazon Machine Image (AMI) that has all the libraries and drivers pre-installed.
This article walks through how to deploy an EC2 instance using the Hugging Face Neuron Deep Learning AMI.
-
First, decide what region(s) to deploy in. See this article for a list of regions that support Inferentia or Trainium instances. If you don't have any existing infrastructure or other requirements, consider us-east-1 or us-west-2 for lower prices.
-
Next, make sure that you have increased your service quota for Inferentia or Trainium for that region (see this article for details). (you can request quota for multiple regions without incurring any extra charges)
-
Now you should be ready to launch an EC2 instance. There are screen shots below, but your console may look slightly different. For more details on deploying an EC2 instance in general here.
-
The most important step is in the Application and OS Images (Amazon Machine Image) section. Enter "Neuron" in the catalog search bar and hit Enter.

-
You will see the images created by Amazon, but to find the Hugging Face version, click on "AWS Marketplace AMIs".

-
You should click "Select" and "Subscribe now". It may look like there is a cost for the image, but the cost shown is only the cost for the instance. There is no charge for the use of the AMI.
-
Select your instance type. If you are testing on a single core (for example, tracing or programing the Neuron Kernel Interface), consider an inf2.xlarge (least expensive). If you are running out of system RAM, consider a trn1.2xlarge or inf2.8xlarge. They all come with a single Neuron device with two cores but vary in the cost, amount of CPU cores, and CPU RAM.
-
Create a Key pair if you don't have one (and save the private key!)
-
Create a security group to allow incoming SSH traffic (if you don't have one) (if you will be accessing your instance through AWS System Manager or a cloud desktop, you may not need this)
-
Change your storage if you are loading very large or very small models.
-
Launch the instance! Then you can click on the instance details to find the external IP address. If you need help connecting with SSH, see the instructions here.
-
When you connect, you should see an announcement that details information about the environment and other Python virtual environments that are available (pytorch 2.1 is the default)