Monday, March 20, 2017

AWS Elastic Compute Cloud

Amazon Elastic Compute Cloud (EC2) is the Amazon Web Service you use to create and run virtual machines in the cloud. Each virtual machine is called instance.
AMI (Amazon Machine Images) contains all the environment files and drivers for you to train on a GPU. It has cuDNN, TensorFlow with GPU support, Python 3, and all the other packages required for this course.

launch an instance

In other words, create a virtual machine on the cloud. AMIs are prebuilt virtual environment. Community AMIs are free. Marketplace AMIs are charged or free to try. I come to realize the target customers are power-hungry, storage-hungry users.
  1. create AWS account
  2. EC2 Dashboard -> create instance -> launch instance -> Choose an Amazon Machine Image (AMI) -> Community AMIs -> search for “udacity-dl”
  3. filter by “GPU instances” -> g2.2xlarge -> Review and launch
  4. edit storage -> 32 GB. This is the space to hold the datasets.
  5. edit security groups -> create a new security group -> Security group name: jupyter -> Add rule: Custom TCP rule, Port Range: 8888, Anywhere: Source -> Review and launch
  6. launch -> launch without a key pair
  7. Note on the EC2 On-Demand Pricing page. For US West(Oregon), the base price for g2.2xlarge is $0.65 per hour. The running instances will be charged until you click “stop” (shutdown). The storage will be charged until you click “terminate” (delete).
  8. set AWS Billing Alarms and budget to avoid high-piling bills due to forgetting to turn off the instances.
  9. GPU EC2 limit increase request takes 2 or 3 days, which is painfully slow.
  10. Alternatively, I try to use “Free tier” instance which is specified here: Amazon Linux AMI 2016.09.1 (HVM), SSD Volume Type - ami-0b33d91d -> t2.micro (free tier eligible) -> launch -> create a new key pair -> MyKeyPair -> Download KeyPair. It is recommended that the keypair is stored in the .ssh folder by mv ~/Downloads/MyKeyPair.pem ~/.ssh/MyKeyPair.pem
  11. After launching your instance, it’s time to connect to it. Restrict permissions to your private SSH key by chmod 400 ~/.ssh/mykeypair.pem
  12. use ssh to connect: ssh -i ~/.ssh/MyKeyPair.pem ec2-user@{IPv4 Public IP}
  13. this virtual machine is too simple to do useful tasks. It only preinstalls simple things: python 2.7,pip 6.1.1. And it seems that you are not allowed to install new things or upgrade. I don’t find it particularly useful so far.
If the udacity AMI instance can be successfully created and initialized, the connection will be ssh udacity@{IPv4 Public IP}. Default password is “udacity”. Test the instance by:
git clone
cd deep-learning/intro-to-tensorflow/
source activate dl
jupyter notebook

Launch a WordPress Website

  1. EC2 dashboard -> launch instance -> AWS marketplace, search”wordpress” -> WordPress powered by Bitnami -> continue
  2. t2.micro(free tier eligible) -> Next -> Next, Add Tag -> Key: Name, Value: WordPress -> next -> review and launch -> launch -> launch without a key pair
  3. view instance. Wait until “Instance State: running, Status Checks: checks passed. Then copy and paste “IPv4 Public IP” to a new browser window to see the magic. Permalink:
  4. Go back to instances. Actions-> Instance settings -> get system log. Scroll down and find the password: 6LyeomW7L1F3
  5. Go back to WordPress site and log in by username: user, and password. Customize the site as you wish.

Register a Domain name

  1. Click here to open the Elastic IP part of the EC2 console in a new window and click “Allocate New Address”
  2. Elastic IP address (EIP) will be charged for $ 0.005/hr unless it is connected to running instances.
  3. Actions-> Associate Address -> Instance: your instance
  4. buy a domain name. I already bought one at google domain, which is equivalent to Amazone Route 53.
  5. The trick is that I not only need to go to google domain to redirect my domain name to the EIP, but also go to Blogspot setting page to check all the redirecting.