LIBJACKET on Amazon EC2 GPU Cloud Instances

by pavan on December 14, 2010

in Benchmarks,CUDA

Amazon recently added GPUs to their Elastic Compute Cloud. We decided to throw LIBJACKET into this GPU cloud to see how it would fare. The $2/hr pay-on-demand pricing is a great option for many Jacket programmers.

This post is full of screenshots detailing the steps we took to get going with GPU computing in Amazon’s cloud:

  1. Sign up with Amazon EC2
  2. Launch a GPU instance
  3. Login to the instance using ssh
  4. Setup the environment
  5. Download, build, and test LIBJACKET!

Everything in this post applies equally well to running Jacket for MATLAB® on EC2. Simply install MATLAB + Jacket in your Amazon GPU instance and start working over ssh.

Note: Simply click on the images to make them larger as needed.

1) Sign up with Amazon EC2

  • Go to http://aws.amazon.com/ec2/ and sign up.
  • Once you are done, you will get multiple email notifications from Amazon.
  • Open the email with “Amazon Elastic Compute Cloud Sign-Up Confirmation”.
  • Navigate to the first link, create the Access keys, and store them in a safe place.
  • Now go to https://console.aws.amazon.com/ec2/home.
  • This is where you will be doing most of your work.
  • If you had not created key pairs already, you can create a new key pair as shown below:

  • At this point you will be prompted to download a .pem key that you will need to use for all future logins.

2) Launch a GPU instance

  • You begin by clicking launch instances in your management console.

  • Be careful to choose the correct type of instance.
  • To create the GPU cluster, choose the Centos 5.5 instance  (AMI ID: aa30c7c3).
  • Verify that CUDA 3.1 is included.

  • Next in instance details, choose “Cluster GPU” as the instance type.

  • Use default values for the rest of the fields in Instance details.
  • When prompted to choose the key pair, use the one that you had already downloaded.
  • For the rest of the tutorial, we use “test_key.pem” as our key.
  • Replace test_key with the appropriate key name whenever necessary.

  • Choose default values for the rest. The final review page should look like this:

  • Congratulations, you now have a GPU instance!
  • Your instance also starts running immediately, So does your billing cycle :)

3) Login to the instance using ssh

  • To connect to your instance, you need to know the IP address associated with your account.
  • For this, click on your instance, choose connect.
  • A popup window opens up giving you the required details.

  • Take note that you have set the permissions of test_key.pem to be readable only by you.
  • cd to the directory test_key.pem is located in and use the following commands to ssh into Amazon EC2:
$ chmod 400 test_key.pem
$ ssh -i test_pem root@ec2-xxx-xxx-xxx-xxx.compute-1.amazonaws.com

4) Setup the environment

  • Once you are logged in poke around a little to get to know a bit about the environment.
  • You could verify if the cuda toolkit and nvidia drivers have been installed:
$ ls /usr/local/cuda
$ cat /proc/driver/nvidia/version
  • Now coming to setting up the environment, you will have to install a few things.
  • Centos 5.5 comes with gcc 4.1 by default, and libjacket currently has compatibility issues with it.
  • Hence we will be installing gcc 44 and g++ libraries:
$ yum install -y gcc-c++ gcc44 gcc44-c++
  • Now you need to set up the system to use gcc44 , g++44 by default:
$ cp /usr/bin/gcc /usr/bin/gcc41; cp /usr/bin/g++ /usr/bin/g++41
$ rm /usr/bin/gcc /usr/bin/g++
$ alternatives --install /usr/bin/gcc gcc /usr/bin/gcc44 40
$ alternatives --install /usr/bin/gcc gcc /usr/bin/gcc41 50
$ alternatives --install /usr/bin/g++ g++ /usr/bin/g++44 40
$ alternatives --install /usr/bin/g++ g++ /usr/bin/g++41 50
  • Now that the alternatives have been set up, you will need to choose the correct version:
$ alternatives --config gcc
  • This will print out a menu on the console. Choose the option that points to gcc44.
  • Repeat the procedure for g++.
$ alternatives --config g++
  • Now you can verify the gcc and g++ versions by using the following commands:
$ gcc --version
$ g++ --version
  • Make sure the version is 4.4.x.
  • Now that gcc is setup, we need to put /usr/local/cuda/bin in .bashrc:
$echo "export PATH=$PATH:/usr/local/cuda/bin" >> ~/.bashrc
  • Now you are all set and can begin working with LIBJACKET!

5.  Download, build, and test LIBJACKET!

  • Download LIBJACKET
$wget -c http://www.accelereyes.com/nightly/libjacket-linux-DEV.tgz
  • Extract it:
$tar xvzf libjacket-linux-DEV.tgz
  • Test it!

 

$cd libjacket/examples/pi
$make run

  • LIBJACKET yielded a 44X speedup for this example!

Notes:

  • Do not forget to go back to the management console to stop the instance once you are done working with it.
  • You will be assigned a new IP every time you stop and start an instance. There may be ways around it, we have not explored it yet.
  • Setting up the whole thing took about one hour’s work. Most of the time being spent to figure out gcc issues.
  • Here is a nice post that was really helpful to us in about getting started with EC2

{ 1 comment }

Jeff Nucciarone December 14, 2010 at 10:12 pm

Use an elastic ip (yet another nickel and dime service, but relatively cheap) to associate your instance with a fixed address. I use one so I only have to poke holes in my local firewall for a specific address.

Comments on this entry are closed.

Previous post:

Next post: