How to use the tensorboard on a remote server

Tensorboard is a very convenient tools for tensorflow, whihc allows us to view the summaries of the running experiments in the browser. However, for the people who study the DNNs, it is very common to run the experiment on a remote server with GPUs. So how could we use tensorboard on our own PC to monitor the experiment on the server?

  1. You need to start SSH with transfer the remote server’s port to your local PC:

    (on your local PC) ssh -L 16007:127.0.0.1:16007 username@server_ip
  2. Then you may start the tensorboard on the remote server with the specific port we want to transfer:

    (on the remote server) tensorboard --logdir='./tensorboard_dirs' --port=16007

But sometime, we need to connect to a contact server, than connect to the GPU server via this contact. In this case, we need to do one more step to transfer the port:

  1. Transfer the port from the contact server to your own PC via SSH:

    (on your local PC) ssh -L 16007:127.0.0.1:16007 username@contact_server_ip
  2. Transfer the port from the GPU server to the contact:

    (on the contact server) ssh -L 16007:127.0.0.1:16007 username@GPU_server_ip
  3. Then start the tensorboard on the GPU server:

    (on the GPU server) tensorboard --logdir='./tensorboard_dirs' --port=16007

Now you’re able to view the tensorboard on your own PC!