General: GPUs on AWS

GPUs on the Amazon Web Services (AWS)

This page describes how to quickly and cheaply run your own server with a GPU.

Starting an own server on the Amazon Web Services. [PPT WITH SCREEN SHOTS]


There are two ways to create a server on AWS: on-demand and through bidding (they are called spot instances).

- Spot instance costs are much smaller and of course might vary, the price is around 5 times lower than on-demand, so this one is suggested for playing with GPU. In the last months the price was below $4 per day.

- the drawback is that in theory Amazon might stop a spot instance if they don't have free ones for on-demand, see the pricing history for a g2.2xlarge server (you should keep a copy of your code).

1. Open an AWS account (free tier) and provide your credit/debit card number. Some basic services are free (account, storage, basic server). We will pay only for GPU server then.

2. Sign in to the AWS console page > EC2. In Instances>Spot Requests click 'Request Spot Instances'.

3. Now let's choose an OS and server: various operating systems are available, and servers with various capabilities, but we will choose Ubuntu with Theano and CUDA drivers pre-installed (hereafter "Theano image"), and a GPU server.

In the top-right corner, you must choose "N. California" region if it is not yet selected, because the Theano image is there.

Now we will find the Theano image. Click 'Community AMIs' on the left. In the search field type either:

==> 'theano', press enter, select 'Theano - CUDA 7'. This will make a generic installation with no Data and sample code.

==> 'hackathon', press enter, select "pure hackathon - ami-196c9c5d", This will reproduce the setup of the Round 1 hackathon at ICML and bootcamp at Stanford.

Click next, choose g2.2xlarge instance (a GPU one), and click next.

4. The only thing to change in the form is the maximum price $: put 0.2 as max price.

Click review and launch, later click launch.

There should be 2 warnings:

1) Warning 'improve your instances security' means that if you have a key you can login from everywhere, so you can limit IP addresses later if you need an extra protection (see AWS manual) or if your data will be confidential, etc.

2) Because we selected a paid GPU, it will also say that it is not included in the free tier.

To login, we need to select a key pair. If you use AWS for the first time, you will create a new one just now, then 'create spot instances'.

5. It will take around 5 minutes for starting the server (instance). Go to instances>instances, you can see the current state of your server, wait until it is 'running'. Click on an instance, you can see the address (public DNS).

Login to your server as in the ‘Connecting to a server’ section (see also instructions "Connecting to a server below").

6. Python and theano are already installed there, let's install sklearn:

> sudo apt-get install build-essential python-dev python-setuptools \

python-numpy python-scipy \

libatlas-dev libatlas3gf-base

> pip install --user --install-option="--prefix=" -U scikit-learn

(will take 2 minutes)

Connecting to a server:

Username is 'ubuntu', so you should login as ubuntu@DNS, authorizing using the key. You need to save your private key in a safe place on your computer. We assume that he key is called: X.pem

For convenience, you can add a key to your key ring:

> chmod 0400 X.pem

now it is ready to use to store it in your key ring do:

> ssh-add -K X.pem

Now you can do (remember to replace DNS with the proper IP):

> ssh ubuntu@DNS

If you cannot add a key to your key ring or have any other problems, you can do just:

> ssh -i X.pem ubuntu@DNS

EXAMPLE (X.pem key in the current folder):

"ssh -i X.pem"

Putting/downloading files

Option 1:

Connect using sftp client, if you don't have any then use WinSCP (windows) or FileZilla (all OS) to have file explorer so it is convenient to upload datasets and files and download predictions.

Option 2:

Instead sftp client, you may use wget to download the datasets to the current folder:

> wget http://www.address

3. Download the zip file to your computer.

Fiva details checklist -- HERE REMEMBER TO:

1. Open a new console locally (do not type it on the server!)

2. Change * to the exact name of your zip.

3. Provide the proper path after the 'home/ubuntu/'

4. provide a filename (also path) where is located the key

5. Change DNS to the proper server address.

scp -i X.pem ubuntu@DNS:/home/ubuntu/[mydir]/*.zip ./

To upload a file from your computer to the server, you need to swap the source and destination, e.g:

scp -i X.pem /C/local/path/ ubuntu@DNS:/home/ubuntu/[mydir]/

That's it, you can now run Theano code, see our MNIST example: