Using visdom for visualization on a cluster server

username: ZSheikhb
cooked: <p>I’d like to use <code>visdom</code> to visualize the results of my deep learning algorithm which has been running on a remote cluster server. First I am wondering whether I should use special command line to connect via <code>ssh</code> to the cluster or not to be able to see the visdom plots?</p>
<p>In my slurm script I added the following command line:<br>
<code>python -u script.py --visdom_server "http://ncc1.clients.dur.ac.uk" --visdom_port 8098</code></p>
<p>and in my python script, I have</p>
<pre><code class="lang-auto">#Plotting on remote server
import visdom
cfg = {"server": "ncc1.clients.dur.ac.uk",
       "port": 8098}
vis = visdom.Visdom('http://' + cfg["server"], port = cfg["port"])

win = None

def update_viz(epoch, loss, title):
    global win

    if win is None:
        title = title

        win = viz.line(
            X=np.array([epoch]),
            Y=np.array([loss]),
            win=title,
            opts=dict(
                title=title,
                fillarea=True
            )
        )
    else:
        viz.line(
            X=np.array([epoch]),
            Y=np.array([loss]),
            win=win,
            update='append'
        )
</code></pre>
<p>I was wondering whether anybody has the experience or a sample code related to saving the visdom plot as a <code>jason</code> file?</p>
<p>I got the following error:</p>
<pre><code class="lang-auto">requests.exceptions.InvalidURL: Failed to parse: http://http::8098/env/main
Port could not be cast to integer value as ':8098'
on_close() takes 1 positional argument but 3 were given
Port could not be cast to integer value as ':8098'
on_close() takes 1 positional argument but 3 were given
Visdom python client failed to establish socket to get messages from the server. This feature is optional and can be disabl
ed by initializing Visdom with `use_incoming_socket=False`, which will prevent waiting for this request to timeout.
Port could not be cast to integer value as ':8098'
on_close() takes 1 positional argument but 3 were given
script.py:41: UserWarning: To copy construct from a tensor, it is recommended to use sourceTensor.clone().d
etach() or sourceTensor.clone().detach().requires_grad_(True), rather than torch.tensor(sourceTensor).
  params['w'].append(nn.Parameter(torch.tensor(Normal(torch.zeros(n_in, n_out), std * torch.ones(n_in, n_out)).rsample(), r
equires_grad=True, device=device)))
Port could not be cast to integer value as ':8098'
on_close() takes 1 positional argument but 3 were given
script.py:42: UserWarning: To copy construct from a tensor, it is recommended to use sourceTensor.clone().d
etach() or sourceTensor.clone().detach().requires_grad_(True), rather than torch.tensor(sourceTensor).
  params['b'].append(nn.Parameter(torch.tensor(torch.mul(bias_init, torch.ones([n_out,])), requires_grad=True, device=devic
e)))
script.py:292: UserWarning: To copy construct from a tensor, it is recommended to use sourceTensor.clone().
detach() or sourceTensor.clone().detach().requires_grad_(True), rather than torch.tensor(sourceTensor).
  return torch.exp(torch.lgamma(torch.tensor(a, dtype=torch.float, requires_grad=True).to(device=local_device)) + torch.lga
mma(torch.tensor(b, dtype=torch.float, requires_grad=True).to(device=local_device)) - torch.lgamma(torch.tensor(a+b, dtype=
torch.float, requires_grad=True).to(device=local_device)))
script.py:679: UserWarning: This overload of add_ is deprecated:
	add_(Number alpha, Tensor other)
Consider using one of the following signatures instead:
	add_(Tensor other, *, Number alpha) (Triggered internally at  /opt/conda/conda-bld/pytorch_1631630815121/work/torch
/csrc/utils/python_arg_parser.cpp:1025.)
  exp_avg.mul_(beta1).add_(1 - beta1, grad)
Port could not be cast to integer value as ':8098'
on_close() takes 1 positional argument but 3 were given
Traceback (most recent call last):
  File "script.py", line 871, in &lt;module&gt;
    update_viz(epoch, elbo2.item(),' KL Loss by Epoch')
  File "script.py", line 736, in update_viz
    win = viz.line(
NameError: name 'viz' is not defined

</code></pre>
<p>Can anyone suggest a way to use visdom for plotting? Thanks.</p>