Skip to content

Instantly share code, notes, and snippets.

@amoudgl
Last active July 4, 2023 11:27
Show Gist options
  • Save amoudgl/011ed6273547c9312d4f834416ab1d0c to your computer and use it in GitHub Desktop.
Save amoudgl/011ed6273547c9312d4f834416ab1d0c to your computer and use it in GitHub Desktop.
Setup Visdom on Remote Server

Setup Visdom on Remote Server

Install visdom on your local system and remote server.

pip3 install visdom

On remote server, do:

ssh -N -f -L localhost:8097:localhost:8097 username@localsystemip

Set the same port in your python plotting script which you used in the port forwarding step above (8097 here).

Plotting script example [demo.py]:

import visdom
import numpy as np
cfg = {"server": "localhost",
       "port": 8097}
vis = visdom.Visdom('http://' + cfg["server"], port = cfg["port"])
vis.text('Hello Visdom!')
image = np.random.randint(0, 255, (3, 256, 256), dtype=np.uint8)
vis.image(image)

Run plotting script on remote server.

no_proxy=localhost python3 demo.py

Note for Ada: As of now, visdom only works if you have your proxy unset on Ada server. Either unset proxy with export http_proxy= or use no_proxy=localhost before your python command.

Run visdom server on local machine.

visdom

View your plots locally at http://localhost:8097.

@andrewjong
Copy link

andrewjong commented Sep 11, 2019

This is very helpful, thanks very much!
In my case, I didn't have to run visdom on my local machine, only on my remote machine.

@amoudgl
Copy link
Author

amoudgl commented Sep 12, 2019

@andrewjong Glad to hear that, thanks for your feedback!

@shruthi0898
Copy link

Hello, when I run the command: ssh -N -f -L localhost:8097:localhost:8097 username@localipaddress -v
I get the following:
OpenSSH_7.6p1 Ubuntu-4ubuntu0.3, OpenSSL 1.0.2n 7 Dec 2017
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: Connecting to 10.130.176.192 [10.130.176.192] port 22.
debug1: Connection established.
debug1: key_load_public: No such file or directory
debug1: identity file /home/shri/.ssh/id_rsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/shri/.ssh/id_rsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/shri/.ssh/id_dsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/shri/.ssh/id_dsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/shri/.ssh/id_ecdsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/shri/.ssh/id_ecdsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/shri/.ssh/id_ed25519 type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/shri/.ssh/id_ed25519-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_7.6p1 Ubuntu-4ubuntu0.3

Can you please help?

@andrewjong
Copy link

andrewjong commented Dec 2, 2019

@shruthi0898 The error says there are issues with your ssh key. Did you make sure to set up your ssh key correctly on your local machine, then register that key with the remote machine? Check if you can ssh normally into the remote machine.

@shruthi0898
Copy link

@shruthi0898 The error says there are issues with your ssh key. Did you make sure to set up your ssh key correctly on your local machine, then register that key with the remote machine? Check if you can ssh normally into the remote machine.

Hello, I am able to ssh into the remote server, but not sure about key setup and registering, can you please help? I am new to this.

@amoudgl
Copy link
Author

amoudgl commented Dec 2, 2019

@shruthi0898 Looks like your ssh key is missing but still I think you should be able to run the command by using your system password (see this). I guess you didn't post the complete log here. If you want, you can properly setup ssh keys by following this tutorial.

To be able to run the command given in the gist, you should be able to ssh into your local system (where you are running browser for visdom) from remote server NOT vice-versa. If you are not able to do so, you may try the following:

  1. Run visdom on your remote machine with a particular port: visdom -port 8998
  2. Run the ssh command on your local machine: ssh -N -f -L localhost:8998:localhost:8998 remote_username@remote_machine_ip
  3. Navigate to http://localhost:8998 on your local machine for visdom.

@patrick100
Copy link

thanks so much

@DakotaFan
Copy link

Hi there I can not use Visdom on the hpc cluster, and error message states that the Connection is refused.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment