Easy Jupyter notebook setup on AWS GPU EC2 with machine learning AMI
I chose the least expensive g2.2xlarge EC2 instance type with a GPU and used the One Click Launch option (you will need to specify a key file pem file for the AWS region where you are starting the instance). to have an instance running and available in about a minute. This GPU instance costs $0.65/hour so remember to either stop it (if you want to reuse it later and don't mind paying a small cost of persistent local storage) or terminate it if you don't want to be charged for the 60GB of SSD storage space associated with the EC2.
I am very comfortable working in SSH shells using Emacs, screen, etc. When an instance boots up, the Actions -> Connect menu shows you the temporary public address which you can use to SSH in:
Anaconda is installed so jupyter is also pre-installed and can be started from any directory on your EC2 using:
Alternative to using SSH tunnel:
A nice alternative is to install (on your laptop - no server side installation is required) and use sshuttle. Assuming I have a domain name attached to the sometimes running EC2, I use the following aliases in my bash configuration file:
alias gpu='ssh -i "~/.ssh/key-pair.pem" ec2-user@MYDOMAIN.COM'
alias tun="sshuttle -r ec2-user@MYDOMAIN.COM 0/0 -e 'ssh -i \".ssh/key-pair.pem\"'"
Note: Keeping an Elastic IP Address attached to a EC2 when the EC2 is usually not running will cost you about $3.40/month, but I find having a "permanent" IP address assigned to a domain name is convenient.
Goodies in the AWS machine learning AMI:
There are many examples installed for each of these frameworks. I usually use Keras and I was pleased to see the following examples ready to run:
There are many other examples for the other frameworks TensorFlow, MXNet, Caffe, Caffe2, PyTorch, Theano, CNTK, and Torch.