TensorFlow
TensorFlow Software
TensorFlow is an end-to-end open source platform for machine learning. It has a comprehensive, flexible ecosystem of tools, libraries and community resources that lets researchers push the state-of-the-art in ML and developers easily build and deploy ML powered applications.
TensorFlow Versions
As TensorFlow leverages GPU, it is available in the 'allnodes' optimization tree. Use the 'module avail' command to see the current list of versions (Output from 4 Nov 22):
----------------------- /usr/local/easybuild_allnodes/modules/all -----------------------
TensorFlow/2.6.0-foss-2021a-CUDA-11.3.1 TensorFlow/2.7.1-foss-2021b-CUDA-11.4.1 (D)
Running MNIST Example in HPC
Copy the python script "mnist.py" from /usr/local/doc/TENSORFLOW/ to your home directory. It is adapted from TensorFlow 2 quickstart for beginners.
cp /usr/local/doc/TENSORFLOW/mnist.py .
Request an appropriate GPU node. In this sample, gpu2v100 is used
srun -p gpu -C gpu2v100 --gres=gpu:1 --mem=8gb --pty bash
Load Python module if you have not already loaded it along with appropriate CUDA and cuDNN modules.
module load TensorFlow/2.7.1-foss-2021b-CUDA-11.4.1
Run Python script:
python mnist.py
output:
9 MB memory: -> device: 0, name: Tesla V100-PCIE-32GB, pci bus id: 0000:3b:00.0, compute capability: 7.0
Epoch 1/5
1875/1875 [==============================] - 3s 1ms/step - loss: 0.2964 - accuracy: 0.9145
Epoch 2/5
1875/1875 [==============================] - 2s 1ms/step - loss: 0.1416 - accuracy: 0.9580
Epoch 3/5
1875/1875 [==============================] - 2s 1ms/step - loss: 0.1071 - accuracy: 0.9675
Epoch 4/5
1875/1875 [==============================] - 2s 1ms/step - loss: 0.0870 - accuracy: 0.9731
Epoch 5/5
1875/1875 [==============================] - 2s 1ms/step - loss: 0.0742 - accuracy: 0.9769
313/313 - 0s - loss: 0.0733 - accuracy: 0.9777 - 413ms/epoch - 1ms/step
For batch submission, follow the instruction at HPC Batch & Interactive Job submission, and be aware of the specifics of Working with Modules on Pioneer
Tensorflow from a singularity Container
Please visit our HPC Guide to Singularity.