Link to this document's Jupyter Notebook

In order to successfully complete this assignment you need to participate both individually and in groups during class. If you attend class in-person then have one of the instructors check your notebook and sign you out before leaving class on Wednesday April 14. If you are attending asynchronously, turn in your assignment using D2L no later than _11:59pm on Wednesday April 14.


In-Class Assignment: Tensorflow

Tensorflow Logo

Agenda for today's class (70 minutes)

  1. (20 minutes) Conda Environments
  2. (20 minutes) Installing Tensorflow
  3. (20 minutes) Testing Tensorflow
  4. (10 minutes) Benchmark Tensorflow

1. Conda Environments

https://www.simplilearn.com/keras-vs-tensorflow-vs-pytorch-article


2. Installing Tensorflow

Instructions for installing Tensorflow can be found here:

https://wiki.hpcc.msu.edu/display/ITH/General+notes+and+installation+via+Python+virtualenv

This includes the following instructions to reset the HPC Environment:

module purge
module load Python
module load CUDA
module load cuDNN

The next step is to make something called a python virtual environment. If you are not using these, you should, they are cool and help you sandbox module installations:

#Setup and activeate a new python vertual enviornment
virtualenv -p python3 tf2env
source tf2env/bin/activate

Once we have our new python enviornment set-up we need to install some programs:

#Install needed libraries
pip3 install --upgrade tensorflow-gpu keras

3. Testing Tensorflow

Lets now try to see if we use the above

...and, set some enviornment variables.

module purge
module load Python
module load CUDA
module load cuDNN

source tf2env/bin/activate

The final step is to see if this thing works:

cp /opt/software/hpc_examples/examples/.Tensorflow/convolutional.py .
time python $convolutional.py

The above doesn't quite work. See following stack overflow for a discussion of the problem and a potential solution;

https://stackoverflow.com/questions/58258003/attributeerror-module-tensorflow-has-no-attribute-app


3. Testing Tensorflow

Lets now try to see if we use the above

...and, set some enviornment variables.

module purge
module load CUDA/10.0.130
module load cuDNN/7.5.0.56-CUDA-10.0.130
module load GCC/5.4.0-2.26 OpenMPI/1.10.3
module load Python/3.5.2

source tf2env/bin/activate

The final step is to see if this thing works:

export TENSORFLOWPROGRAM=/opt/software/hpc_examples/examples/Tensorflow/convolutional.py
time python $TENSORFLOWPROGRAM

4. Benchmark Tensorflow

Lets now try to see if we use the above to run a few benchmarks.


Congratulations, we're done!

If you attend class in-person then have one of the instructors check your notebook and sign you out before leaving class. If you are attending asynchronously, turn in your assignment using D2L.

Course Resources:

Written by Dr. Dirk Colbry, Michigan State University Creative Commons License
This work is licensed under a Creative Commons Attribution-NonCommercial 4.0 International License.