Software name: 

Keras is available to all users of HPC2N.


Keras is a minimalist, highly modular neural networks library, written in Python and capable of running on top of either TensorFlow or Theano.


Keras was developed with a focus on enabling fast experimentation. Being able to go from idea to result with the least possible delay is key to doing good research.

Use Keras if you need a deep learning library that:

  • Allows for easy and fast prototyping (through user friendliness, modularity, and extensibility).
  • Supports both convolutional networks and recurrent networks, as well as combinations of the two.
  • Runs seamlessly on CPU and GPU.

On HPC2N we have Keras available as a module on Kebnekaise.

Usage at HPC2N 

To use the Keras module, first add it to your environment. Use:

module spider keras

to see which versions are available, as well as how to load the module and the needed prerequisites.

Note that while the case does not matter when you use "ml spider", it is necessary to match the case when loading the modules.

You can read more about loading modules on our Accessing software with Lmod page and our Using modules (Lmod) page.


When you use this Python module, a couple directories are needed, which are used for compiling etc. They are created automatically in your home directory first time you import the module in Python if you are running interactively, however this means trouble when you are running as a batch job since the batch system is not allowed to write to your home directory on AFS.

To solve this, delete the directories from your home directory if they have already been created, and then create them in your pfs and make a symbolic link from your home directory:

cd /pfs/nobackup$HOME
mkdir .theano
mkdir .keras
cd $HOME
ln -s /pfs/nobackup$HOME/.theano .theano
ln -s /pfs/nobackup$HOME/.keras .keras

Note also that if you are running as a batch job, you need to do

srun python .....

since the Keras module is built with MPI.

Note that KERAS_BACKEND is set to theano in the module file, so if you want to use tensorflow instead, you have to set the environment variable to that

export KERAS_BACKEND=tensorflow
Additional info 

More information about Keras, including documentation and getting started guides can be found on the Keras homepage.

Updated: 2020-07-14, 21:10