How can I run Tensorboard on a remote server?
I'm new to Tensorflow and would greatly benefit from some visualizations of what I'm doing. I understand that Tensorboard is a useful visualization tool, but how do I run it on my remote Ubuntu machine?
Here is what I do to avoid the issues of making the remote server accept your local external IP:
- when I ssh into the machine, I use the option
-L
to transfer the port6006
of the remote server into the port16006
of my machine (for instance):ssh -L 16006:127.0.0.1:6006 olivier@my_server_ip
What it does is that everything on the port 6006
of the server (in 127.0.0.1:6006
) will be forwarded to my machine on the port 16006
.
- You can then launch tensorboard on the remote machine using a standard
tensorboard --logdir log
with the default6006
port - On your local machine, go to http://127.0.0.1:16006 and enjoy your remote TensorBoard.
You can port-forward with another ssh
command that need not be tied to how you are connecting to the server (as an alternative to the other answer). Thus, the ordering of the below steps is arbitrary.
-
from your local machine, run
ssh -N -f -L localhost:16006:localhost:6006 <user@remote>
-
on the remote machine, run:
tensorboard --logdir <path> --port 6006
-
Then, navigate to (in this example) http://localhost:16006 on your local machine.
(explanation of ssh command:
-N
: no remote commands
-f
: put ssh in the background
-L <machine1>:<portA>:<machine2>:<portB>
:
forward <machine1>:<portA>
(local scope) to <machine2>:<portB>
(remote scope)
You don't need to do anything fancy. Just run:
tensorboard --host 0.0.0.0 <other args here>
and connect with your server url and port. The --host 0.0.0.0
tells tensorflow to listen from connections on all IPv4 addresses on the local machine.
Another option if you can't get it working for some reason is to simply mount a logdir directory on your filesystem with sshfs:
sshfs user@host:/home/user/project/summary_logs ~/summary_logs
and then run Tensorboard locally.