Index of /examples/machine_learning/tensorflow

[ICO]NameLast modifiedSizeDescription

[PARENTDIR]Parent Directory   -  
[DIR]v1.13.1/ 2021-02-24 14:11 -  
[DIR]v2.1.0/ 2021-05-10 14:59 -  

Tensorflow on the SCC

Tensorflow on the SCC

Tensorflow is available on the SCC with support for GPU accelerated computations and CPU-only computations. This page provides examples and guidance on how to use Tensorflow on the SCC.

Modules

To see the versions of Tensorflow available (including the latest) run the command:

 module avail tensorflow

Here is an example of loading the 2.7.0 verion of the Tensorflow module. This module supports Python 3.7, 3.8, and 3.9. You can access Python using the available modules (run "module avail python3") or if you have activated a conda environment using one of those versions of Python. The following commands will therefore work on GPU and on CPU-only nodes. On a GPU node the GPU version of Tensorflow is automatically used:

module load python3/3.8.10
module load tensorflow/2.7.0 

Installing Tensorflow via Pip

If you do not wish to use the existing Tensorflow modules you can install Tensorflow for yourself. The Tensorflow website has a page that indicates the correct versions of the CUDA and cuDNN libraries that need to be available to enable GPU functionality. This requires you to load appropriate modules to access these libraries before running Python. For example, Tensorflow 2.8.0 requires the CUDA 11.2 and cuDNN 8.1 libraries. After installing Tensorflow with pip you then load extra module:

 module load python3/3.8.10
 # install tensorflow - this includes both CPU and GPU versions
 pip install --prefix=/projectnb/myproject/myfolder/mypip tensorflow==2.8.0
 # cuda/11.2 comes with cuDNN 8.3 
 module load cuda/11.2  
 # load this next so that the correct cuDNN is found
 # by Tensorflow 
 module load cudnn/8.1.1 
 python -c 'import tensorflow as tf; print(tf.config.list_physical_devices()'

Installing Tensorflow via Conda

Conda environments can also use the Tensorflow modules using the conda-forge repository. The conda "tensorflow" package is the CPU version. The "tensorflow-gpu" version includes both CPU and GPU versions. If you want to install tensorflow-gpu package into your own conda environment you must run the conda install command on a GPU node or else you will get the CPU-only install without any warnings or indications!

 # RUN THIS ON A GPU NODE
 module load miniconda/4.9.2
 conda activate myenv
 # this brings along its own copy of the req'd CUDA and cuDNN libraries
 conda install -c conda-forge tensorflow-gpu==2.8.0
 python -c 'import tensorflow as tf; print(tf.config.list_physical_devices()'

Depending on the version you need, here are two examples of release v1.13.1 and v2.1.0 in each corresponding foler. Detailed python code examples and batch submit scripts are available in each.

Contact Information

Help: help@scc.bu.edu

Note: RCS example programs are provided "as is" without any warranty of any kind. The user assumes the entire risk of quality, performance, and repair of any defect. You are welcome to copy and modify any of the given examples for your own use.