Wednesday, February 4, 2015

Using Ipython Notebook and Theano on an AWS GPU machine


Using a service such as Sage Math Cloud is an excellent way to use Ipython Notebooks (or Sage Worksheets) online, but I wanted to give Theano's GPU features a serious try, so I decided to spin up a VM with a powerful GPU (using Amazon AWS's g2.2xlarge instance). This post is a sort of a "note-to-self" type step-by-step guide on how to get it done, since it's not completely trivial... I'm not going to repeat what others have written about this, so I just added the relevant links.

1) Check out this post to set up Theano on AWS. Make sure to run the test too... The test passed for me, but turns out I got further problems with BLAS (see below)

2) Check out this post to set up an Ipython Notebook server on AWS. Make sure to allow inbound traffic: go to Security Groups on AWS Dashboard, click Actions and Edit Inbound Rules. Here add a custom TCP rule with a port number you wish to use

3) I still got an error "WARNING (theano.tensor.blas): We did not found [sic] a dynamic library into the library_dir of the library we use for blas. If you use ATLAS, make sure to compile it with dynamics library." Maybe it's just something I did, but apparently Theano cannot find BLAS, although it did install with Anaconda... Anyway, I just edited the .theanorc file and added a flag for blas like this (after installing openblas; or maybe it was installed by default??):


[blas]
ldflags = -lopenblas

That sorted it out... and now it's running like crazy, with only about $0.09 per hour!! ;)