From Documentation
Revision as of 15:05, 25 July 2017 by Preney (Talk | contribs)

Jump to: navigation, search
Note: Some of the information on this page is for our legacy systems only. The page is scheduled for an update to make it applicable to Graham.

Theano is a Python library that allows you to define, optimize, and evaluate mathematical expressions involving multi-dimensional arrays efficiently.

Testing Theano 0.9 (new pygpu backend) on Copper/Mosaic

A test version of Theano v0.9.0b1 is installed on Copper/Mosaic. To use this Theano, please do:

source /opt/sharcnet/testing/

This will load python 2.7.10 module together with some useful python packages (e.g. OpenCV, Hickle, ZMQ, Lasagne, Cython, mpi4py, etc)

SHARCNET installation

Theano on Mosaic, Copper and Angel

Currently, Mosaic, Copper and Angel cluster have CUDA7.5 and python/intel/2.7.10 module which includes Theano 0.7. To use this Theano, please do before submitting jobs:

module unload intel/12.1.3 mkl/10.3.9 openmpi/intel/1.6.2 
module load intel/15.0.3 
module load hdf/serial/ 
module unload cuda
module load cuda/7.5.18 
module load python/intel/2.7.10

You still need to edit “.theanorc” under /home/username by adding “device = gpu” under [global]:

floatX = float32
device = gpu

Theano with cuDNN

cuDNN is an NVIDIA library with functionality used by deep neural network. It provides optimized versions of some operations like the convolution.

To make theano to use cuDNN, you should set the environment variables LD_LIBRARY_PATH, LIBRARY_PATH and CPATH.

Example for cuDNN v4:

On Copper or Mosaic:
export LD_LIBRARY_PATH=/opt/sharcnet/testing/cudnn/cudnn4:$LD_LIBRARY_PATH
export CPATH=/opt/sharcnet/testing/cudnn/cudnn4:$CPATH
export LIBRARY_PATH=/opt/sharcnet/testing/cudnn/cudnn4:$LD_LIBRARY_PATH

On Angel:
export LD_LIBRARY_PATH=/work/feimao/software_installs/cudnn4:$LD_LIBRARY_PATH
export CPATH=/work/feimao/software_installs/cudnn4:$CPATH
export LIBRARY_PATH=/work/feimao/software_installs/cudnn4:$LD_LIBRARY_PATH

By default, Theano will detect if it can use cuDNN. If so, it will use it. If not, Theano optimizations will not introduce cuDNN ops. So Theano will still work if the user did not introduce them manually.

Monk GPU cluster

Theano is not recommended to be run on Monk due to the lack of cuDNN support.

User installation

Installing an updated version of theano is easy.

After you login to Mosaic, Copper or Angel and setup the modules:

module unload intel mkl openmpi cuda 
module load intel/15.0.3 
module load hdf/serial/ 
module load cuda/7.5.18 
module load python/intel/2.7.10

you can get the lastest Theano form github:

git clone

cd to Theano folder and run:

python build 
python install --user

This will install the Theano in your /home/yourname/.local folder and make it default version when you import theano in python.

Flushing output of Python print

Sometimes you may not see the output in the file, which specified when submitting job, until PYTHON flush the output buffer to it. If you want an unbuffered output (immediately writing output into file), you can add "-u" option after "python" command:

python -u