Dongyang's learning record, persistence is victory!
Article directory
The pytorch visdom service running in colab cannot be accessed directly through the port in colab, not much BB, see the code:
Open the service (the port can be determined by yourself)
! npm install -g localtunnel
# 8097是我自己设置的端口号,可修改为自己要用的端口号
get_ipython().system_raw('python3 -m pip install visdom')
get_ipython().system_raw('python3 -m visdom.server -port 8097 >> visdomlog.txt 2>&1 &')
get_ipython().system_raw('lt --port 8097 >> url.txt 2>&1 &')
import time
time.sleep(5)
! cat url.txt
import visdom
time.sleep(5)
vis = visdom.Visdom(port='8097')
print(vis)
time.sleep(3)
vis.text('testing')
! cat visdomlog.txt
Make local browser accessible
output in notebook
from google.colab import output
output.serve_kernel_port_as_iframe(8097)
Access in a browser window
from google.colab import output
output.serve_kernel_port_as_window(8097)
A URL will be output:
click on OK! (Opens in a new tab!)