当前位置:网站首页>Remote access to tensorboard

Remote access to tensorboard

2022-06-10 11:38:00 MallocLu

Application scenarios

The code runs on the remote server , We want to get its running status ( For example, current losses 、 Accuracy, etc )

Method 1 : Use SSH Connect , from terminal Output understanding of ( If SSH Broken line or network , The program being executed will stop , Reconnection requires a rerun , We can match tmux To guarantee SSH The disconnection procedure does not terminate )

Method 2 : Write the running data in the program Tensorboard, Use SSH The tunnel function of maps the port of the remote host to the local port . Use tmux Start two session, One session Middle run program , the other one session Start in Tensorboard.

Method 1 demonstration

# test.py

import time

for i in range(100000):
    time.sleep(1)
    print(i)

  1. Use XShell Connect to remote host
  2. tmux new -s test, Create a new one called test Of session
  3. python test.py Execution procedure , It continuously outputs incrementing integers

Method 2 demonstration

# test.py

from torch.utils.tensorboard import SummaryWriter
import time

writer = SummaryWriter("logs")

for i in range(100000):
    time.sleep(1)
    print(i)
    writer.add_scalar("tttt", i ** 2 + 1, i)

writer.close()

  1. stay XShell The left session manager window On the current active session Right click -> attribute -> Connect ->SSH-> Tunnel -> add to

    The figure below Red box You can choose the port number in

    image-20220526102050241

  2. tmux new -s test Create a new one called test Of session

    python test.py Execution procedure , It will continue to Tensorboard Write an incrementing integer

    ctrl+b+d Exit the current session without terminating the running program test.py

  3. tmux new -s tb Create a new one tb Of session

    Execution instruction tensorboard --logdir=logs --port=<port_name> start-up Tensorboard

    ​ 1) stay logs Execute the command in the path where the folder is located , Otherwise it would be logs Change to relative path or absolute path

    ​ 2) --port=<port_name> by 1 The port number in the red box , If you use 6006, Then it can be abbreviated as tensorboard --logdir=logs

    ctrl+b+d Exit the current session without terminating the running Tensorboard

  4. In local browser Input http://localhost:<port_name> or http://127.0.0.1:<port_name> visit , The page will not refresh automatically , Get the latest data through manual refresh ( Upper right corner Tensorboard Refresh / The browser in the upper left corner is refreshed )

原网站

版权声明
本文为[MallocLu]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/161/202206101132290569.html