62

How do I install TensorFlow's tensorboard?

nbro
  • 15,395
  • 32
  • 113
  • 196
Alex_M
  • 1,824
  • 1
  • 14
  • 26

12 Answers12

56

The steps to install Tensorflow are here: https://www.tensorflow.org/install/

For example, on Linux for CPU-only (no GPU), you would type this command:

pip install -U pip
pip install tensorflow

Since TensorFlow depends on TensorBoard, running the following command should not be necessary:

pip install tensorboard
nbro
  • 15,395
  • 32
  • 113
  • 196
Mike Harris
  • 1,487
  • 13
  • 20
  • have you tried it. i wasn't able to run tensorboard. now i have git-cloned the tensorflow repo and i'm trying to build bazel since this seems to be a requirement – Alex_M Nov 10 '15 at 16:14
  • 9
    @Alex_M Yes, that worked for me. TensorBoard was installed as part of Tensorflow, and I was able to run it using `python .local/lib/python2.7/site-packages/tensorflow/tensorboard/tensorboard.py --logdir=tmp` – Mike Harris Nov 10 '15 at 19:16
  • @Alex_M: Any time you're able to run TensorFlow you should be able to run TensorBoard as well; if you pip installed then you can just use the `tensorboard` command, but running the tensorboard.py file under tensorflow/tensorboard should work as well. – dandelion Nov 11 '15 at 00:23
  • totally curious. since i was running linux in a vm on windows, i organized today a ssd and installed linux on bare-metal. i pip installed tensorflow and I'm now not able to run tensorboard any more. "hich tensorboard" returns nothing – Alex_M Nov 16 '15 at 21:20
  • 4
    I find this answer misleading as ```tensorflow``` isn't needed for ```tensorboard```. Many other ML libraries use ```tensorboard``` for logging so I wouldn't state ```tensorflow``` as a requirement for ```tensorboard```. The correct and simpler response would be directly install tensorboard either with conda or pip, skipping the install of ```tensorflow```. – Vichoko Sep 02 '20 at 20:18
  • what about with conda? – Charlie Parker Jul 20 '21 at 15:37
  • you can do: `conda install -y -c conda-forge tensorboard` – Charlie Parker Jul 20 '21 at 15:38
37

Try typing which tensorboard in your terminal. It should exist if you installed with pip as mentioned in the tensorboard README (although the documentation doesn't tell you that you can now launch tensorboard without doing anything else).

You need to give it a log directory. If you are in the directory where you saved your graph, you can launch it from your terminal with something like:

tensorboard --logdir .

or more generally:

tensorboard --logdir /path/to/log/directory

for any log directory.

Then open your favorite web browser and type in localhost:6006 to connect.

That should get you started. As for logging anything useful in your training process, you need to use the TensorFlow Summary API. You can also use the TensorBoard callback in Keras.

Engineero
  • 12,340
  • 5
  • 53
  • 75
14

If your Tensorflow install is located here:

/usr/local/lib/python2.7/dist-packages/tensorflow

then the python command to launch Tensorboard is:

$ python /usr/local/lib/python2.7/dist-packages/tensorflow/tensorboard/tensorboard.py --logdir=/home/user/Documents/.../logdir

The installation from pip allows you to use:

$ tensorboard --logdir=/home/user/Documents/.../logdir
Mar Cnu
  • 1,165
  • 11
  • 16
  • The path has changed slightly since this answer was written. It is now: `tensorflow/tensorboard/backend/tensorboard.py` (also, `pip show tensorflow` can be used to get the base directory for a particular machine) – Dave Mar 13 '16 at 11:20
9

It may be helpful to make an alias for it.

Install and find your tensorboard location:

pip install tensorboard
pip show tensorboard

Add the following alias in .bashrc:

alias tensorboard='python pathShownByPip/tensorboard/main.py'

Open another terminal or run exec bash.

For Windows users, cd into pathShownByPip\tensorboard and run python main.py from there.

For Python 3.x, use pip3 instead of pip, and don't forget to use python3 in the alias.

nbro
  • 15,395
  • 32
  • 113
  • 196
Dani
  • 519
  • 5
  • 8
8

TensorBoard isn't a separate component. TensorBoard comes packaged with TensorFlow.

nbro
  • 15,395
  • 32
  • 113
  • 196
dandelion
  • 1,742
  • 1
  • 15
  • 18
4

Adding this just for the sake of completeness of this question (some questions may get closed as duplicate of this one).

I usually use user mode for pip ie. pip install --user even if instructions assume root mode. That way, my tensorboard installation was in ~/.local/bin/tensorboard, and it was not in my path (which shouldn't be ideal either). So I was not able to access it.

In this case, running

sudo ln -s ~/.local/bin/tensorboard /usr/bin

should fix it.

0xc0de
  • 8,028
  • 5
  • 49
  • 75
3
pip install tensorflow.tensorboard  # install tensorboard
pip show tensorflow.tensorboard
# Location: c:\users\<name>\appdata\roaming\python\python35\site-packages
# now just run tensorboard as:
python c:\users\<name>\appdata\roaming\python\python35\site-packages\tensorboard\main.py --logdir=<logidr>
Jason
  • 1,974
  • 24
  • 19
3

If you're using the anaconda distribution of Python, then simply do:

 $❯ conda install -c conda-forge tensorboard 

or

 $❯ conda install -c anaconda tensorboard 

Also, you can have a look at various builds by search the packages repo by:

$❯ anaconda search -t conda tensorboard

which would list the channels and the corresponding builds, the supported OS, Python versions etc.,

kmario23
  • 57,311
  • 13
  • 161
  • 150
2

If you installed TensorFlow using pip, then the location of TensorBoard can be retrieved by issuing the command which tensorboard on the terminal. You can then edit the TensorBoard file, if necessary.

nbro
  • 15,395
  • 32
  • 113
  • 196
Vin
  • 69
  • 3
2

The pip package you are looking for is tensorflow-tensorboard developed by Google.

nbro
  • 15,395
  • 32
  • 113
  • 196
Jerry Ajay
  • 1,084
  • 11
  • 26
  • This answer used to be accurate, but no longer is: the package is now simply called `tensorboard`, and `tensorflow-tensorboard` is defunct. – wchargin Mar 12 '19 at 23:54
1

It is better not to mix up the virtual environments or perform installation on the root directory. Steps I took for hassle free installation are as below. I used conda for installing all my dependencies instead of pip. I'm answering with extra details, because when I tried to install tensor board and tensor flow on my root env, it messed up.

  • Create a virtual env

    conda create --name my_env python=3.6

  • Activate virtual environment

    source activate my_env

  • Install basic required modules

    conda install pandas

    conda install tensorflow

  • Install tensor board

    conda install -c condo-forge tensor board

Hope that helps

Gayathry
  • 45
  • 9
0

I have a local install of tensorflow 1.15.0 (with tensorboard obviously included) on MacOS.

For me, the path to the relevant file within my user directory is Library/Python/3.7/lib/python/site-packages/tensorboard/main.py. So, which does not work for me, but you have to look for the file named main.py, which is weird since it apparently is named something else for other users.

demongolem
  • 9,474
  • 36
  • 90
  • 105