Theano is a Python library that allows you to define, optimize, and evaluate mathematical expressions involving multi-dimensional arrays efficiently. Theano is most commonly used to perform Deep Learning and has excellent GPU support and integration through PyCUDA. The following steps can be used to setup and configure Theano on your own profile.
A GPU-enabled worker node must be requested in order to use the GPU version of this software. See Using GPUs on ShARC for more information.
Theano is available on ShARC as both Singularity images and by local installation.
As Theano and all its dependencies are written in Python. A Singularity image is available for instant usage and it can also be installed locally in your home directory. For local installation, the use of Anaconda (Python) is recommended as it is able to create a virtual environment in your home directory, allowing the installation of new Python packages without admin permission.
This software and documentation is maintained by the RSES group and GPUComputing@Sheffield. For feature requests or if you encounter any problems, please raise an issue on the GPU Computing repository.
Load the relevant modules with the following command:
module load libs/cudnn/5.1/binary-cuda-8.0.44 module load apps/python/conda
Create a conda environment to load relevant modules on your local user account:
conda create -n theano python=3.5 source activate theano
Install the other Python module dependencies which are required using conda:
conda install -y numpy scipy nose pip install pydot-ng pip install parameterized conda install -y theano pygpu
For optimal Theano performance, enable the CUDA memory manager CNMeM. To do this, create the .theanorc file in your HOME directory and set the fraction of GPU memory reserved by Theano. The exact amount of energy may have to be hand-picked: if Theano asks for more memory that is currently available on the GPU, an error will be thrown during import of theano module. Create or edit the
.theanorc file with nano:
Add the following lines and, if necessary, change the 0.8 number to whatever works for you
Run python and verify that Theano is working correctly
python -c "import theano;theano.test()"
The previous instuctions installs Theano and its dependencies inside your home directory but every time you use a new session or within your job scripts, the modules must be loaded and conda must be activated again. Use the following command to activate the Conda environment with Theano installed:
module load libs/cudnn/5.1/binary-cuda-8.0.44 module load apps/python/conda source activate theano
Theano singularity images support is now discontinued as the use of conda virtual environments is deemed to be more customisable and simpler to use. Existing images will still be available but to use a newer version of Theano, please follow instructions above to install Theano to your home directory.
Singularity images are self-contained virtual machines similar to Docker. For more information on Singularity and how to use the images, see Singularity.
A symlinked file is provided that always point to the latest image:
To get a bash terminal in to an image for example, use the command:
singularity exec --nv /usr/local/packages/singularity/images/theano/gpu.img /bin/bash
exec command can also be used to call any command/script inside the image e.g.
singularity exec --nv /usr/local/packages/singularity/images/theano/gpu.img python your_theano_script.py
--nv flag enables the use of GPUs within the image and can be removed if the software you’re using does not use the GPU.
You may get a warning similar to
groups: cannot find name for group ID ..., this can be ignored and will not have an affect on running the image.
/shared are automatically mounted to your ShARC filestore directories. For GPU-enabled images the
/nvbin is mounted to the correct Nvidia driver version for the node that you’re using.
Theano is installed as part of Anaconda and can be found inside the image at:
To submit jobs that uses a Singularity image, see Submitting Batch Jobs That Uses Singularity Images for more detail.
Paths to the actual images and definition files are provided below for downloading and building of custom images.