This is an old revision of the document!


TensorFlow is a open-source machine learning framework mainly developed by Google. It can be used for verious machine learning tasks, e.g. deep learning. TensorFlow provides a high level API in python and other languages and is can run on CPUs as well as GPUs.

Installing TensorFlow

It is recommended to use the python tools virtualenv and pip to create a virtual python environment and install the desired version of tensorflow within that environment.

module load python/3.5.1
virtualenv <your_virtual_env>
cd <your_virtual_env>
source bin/activate
pip install --upgrade pip
pip install tensorflow-gpu==1.12.0

If you do not want to use GPUs simply replace the last line with

pip install tensorflow==1.12.0

Testing the installation

To run TensorFlow on GPUs, load the correct modules and submit a job to the gpu partition.
#SBATCH -p gpu
#SBATCH -t 1
#SBATCH --gpus-per-node 1
module load cuda10.0/toolkit/10.0.130
module load cuda10.0/blas/10.0.130
module load cudnn/10.0v7.6.3
import tensorflow as tf
hello = tf.constant('Hello, TensorFlow!')
sess = tf.Session()

And then submit the job using Slurm:


The output file should contain

The output (if any) follows:

b'Hello, TensorFlow!'

and also information about the GPUs selected.

Testing CPU only installation

If you want to test a CPU only installation, you can just run the on a login node.

Using TensorFlow

You can now use TensorFlow in your python scripts. Please read gpu_selection for more information about GPU usage.

This website uses cookies. By using the website, you agree with storing cookies on your computer. Also you acknowledge that you have read and understand our Privacy Policy. If you do not agree leave the website.More information about cookies