1

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.

1 Answers1

2

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

Ricco D
  • 6,873
  • 1
  • 8
  • 18
  • Hi Ricco, thanks a lot! I did it once and it seems to work; (i) do I need to follow these steps every time I start my GCP notebook instance again? (ii) Do I somehow need to log out of TensorBoard when closing the instance? (iii) Will the images on Tensorboard be saved for next time? – Hulio Almedo Feb 17 '21 at 20:53
  • @HulioAlmedo i) Yes you need to follow the steps every time you open the instance. ii) Yes, logging out of the instance will ensure proper disconnection from tensorboard. iii) As long as the images are stored in `logs` directory in your instance, and you did not delete them manually, they should be saved for the next time you use them. – Ricco D Feb 18 '21 at 02:35
  • Hi Ricco, I upvoted and accepted your answer. Could you please answer me one more thing: When I have the log files in the folder `logs`, I can download them. Is it possible to view the download log-files locally on one's PC? – Hulio Almedo Feb 24 '21 at 19:15
  • @HulioAlmedo in your cloud shell or if you have installed the google cloud SDK you can run `gcloud compute scp your-instance-name:/your_full_path_of_logs_dir/ your_full_destination_path_here`. You can check this for [reference](https://cloud.google.com/compute/docs/instances/transfer-files). But if you have further questions, I suggest that you post another question on how to download files on an instance to your local directory. Just so the community can contribute as well. – Ricco D Feb 25 '21 at 01:44