我可以从我的大学远程访问另一个远程服务器,通过本地机器进行访问!然而,我的本地机器没有足够的内存来运行多个Jupyter笔记本。有没有办法通过远程服务器来运行它们,可能会加快任务的速度!尽管我不是很确定!
我在macOS终端中访问服务器。 谢谢!
我可以从我的大学远程访问另一个远程服务器,通过本地机器进行访问!然而,我的本地机器没有足够的内存来运行多个Jupyter笔记本。有没有办法通过远程服务器来运行它们,可能会加快任务的速度!尽管我不是很确定!
我在macOS终端中访问服务器。 谢谢!
这里有一个相当不错的教程,在这里
实质上,您只需在无浏览器模式下在远程计算机上运行笔记本电脑即可。
jupyter notebook --no-browser --port=8080
接下来在本地机器上设置一个ssh隧道:
ssh -L 8080:localhost:8080 <REMOTE_USER>@<REMOTE_HOST>
然后在您的本地浏览器中转到:http://localhost:8080/
在特定端口上运行不是必需的,--no-browser
标记是必需的。
我认为您可能正在寻找端口转发功能。
例如,在通过ssh登录到远程主机后,您可以:
On the remote machine, start jupyter notebook from your current directory and specify the port:
jupyter notebook --no-browser --port=9999
On the local machine, catch the forwarded port:
ssh -NfL localhost:9999:localhost:9999 your_user_name@remote_ip_address
Go to http://localhost:9999
. You should be able to select your notebook and you'll be good to go.
您可以在远程服务器终端上运行jupyter notebook --no-browser --ip="<remote server ip>"
,然后从本地机器的浏览器中使用http://:8888/?token=<>访问笔记本。
localuser
,主机为 localhost
,远程用户和远程主机为 remoteuser
和 remotehost
。要从本地计算机上运行远程服务器上的 Jupyter 笔记本,请按照以下步骤操作。
On remote machine run Jupyter notebook with --no-browser
with specifying a port
jupyter notebook --no-browser --port=XXXX
Forward it to your local machine via SSH
ssh -N -f -L localhost:YYYY:localhost:XXXX remoteuser@remotehost
Open a browser and go to http://localhost:YYYY
你可能需要关闭连接
Stop your running notebook with CTRL+C
then y
Kill the process running on port YYYY
, netstat
returns you the process ID (PID)
sudo netstat -lpn | grep :YYYY -> for LINUX
sudo netstat -anv | grep YYYY -> for MacOS
kill PROCESS_ID
要通过浏览器访问远程机器,笔记本必须在外部端口上侦听(而不是localhost)。如果要在容器上运行Jupyter笔记本,您将需要相同的调用。在这种情况下,类似于这样:
jupyter notebook --no-browser --port=8080 --ip=0.0.0.0
只需在本地主机上进行侦听,您可以省略 IP 地址
jupyter notebook --no-browser --port=8080
sshuttle
工具在SSH上模拟VPN,这样您就不必创建多个隧道。使用sshuttle
选项运行,可以完全访问远程机器的网络(例如10.250.100.40/24),或者您可以将所有流量都通过远程机器转发(类似传统VPN)。# forward all traffic to network of remote server over the SSH VPN
sshuttle --dns -NHr username@sshserver 10.250.100.40/24
# forward all traffic through the remote server over the SSH VPN
sshuttle --dns -NHr username@sshserver 0/0
jupyter notebook --no-browser --port=8080 --ip=0.0.0.0
jupyter notebook --no-browser --port=8081 --ip=0.0.0.0
jupyter notebook --no-browser --port=8082 --ip=0.0.0.0
http://server.example.com:8080/tree?token=dd9024f1fb68434645d3902d161f41720650644dc5832f16
http://<name-of-remote-machine>:8080/tree?token=<your-token>
http://<name-of-remote-machine>:8081/tree?token=<your-token>
http://<name-of-remote-machine>:8082/tree?token=<your-token>
在无浏览器模式下使用您的自定义端口号运行jupyter笔记本
jupyter notebook --no-browser --port=8888
然后在本地机器上设置一个ssh隧道:
ssh -L 8888:localhost:8888 <REMOTE_USER>@<REMOTE_HOST>
jupyter notebook --no-browser --ip=<remote-host-ip>
。然后在本地浏览器中复制远程终端中的链接,链接的格式为http://<remote-host-ip>:8888/tree?token=<>
。