Keras

Overview

Keras is a high-level neural networks API, written in Python and capable of running on top of either Tensorflow or Theano. It was developed with a focus on enabling fast experimentation.

Versions 1.0.8, 2.0.5 and 2.1.5 (for Python 2.7.11 from Anaconda 2.5.0) are installed on the zrek. They support CUDA and cuDNN all on the K20 and K40 GPUs.

Restrictions on use

There are no access restrictions on zrek.

Supported Backend Compute Nodes

This application is available on the Nvidia GPU nodes: besso and kaiju{[1-5],101}. Please see the K40 node instructions and the K20 node instructions for how to access the nodes.

Set up procedure

  • To use Keras with Theano as the software backend load one of the following modulefiles:
    # Load one of these to use the theano backend
    module load apps/gcc/python-packages/anaconda3-4.2.0/keras/2.1.5     # Python 3.5
    
    module load apps/gcc/python-packages/anaconda-2.5.0/keras/2.1.5      # Python 2.7
    module load apps/gcc/python-packages/anaconda-2.5.0/keras/2.0.5      # Python 2.7
    
    module load apps/binapps/keras/1.0.8                                 # Python 2.7
    
    • This will automatically load the following modulefiles for you:
      # One of
      apps/binapps/anaconda/3/4.2.0     # Provides Python 3.5.2
      apps/binapps/anaconda/2.5.0       # Provides Python 2.7.11
      
      libs/cuda/9.1.85
      libs/cuDNN/7.1.3
      
      # One of
      apps/gcc/python-packages/anaconda3-4.2.0/theano/1.0.1
      apps/gcc/python-packages/anaconda-2.5.0/theano/0.9.0
      
  • To use keras with Tensorflow as the software backend load one of the following modulefiles:
    # Load one of these to use the tensorflow backend
    module load apps/gcc/python-packages/anaconda3-4.2.0/keras/2.1.5-tensorflow    # Python 3.5
    module load apps/gcc/python-packages/anaconda-2.5.0/keras/2.0.5-tensorflow     # Python 2.7
    module load apps/binapps/keras/1.0.8-tensorflow
    
    • This will automatically load the following modulefiles for you:
      # One of
      apps/binapps/anaconda/3/4.2.0     # Provides Python 3.5.2
      apps/binapps/anaconda/2.5.0       # Provides Python 2.7.11
      
      libs/cuda/9.1.85
      libs/cuDNN/7.1.3
      
      # One of
      apps/gcc/tensorflow/1.8.0-py35-gpu
      apps/gcc/tensorflow/
      

Running the application

Please do not run Keras on the login node. Jobs should be run interactively on the backend compute nodes (via qrsh) or submitted to the compute nodes via batch.

The following instructions describe interactive use on a backend compute node and batch jobs from the login node.

Interactive use on a Backend Compute Node

To see the commands used to log in to a particular backend compute node, run the following on the zrek login node:

backends

Once logged in to a backend compute node K20 node or K40 node (using qrsh) and having loaded the modulefile there (see above), run:

python
import keras

You can then import Keras python modulefiles and it will report the software backend it is using (Tensorflow or Theano):

>>> from keras.models import Sequential
  #
  # Will report one of:
  #   Using Theano backend.
  #   Using Tensorflow backend (will also report CUDA library loads)

You can also check the software backend with the following;

python -c "from keras import backend"

Serial batch job submission

Do not log in to a backend computer node. The job must be submitted from the zrek login node. Ensure you have loaded the correct modulefile on the login node and then create a jobscript similar to the following:

#!/bin/bash
#$ -S /bin/bash
#$ -cwd                   # Run job from directory where submitted
#$ -V                     # Inherit environment (modulefile) settings
#$ -l k20                 # Select a single GPU (Nvidia K20) node
                          # Or use: #$ -l k40
# Run Keras 
python my-keras-test.py

Submit your jobscript from the zrek login node using

qsub jobscript

where jobscript is the name of your jobscript.

Further info

Updates

None.

Last modified on May 1, 2018 at 10:29 am by George Leaver