• jupyter 远程访问


    Jupyter 远程访问

    jupyter 远程访问的工作方法是,在本地通过浏览器打开jupyter,但是代码和服务运行在远程集群中。

    集群设置

    首先需要确保集群中安装有python和jupyter。
    在集群 /opt/intel/2019 目录下,已经安装好python3和jupyter。将其添加入环境变量中

    export PATH=/opt/intel/2019/intelpython3/bin:${PATH}
    

    随后对python路径进行检查,可以看出此时已经在调用intel python。

    $ which python
    /opt/intel/2019/intelpython3/bin/python
    

    随后用以下命令对 jupyter 进行设置,设置 jupyter 登录密码。

    $ jupyter notebook --generate-config
    
    $ jupyter notebook password
    Enter password:  ****
    Verify password: ****
    

    此时在个人目录下就生成了 jupyter 配置文件 jupyter_notebook_config.py
    对配置文件进行修改,增加以下设置

    c.NotebookApp.ip='*' # 星号代表任意ip,这个跟mysql的权限设置一样,所以说知识是互通的
    c.NotebookApp.allow_remote_access = True # 允许远程连接
    c.NotebookApp.password = u'sha1:xxx' # 复制密码在此 
    c.NotebookApp.open_browser = False # 不自动打开浏览器
    c.NotebookApp.port = 6666 # 指定端口, 访问时使用
    

    注意在设置端口时给定一个较大的整数,22 或 24 等常用端口时不可以的。
    此时即可在命令行中启动jupyter notebook服务,会显示以下内容:

    $ jupyter notebook
    [W 14:01:28.051 NotebookApp] Collisions detected in /home/lilongxiang/.jupyter/jupyter_notebook_config.py and /home/lilongxiang/.jupyter/jupyter_notebook_config.json config files. /home/lilongxiang/.jupyter/jupyter_notebook_config.json has higher priority: {
          "NotebookApp": {
            "password": "'sha1:llx891209' ignored, using 'sha1:a221858aea95:923e3211599640af335a06052fcea5818f118621'"
          }
        }
    [W 14:01:28.054 NotebookApp] Config option `allow_remote_access` not recognized by `NotebookApp`.  Did you mean one of: `allow_credentials, allow_root`?
    [W 14:01:28.206 NotebookApp] WARNING: The notebook server is listening on all IP addresses and not using encryption. This is not recommended.
    [I 14:01:28.213 NotebookApp] Serving notebooks from local directory: /home/lilongxiang
    [I 14:01:28.213 NotebookApp] 0 active kernels
    [I 14:01:28.213 NotebookApp] The Jupyter Notebook is running at:
    [I 14:01:28.213 NotebookApp] http://[all ip addresses on your system]:1224/
    [I 14:01:28.213 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
    [I 14:01:41.532 NotebookApp] 302 GET / (10.155.11.18) 0.50ms
    

    本地登录

    注意上面内容中,提示可以使用任意ip地址登录Notebook服务。在本地网页浏览器中,以集群IP地址代替。如集群IP为10.166.15.60,在本地浏览器中输入

    https://10.166.15.60:1224/
    

    随后即可登录集群jupyter notebook服务进行操作。

  • 相关阅读:
    pycharm2018.1下载激活(mac平台)
    python 保存登录状态 cookie
    utf-8和utf-8-sig的区别
    AcWing 803. 区间合并
    AcWing 801. 二进制中1的个数
    AcWing 800. 数组元素的目标和
    AcWing 799. 最长连续不重复子序列
    AcWing 795. 前缀和
    AcWing 791. 高精度加法 解题记录
    九州缥缈录 合集序言
  • 原文地址:https://www.cnblogs.com/li12242/p/11685387.html
Copyright © 2020-2023  润新知