Keras

From UFRC
Jump to navigation Jump to search

Description

Keras website  

Keras is a minimalist, highly modular neural networks library, written in Python and capable of running on top of either TensorFlow or Theano. It 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.

Required Modules

=GPU

  • tensorflow

MPI

  • gcc/5.2.0
  • openmpi/1.10.2
  • keras

Example:

module load gcc/5.2.0 openmpi keras

System Variables

  • HPC_KERAS_DIR - installation directory
  • HPC_KERAS_BIN - executable program directory
  • HPC_KERAS_LIB - library directory


Additional Information

Keras can use either theano or tensorflow backend. Her'e how it can be used with the tensorflow backend and GPU acceleration.


Backend selection

put 'export KERAS_BACKEND=tensorflow' into your job script or set up as your default backend by putting

{
    "image_dim_ordering": "tf", 
    "epsilon": 1e-07, 
    "floatx": "float32", 
    "backend": "tensorflow"
}

into your ~/.keras/keras.json keras configuration file.

The above is discussed in the Keras backend documentation.

Interactive testing
$ srun -p hpg2-gpu --gres=gpu:1 --pty -u bash -i --time=01:00:00 --mem=2gb
srun: job 123456 queued and waiting for resources
srun: job 123456 has been allocated resources

gpu node $ module load  tensorflow

gpu node $ launch_tensorflow python
Python 2.7.12 (default, Nov 19 2016, 06:48:10) 
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from keras import backend
Using TensorFlow backend.
I tensorflow/stream_executor/dso_loader.cc:135] successfully opened CUDA library libcublas.so.8.0 locally
I tensorflow/stream_executor/dso_loader.cc:135] successfully opened CUDA library libcudnn.so.5 locally
I tensorflow/stream_executor/dso_loader.cc:135] successfully opened CUDA library libcufft.so.8.0 locally
I tensorflow/stream_executor/dso_loader.cc:135] successfully opened CUDA library libcuda.so.1 locally
I tensorflow/stream_executor/dso_loader.cc:135] successfully opened CUDA library libcurand.so.8.0 locally
>>> 

Running a script within a job

Put

module load tensorflow
launch_tensorflow python my_keras_script.py

into the job script that you submit to the [partition]