Link to section 'Tensorflow on Hammer' of 'Tensorflow' Tensorflow on Hammer
Link to section 'Tensorflow Modules' of 'Tensorflow' Tensorflow Modules
A set of stable tensorflow builds are provided on Hammer. At present, tensorflow is part of the ML-Toolkit packages. You must load one of the learning modules before you can load the tensorflow module. We recommend getting an interactive job for running Tensorflow.
$ module load learning/conda-5.1.0-py36-cpu
$ module spider ml-toolkit-cpu/tensorflow
$ module show ml-toolkit-cpu/tensorflow
$ module load ml-toolkit-cpu/tensorflow
$ python -c "import tensorflow as tf"
Downloading and installing Tensorflow in user's home directory using anaconda environments is recommended. Installing Tensorflow in your home directory has the advantage that it can be upgraded to newer versions easily. Therefore, researchers will have access to the latest libraries when needed.
- We recommend getting an interactive job for installing and running Tensorflow.
- First load the necessary modules and define which tensorflow version to install:
$ module purge $ module load anaconda/5.1.0-py36 $ module list $ export TF_BINARY_URL="https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-1.12.0-cp36-cp36m-linux_x86_64.whl"
- Create an anaconda environment using conda-env-mod. The script also prints a list of modules that should be loaded to use the custom environment, please note down these module names.
$ conda-env-mod create -n my_tf_env
- Activate the anaconda environment.
$ module load use.own $ module load conda-env/my_tf_env-py3.6.4
- Now install Tensorflow binaries in your home directory:
$ pip install --ignore-installed --upgrade $TF_BINARY_URL
- Wait for installation to finish.
- If the installation finished successfully, you can now proceed with the examples below. If not, please look at common installation problems and how to resolve them.
Link to section 'Testing the installation' of 'Tensorflow' Testing the installation
- Check that you have the anaconda module and your custom environment loaded using the command module list. Otherwise, load the necessary modules:
$ module load anaconda/5.1.0-py36 $ module load use.own $ module load conda-env/my_tf_env-py3.6.4
- Save the following code as tensor_hello.py
# filename: tensor_hello.py import tensorflow as tf hello = tf.constant('Hello, TensorFlow!') sess = tf.Session() print(sess.run(hello))
- Run the example
$ python tensor_hello.py
- This will produce an output like the following:
< ... tensorflow build related information ... > < ... hardware information ... > Hello, TensorFlow!
Link to section 'Tensorboard' of 'Tensorflow' Tensorboard
- You can visualize data from a Tensorflow session using Tensorboard. For this, you need to save your session summary as described in the Tensorboard User Guide.
- Launch Tensorboard:
$ python -m tensorboard.main --logdir=/path/to/session/logs
- When Tensorboard is launched successfully, it will give you the URL for accessing Tensorboard.
<... build related warnings ...> TensorBoard 0.4.0 at http://hammer-a000.rcac.purdue.edu:6006
- Follow the printed URL to visualize your model.
- Please note that due to firewall rules, the Tensorboard URL may only be accessible from Hammer nodes. If you cannot access the URL directly, you can use Firefox browser in Thinlinc.
- For more details, please refer to the Tensorboard User Guide.