EDAS
EDAS

Reputation: 21

Tensorflow Tensorboard (Ngrok) on Google Colab

I am trying to make a custom Object Detection Model on Google Colab. I am facing problem to launch Tensorboard. Just before start the Training I ran the below commands for Ngrok.

!wget https://bin.equinox.io/c/4VmDzA7iaHb/ngrok-stable-linux-amd64.zip
!unzip ngrok-stable-linux-amd64.zip

LOG_DIR = '/tmp/log'
get_ipython().system_raw(
    'tensorboard --logdir {} --host 0.0.0.0 --port 6006 &'
    .format(LOG_DIR)
)

get_ipython().system_raw('./ngrok http 6006 &')

!curl -s http://localhost:4040/api/tunnels | python3 -c \
    "import sys, json; print(json.load(sys.stdin)['tunnels'][0]['public_url'])"

And got output with URL like this.

Then I started training and after that I went to the URL. But no data found there. Can anyone advise where I am making mistake ?

Also one more ques ... I found to stop the Training I need to use Ctrl+C. But how to send Ctrl+C on Colab Notebook?

Thanks in advance.

Regards.

Upvotes: 2

Views: 2729

Answers (1)

wchargin
wchargin

Reputation: 16037

Using Ngrok to get a tunnel to a TensorBoard instance in Colab used to be a fairly common practice, but it’s not needed anymore: TensorBoard has built-in support for notebook environments, including Colab and Jupyter. After loading the tensorboard notebook extension, you can just start your command line with %tensorboard, and it should just work:

%load_ext tensorboard  # only needed once (e.g., at top of notebook)

%tensorboard --logdir logs

Screenshot of TensorBoard running in Colab

You also don’t need to set the host and port (though you can; it should still work as long as the host resolves), and you don’t need to run in the background. The TensorBoard instance shown in the notebook will continue to refresh live as you write more training data from your Colab notebook.

For more details, you can take a look at the docs for “Using TensorBoard in Notebooks”.

(Disclosure: I work on TensorBoard and implemented this functionality.)

Upvotes: 5

Related Questions