Friday, May 12, 2017

TensorFlow setup using pip3 and Starting Tensorboard in Linux Mint VirtualBox


The easiest way to get started is to install TensorFlow with CPU support only. My method of installation is with pip, more specifically pip3 for python3+. I am using Linux Mint 18 with python version 3.5. This method may be more problematic than using pip.

TensorFlow Setup:

First run, pip3 -V command to see if it is already installed. If not installed then it will show this command, sudo apt install python3-pip to install it.

Next run, pip3 install tensorflow command in terminal to install tensorflow. Now to test type python3 in terminal and paste,
import tensorflow as tf

If that did not give any errors then continue with pasting three more lines,
hello = tf.constant('Hello, TensorFlow!')
sess = tf.Session()
print(sess.run(hello))

The output should be,
Hello, TensorFlow!

Running Tensorboard:

According to google docs, tensorboard can be started using, python -m tensorflow.tensorboard . Maybe in my case, python3 -m tensorflow.tensorboard . Another option, tensorboard --logdir=path/to/log-directory .

None of the above commands work for me. Writing tensorboard in the terminal gives command not found error.
Run pip3 show tensorflow command to know the location of your tensorflow folder. In my case it is in,
/home/cs/.local/lib/python3.5/site-packages

Now though terminal or address bar move to that directory and type,
python3 tensorboard.py --logdir=tmp

Next pasting the given local address with port in a browser should start tensorboard. In my case it is, http://0.0.0.0:6006

Screenshots:





Graph Visualization:

To visualize a graph type, python3 tensorboard.py --logdir=file:///home/cs/Documents/tensorflow/output in terminal. Here change the part after equal sign with your own output directory of a program. Open browser and move to graph tab to get the visualization.

No comments: