简体   繁体   English

将 Jupyter 笔记本连接到远程服务器

[英]Connecting Jupyter notebook to Remote server

I have a linux server.我有一个 linux 服务器。 On that I have installed Miniconda3 and other python packages along with Jupyter.我已经安装了 Miniconda3 和其他 python 软件包以及 Jupyter。

Now I want to run the notebook on the server and open in my browser.现在我想在服务器上运行笔记本并在我的浏览器中打开。

For that, after installation of all packages, I do:为此,在安装所有软件包后,我会:

user@remoteip:$ jupyter notebook --no-browser --port=8890

Now I am copying the server IP address along with port to open it in my local browser.现在我正在复制服务器 IP 地址以及端口以在本地浏览器中打开它。

http://remoteip:8890

However it doesn't open up anything.然而它并没有打开任何东西。

I then followed all suggestions given in this SO answer by adding the required statements in the configuration file on the remote server anaconda and even local anaconda jupyter config file.然后,我通过在远程服务器 anaconda 甚至本地 anaconda jupyter 配置文件的配置文件中添加所需的语句来遵循此 SO 答案中给出的所有建议。

But it doesn't help at all.但这根本没有帮助。

After that I had to port forwarding as below in my local terminal:之后,我必须在本地终端中进行如下端口转发:

user@localhost: ssh -N -f -L localhost:8890:localhost:8890 user@remoteip

And after that when I open然后当我打开

localhost:8890 

now it opens up the notebook requiring the token to be entered and then it works.现在它打开需要输入令牌的笔记本,然后它就可以工作了。

My question is that do we need to do port forwarding everytime for us to open a notebook on remote server?我的问题是,我们是否需要每次都进行端口转发才能在远程服务器上打开笔记本? One of my colleague said he didn't do any port forwarding and after first step itself, he was able to open the notebook with by typing我的一位同事说他没有进行任何端口转发,并且在第一步之后,他能够通过键入打开笔记本

http://remoteip:8890 http://remoteip:8890

So I am not sure we need to do port forwarding for us to open the server jupyter notebook to open in browser or we can directly open the notebook with remoteip address?所以我不确定我们是否需要进行端口转发才能打开服务器 jupyter notebook 以在浏览器中打开,或者我们可以直接使用 remoteip 地址打开笔记本?

Edit:编辑:

As per Alex's suggestion below, ran the following command after logging into dev server.根据下面 Alex 的建议,在登录开发服务器后运行以下命令。

(ds_env) user@devvm1049:~$ jupyter notebook --no-mathjax --no-browser --ip 0.0.0.0 --port 8890
[I 23:49:56.032 NotebookApp] Serving notebooks from local directory: /home/user
[I 23:49:56.032 NotebookApp] The Jupyter Notebook is running at:
[I 23:49:56.032 NotebookApp] http://devvm.cdw.com:8890/
[I 23:49:56.032 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).

Copied the above link to both chrome and Safari but it didn't open anything.将上述链接复制到 chrome 和 Safari 但它没有打开任何东西。

I have already done the above suggestions in this post.我已经在这篇文章中完成了上述建议。 The only thing that has worked until now is doing Port tunneling but that is 3 steps everytime one has to open the jupyter on remote server.到目前为止,唯一有效的方法是进行端口隧道,但每次必须在远程服务器上打开 jupyter 时都需要 3 个步骤。

Is this can be some port blocking issue?这可能是一些端口阻塞问题吗? I tried pinging the remote server on laptop and it didn't give me any ping.我尝试在笔记本电脑上 ping 远程服务器,但它没有给我任何 ping。

If you specify the --ip option when starting the server you can allow remote connection without port forwarding.如果在启动服务器时指定--ip选项,则可以允许远程连接而无需端口转发。

jupyter notebook --no-mathjax --no-browser --ip 0.0.0.0 --port 8890
# The --no-mathjax improves loading over slow connections

This is not recommended, though.但是,建议这样做。 See running a public jupyter notebook server .请参阅运行公共 jupyter 笔记本服务器 If you do this, I strongly recommend that you set a password, as described in that link.如果您这样做,我强烈建议您设置密码,如该链接中所述。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM