How to use Amazon Web Services
Should I use Amazon’s cloud service for my homework?
In Problem Set 5, you are going to use Google’s deep learning framework TensorFlow. You are free to install TensorFlow on your local computer and do your work there. We are also providing the option to use Amazon EC2 instances in the cloud. This is not strictly necessary, but there are several incentives to do this:
- We have configured Amazon Machine Images (AMIs) for your use, which should obviate the need to install TensorFlow, Python, Julia, etc.
- Once you have developed your code, you may want to run it run it on a GPU so it’s faster. If you do not have an NVIDIA GPU in your local computer, you can access one through EC2. For example, you can use the
p2.xlarge
instance which is half a K80 GPU. - You may want experience in using cloud services, and Amazon is giving $100 free credit for you to learn.
How to sign up for Amazon Web Services (AWS)
- Create an AWS account and claim $100 free credit. Note that you will have to provide your own credit card, which will be charged if you use up the $100 free credit. (If this worries you a lot, then perhaps you should stick with your local computer.) Therefore cost control is important, and tips about it are given in a later section.
- AWS Student Onboarding
- Note: AWS Account ID can be found at AWS Billing Console
- Create a key pair. You should store your private key in a
.pem
file somewhere on your computer. You will need it, for example, if you need to establish anssh
connection to an EC2 instance.
Basic information about costs
A virtual machine running in Amazon’s cloud is called an instance. EC2 offers a bewildering number of instance types. The more powerful the instance, the higher the price. New AWS accounts receive free tier access for 12 months, which means that the weakest instances are essentially free. However, these may not have enough RAM for Problem Set 5. You will probably want to use at least t2.medium
or t2.large
, which cost less than 10 cents per hour. A GPU instance like p2.xlarge
costs closer to one dollar per hour. Note that the time unit for charges is one hour; if you use 10 minutes you are still charged for the full hour.
Run TensorFlow in the cloud from a Jupyter notebook
We have remixed the Amazon deep learning AMI to add Julia support for TensorFlow.
- Launch the remixed AMI. The
t2.medium
instance should be sufficiently powerful to start, and costs less than 10 cents per hour. Later on, you may want to use the more expensivep2.xlarge
instance. (That’s the cheapestp2
instance, at less than one dollar per hour.) - Follow Amazon’s instructions for its original deep learning AMI to set up communication with your instance through an IJulia notebook.
- You can ignore the “security group” instructions if you are lazy. If the instance will be active for a short time, it’s unlikely that someone will break into it.
- Once the Jupyter dashboard is open, you can ignore the final Amazon instructions about MXNet and switch to the instructions in Problem Set 5.
- Select
New > Terminal
if you want to interact with a shell. This will be helpful when yougit clone
the sample code for the homework assignment.
Another AMI not requiring ssh key but only for Python
If you don’t want to deal with ssh keys, this AMI offers a slightly less secure but slightly easier to use option for Python only.
- Launch Bitfusion AMI
- Make sure not to choose an expensive instance type if you don’t need it.
t2.medium
should be sufficient to start. - After launching it may take up to 5 minutes before the Jupyter notebook is ready
- Make sure not to choose an expensive instance type if you don’t need it.
- Follow the Bitfusion instructions to connect with your instance through a Python/Jupyter notebook.
- Select
New > Terminal
if you want to interact with a shell. This will be helpful when yougit clone
the sample code for the homework assignment.
Cost control
There is no way to automatically limit your costs in AWS.
Costs incurred above the $100 credit are automatically charged to your registered credit card!
Here are some tips to keep you under budget!
- STOP Your instance when you’re not using them
- Do NOT Terminate, you will lose all your work.
- Start them again when you want to work again. Warning: IP address could change after restart!
- TERMINATE only when all your data has been migrated out of the instance / you are finished with the assignment.
- Use Billing Alarms to warn you when you are close to using up all your $100 credit
- Create an Idle alarm to warn you if you forgot to stop the instance
- Select instance and create alarm
- Create a topic to send yourself an email
- Set CPU Utilization level (Note: you can also automatically Stop Instance as well)