This document is relevant for: Inf1
PyTorch HuggingFace MarianMT Tutorial#
Overview#
In this tutorial you will compile and deploy the HuggingFace MarianMT model for sequence-to-seqeunce language translation on an Inf1 instance.
To enable faster environment setup, you will run the tutorial on an inf1.6xlarge instance to enable both compilation and deployment (inference) on the same instance.
In a production environment we encourage you to try different instance sizes to optimize to your specific deployment needs.
If you have already launched an Inf1 instance and have Neuron pytorch DLAMI environment ready, tutorial is available as a Jupyter notebook at transformers-marianmt.ipynb and instructions can be viewed at:
Instructions of how to setup Neuron pytorch environment and run the tutorial as a Jupyter notebook are available in the next sections.
Setup The Environment#
Launch an Inf1 instance by following the below steps, please make sure to choose an inf1.6xlarge 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.
When choosing an Amazon Machine Image (AMI) make sure to select Deep Learning AMI with Conda Options. Please note that Neuron Conda environments are supported only in Ubuntu 18 DLAMI and Amazon Linux2 DLAMI, Neuron Conda environments are not supported in Amazon Linux DLAMI.
After launching the instance, follow the instructions in Connect to your instance to connect to the instance
Note
You can also launch the instance from AWS CLI, please see AWS CLI commands to launch inf1 instances.
Run The Tutorial#
After connecting to the instance from the terminal, clone the Neuron Github repository to the EC2 instance and then change the working directory to the tutorial directory:
git clone https://github.com/aws/aws-neuron-sdk.git
cd aws-neuron-sdk/src/examples/pytorch
The Jupyter notebook is available as a file with the name transformers-marianmt.ipynb that you can run from browser:
Running tutorial from browser
First setup and launch the Jupyter notebook on your local browser by following instructions at Jupyter Notebook QuickStart
Open the Jupyter notebook from the menu and follow the instructions
You can also view the Jupyter notebook at:
Clean up your instance/s#
After you’ve finished with the instance/s that you created for this tutorial, you should clean up by terminating the instance/s, please follow instructions at Clean up your instance.
This document is relevant for: Inf1