Search code examples
google-cloud-platformtensorboard

How to Use Tensorboard Directly on GCP Without Terminal?


Is it possible to use Tensorboard on GCP directly from Jupyter Lab? I already gave the method of the second answer from this question a try, but it doesn't work in GCP (I get this error): enter image description here

I would like to avoid doing things from the terminal (because I don't really understand where I have to do what), that's why I am asking.


Solution

  • It is not yet possible to use Tensorboard in GCP AI Platform Notebooks. There is a workaround for this but it involves running a few commands. It is up to you if you'd like to try this out on your project.

    NOTE: Steps provided were tested using CloudShell. You can check this on how to open/use the CloudShell.

    1. Make sure that the notebook has tcp:22 ingress allowed. If not, create a firewall rule to allow it.

      gcloud compute firewall-rules create default-allow-ssh --allow tcp:22

    2. Open a terminal in your notebook and start Tensorboard on a port of choice (here we've chosen 7000). Make sure to specify the right logs dir that TensorBoard can read from. Just let it run.

      tensorboard --port=7000 --logdir logs enter image description here

    3. Open a terminal on local machine OR in CloudShell, SSH into the notebook VM and port forward 7000 to localhost:7000 to see the TensorBoard in your local browser.

      gcloud beta compute ssh --zone "zone-of-your-instance" "name-of-the-notebook-instance" --project "your-project-name-here" -- -L 7000:localhost:7000

      enter image description here

    4. If you did Step 3 in your local machine then you open http://127.0.0.1:7000/ in your local browser to access TensorBoard for that VM.

    5. If you did step 3 in CloudShell, you need to access the local host of cloud shell.

    • Click Web Preview

    • Click Change Port and put 7000

      enter image description here enter image description here

    • The web page will be opened and you can use Tensorboard

      enter image description here