Skip to content

TensorFlow

TensorFlow is a library for machine learning and artificial intelligence.

TensorFlow is available in multiple variants:

TensorFlow as a Python package for CPU

TensorFlow as a Python package for CPU that works on Rackham.

It is part of the python_ML_packages/[version]-cpu modules, where [version] is a version, for example, python_ML_packages/3.11.8-cpu.

How to test TensorFlow as a Python package for CPU?

On Rackham, load the module to get access to the library:

module load python_ML_packages/3.11.8-cpu

Start Python:

python

In Python, type:

import tensorflow as tf
print(tf.test.is_gpu_available())

This should print:

False

The output is correct: this is the CPU version.

TensorFlow as a Python package for GPU

TensorFlow as a Python package for GPU that works on Bianca and Snowy.

It is part of the python_ML_packages/[version]-gpu modules, where [version] is a version, for example, python_ML_packages/3.9.5-gpu

⚠ You can load this package on nodes without GPU but python will not find Tensorflow!

If you want to work interactively and test things, first allocate resources as seen below:

On Snowy

$ interactive -A <proj> -n 2 -M snowy --gres=gpu:1  -t 1:00:01

On Bianca

$ interactive -A <proj> -n 1 -C gpu --gres=gpu:1 -t 01:10:00
How to test TensorFlow as a Python package for GPU?

Load the module to get access to the library:

module load python_ML_packages/3.9.5-gpu

Start Python:

python

In Python, type:

import tensorflow as tf
print(tf.test.is_gpu_available())

This should print something like:

2024-03-15 14:13:02.038401: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1525] Created device /device:GPU:0 with 13614 MB memory:  -> device: 0, name: Tesla T4, pci bus id: 0000:08:00.0, compute capability: 7.5
True

The output is correct: this is the GPU version.