Can I Use TensorBoard With Google Colab?


Answer :

EDIT: You probably want to give the official %tensorboard magic a go, available from TensorFlow 1.13 onward.


Prior to the existence of the %tensorboard magic, the standard way to achieve this was to proxy network traffic to the Colab VM using ngrok. A Colab example can be found here.

These are the steps (the code snippets represent cells of type "code" in colab):

  1. Get TensorBoard running in the background.
    Inspired by this answer.

    LOG_DIR = '/tmp/log' get_ipython().system_raw(     'tensorboard --logdir {} --host 0.0.0.0 --port 6006 &'     .format(LOG_DIR) ) 
  2. Download and unzip ngrok.
    Replace the link passed to wget with the correct download link for your OS.

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

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

    ...and retrieve public url. Source

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

Many of the answers here are now obsolete. So will be mine I'm sure in a few weeks. But at the time of this writing all I had to do is run these lines of code from colab. And tensorboard opened up just fine.

%load_ext tensorboard %tensorboard --logdir logs 

Here's an easier way to do the same ngrok tunneling method on Google Colab.

!pip install tensorboardcolab 

then,

from tensorboardcolab import TensorBoardColab, TensorBoardColabCallback  tbc=TensorBoardColab() 

Assuming you are using Keras:

model.fit(......,callbacks=[TensorBoardColabCallback(tbc)]) 

You can read the original post here.


Comments

Popular posts from this blog

Are Regular VACUUM ANALYZE Still Recommended Under 9.1?

Can Feynman Diagrams Be Used To Represent Any Perturbation Theory?