Yuka
Yuka

Reputation: 51

Tensorboard Not Found

I'm trying to use tensorboard dashboard to check the model performance. Below is the code I used:

from keras.callbacks import TensorBoard
%load_ext tensorboard

log_dir = "logs/fit/" + datetime.now().strftime("%Y%m%d-%H%M%S")

tensorboard_callback = TensorBoard(log_dir=log_dir, histogram_freq=1)

checkpoint_name = 'Weights-{epoch:03d}--{val_loss:.5f}.hdf5' 

checkpoint = ModelCheckpoint(checkpoint_name, monitor='val_loss', verbose = 1, save_best_only = True, mode ='auto')

es = EarlyStopping(monitor='val_loss', verbose=1, patience=10)

callbacks_list = [checkpoint ,es,tensorboard_callback]

NN_model.fit(train, target, epochs=100, batch_size=32, validation_split = 0.2, callbacks=callbacks_list)

But after the model training, I could not display the dashboard:

%tensorboard --logdir logs

Here's the error I got:

ERROR: Could not find `tensorboard`. Please ensure that your PATH
contains an executable `tensorboard` program, or explicitly specify
the path to a TensorBoard binary by setting the `TENSORBOARD_BINARY`
environment variable.

Upvotes: 4

Views: 12768

Answers (3)

Pallav
Pallav

Reputation: 342

  1. install tensorboard if not installed already pip3 install tensorboard
  2. check the location of package using command pip3 show tensorboard

you will see output like this

Name: tensorboard
Version: 2.12.0
Summary: TensorBoard lets you watch Tensors Flow
Home-page: https://github.com/tensorflow/tensorboard
Author: Google Inc.
Author-email: packages@tensorflow.org
License: Apache 2.0
Location: /Users/admin/Library/Python/3.9/lib/python/site-packages
Requires: protobuf, wheel, tensorboard-plugin-wit, numpy, setuptools, requests, google-auth-oauthlib, absl-py, grpcio, werkzeug, markdown, tensorboard-data-server, google-auth
Required-by:

copy the 'Location' ( in this case /Users/admin/Library/Python/3.9/lib/python/site-packages) and run the tensorboard by running python3 <Locaton copied>/tensorboard/main.py --logdir=<log dir path>

eg:

python3 /Users/admin/Library/Python/3.9/lib/python/site-packages/tensorboard/main.py --logdir=./

this will start tensorboard and show the URL as below:

TensorFlow installation not found - running with reduced feature set.
Serving TensorBoard on localhost; to expose to the network, use a proxy or pass --bind_all
TensorBoard 2.12.0 at http://localhost:6006/ (Press CTRL+C to quit)

you can now open the url( in this case http://localhost:6006/) to view tensorboard

Upvotes: 1

Darknessest
Darknessest

Reputation: 81

It probably happens because of some conflict between notebook and virtual environment.

An easy solution here would be just to specify TENSORBOARD_BINARY variable right in your notebook, so it won't interfere with global variables, before calling tensorboard like that:

os.environ['TENSORBOARD_BINARY'] = '/path/to/envs/my_env/bin/tensorboard'

A longterm solution would be to set up a variable for virtual environment like it was proposed here.

Upvotes: 8

Rajith Thennakoon
Rajith Thennakoon

Reputation: 4130

You need to execute tensorboard command on terminal to open the tensorboard server.

command should be

tensorboard --logdir="<path to your logdir>"

Upvotes: -1

Related Questions