您的位置:首页 > 运维架构 > Linux

本地Windows系统连接远程Linux服务器系列(三)--jupyter notebook的使用

2019-03-31 00:19 736 查看
版权声明:本文为博主原创文章,遵循 CC 4.0 by-sa 版权协议,转载请附上原文出处链接和本声明。 本文链接:https://blog.csdn.net/kfyang_0/article/details/88918502

 

概览

主要有以下几个部分

1. 安装jupyter notebook

2. 设置jupyter notebook可远程访问

3. 非常关键的一点

4. 参考博文和资源

 

    自己用的深度学习集成开发环境(IDE)为jupyter notebook,可以在本地浏览器调用远程服务器的jupyter notebook,看起来就像自己笔记本上的IDE,不同的是有服务器强大的性能为其提供支撑。

    jupyter notebook的文档https://jupyter-notebook.readthedocs.io/en/latest/public_server.html#notebook-server-security

1. 安装jupyter notebook

    一种方法是下载安装ananconda,里面有自带的jupyter notebook。另一种是使用pip(更换pip源)来安装pip install jupyter。

可参考:

如何在Ubuntu 18.04上安装Anaconda https://cloud.tencent.com/developer/article/1349098

Jupyter notebook使用指南 https://cloud.tencent.com/developer/article/1082691

 

2. 设置jupyter notebook可远程访问

(1) 在远程服务器上,生成notebook的配置文件。

[code]jupyter notebook --generate-config

    如果是 root 用户执行上面的命令,可能会出现:

[code]Running as root it not recommended. Use --allow-root to bypass.

    此时需要这样:

[code]jupyter notebook --generate-config --allow-config

    执行成功后,会出现下面的信息:

[code]Writing default config to: /root/.jupyter/jupyter_notebook_config.py

 (2) 生成密码

    运行python,逐语句输入如下代码,将生成的‘sha1:ce23*************************’复制下来,后面会用到

[code]~#python
from notebook.auth import passwd
passwd()
Enter password:
Verify password:
Out[2]: 'sha1:ce23d945972f:34769685a7ccd3d08c84a18c63968a41f1140274'

(3) 修改默认配置文件

[code]#用vim打开jupyter_notebook_config.py配置文件
vim /home/ubuntu/.jupyter/jupyter_notebook_config.py

#添加如下语句
# 将ip设置为*,意味允许任何IP访问
c.NotebookApp.ip = '*'
# 这里的密码就是上边我们生成的那一串
c.NotebookApp.password= u'sha1:1e39d24dcd6c:b265321ca0c4cb798888bcb69b0024983a8ac439'
# 服务器上并没有浏览器可以供Jupyter打开
c.NotebookApp.open_browser = False
# 监听端口设置为8888或其他自己喜欢的端口
c.NotebookApp.port = 8888
# 我们可以修改jupyter的工作目录,也可以保持原样不变,如果修改的话,要保证这一目录已存在
#c.MappingKernelManager.root_dir = '/home/ubuntu/.jupyter_run/root'
# 允许远程访问
c.NotebookApp.allow_remote_access = True

(4)在服务器启动notebook

    在服务器上启动 jupyter notebook,root 用户使用 

jupyter notebook --allow-root,此时

    显示出http,

 

3. 非常关键的一点

    查找的网上绝大多数文档,到上面就说能在本地浏览器里输入“服务器IP:8888”和Password,就可以远程访问了。但我却碰到网页丢失或者是提示防火墙和代理的问题(360、IE、chrom)。

    经过多方查阅和实践,发现还需要将端口转发一下(有时候也称为构建通道),我理解的是,把远程服务器的端口映射到本地端口,然后通过本地端口访问远程端口。本次是使用SecureCRT进行的,如下:

(1)先用这句~# jupyter notebook --allow-root,查看jupyter notebook当下使用的端口号。

(2)在Options——Session Options——Port Forwarding——Add,设置相同的端口号。

 

 

(3)此时在本地浏览器,输入网址的位置,将服务器IP:设置的端口号输入。再输入Password,就可以使用jupyter notebook了。

 

 

4. 参考博文和资源

设置 jupyter notebook 可远程访问 https://www.geek-share.com/detail/2713269688.html

远程访问jupyter notebook https://www.geek-share.com/detail/2682361700.html

Jupyter Notebook 远程连接及配置方法说明 https://www.jianshu.com/p/08f276d48669?utm_campaign=maleskine&utm_content=note&utm_medium=seo_notes&utm_source=recommendation

ssh正向和反向隧道建立,及socks4/5代理 https://www.geek-share.com/detail/2698084164.html

远程访问服务器Jupyter Notebook的两种方法 https://www.jianshu.com/p/8fc3cd032d3c

Windows+Jupyter Notebook+SecureCRT+Ubuntu+Docker配置tensorflow https://blog.csdn.net/qq_23216827/article/details/80460389

基于docker的服务器端使用jupyter notebook的方法 https://blog.csdn.net/weixin_40008349/article/details/81135847

Win10下远程访问服务器 + Jupyter Notebook 简明教程  https://www.geek-share.com/detail/2730830148.html

jupyter 远程访问配置:KeyError: 'allow_remote_access' https://blog.csdn.net/w5688414/article/details/82927564

利用本地浏览器远程服务器上的jupyter notebook https://www.cnblogs.com/qiangzi0221/p/8933722.html

 

 

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: