zoukankan      html  css  js  c++  java
  • 机器学习环境配置系列六之jupyter notebook远程访问

    jupyter运行后只能在本机运行,如果部署在服务器上,大家都希望可以远程录入地址进行访问,这篇文章就是解决这个远程访问的问题。几个基本的命令就可以搞定,然后就可以愉快的玩耍了。

    1、安装jupytetr

    conda install jupyter

    2、远程访问配置

    jupyter notebook --generate-config
    jupass = 'python -c"from notebook.auth
    import passwd; print(passwd())"'
    
    echo "c.NotebookApp.password = u'"$jupass"'" >> .jupyter/jupyter_notebook_config.py
    
    echo "c.NotebookApp.ip = '*'
    c.NotebookApp.open_browser = Flase
    c.NotebookApp.port = 端口号">> .jupyter/jupyter_notebook_config.py
    

      注:如果服务器是固定ip地址,c.NotebookApp.ip 也可以指定固定的ip更稳定

    3、开启linux端口命令

    /sbin/iptables -I INPUT -p tcp --dport 80 -j ACCEPT #开启80端口 
    /sbin/iptables -I INPUT -p tcp --dport 22 -j ACCEPT #开启22端口 
    /etc/rc.d/init.d/iptables save #保存配置 
    /etc/rc.d/init.d/iptables restart #重启服务 
    查看已开放端口 
    /etc/init.d/iptables status 

    4、启动jupyter

    jupyter notebook
    

      启动信息如下:

    [I 18:52:57.324 NotebookApp] Serving notebooks from local directory: /home/用户名
    [I 18:52:57.324 NotebookApp] The Jupyter Notebook is running at:
    [I 18:52:57.324 NotebookApp] http://ip:port/
    [I 18:52:57.324 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
    [I 19:17:27.484 NotebookApp] Kernel started: 78d6fb00-dadd-4cfa-91d8-7102d7907599
    [I 19:17:31.084 NotebookApp] Adapting to protocol v5.1 for kernel 78d6fb00-dadd-4cfa-91d8-7102d7907599
    [W 19:17:47.801 NotebookApp] 404 GET /nbextensions/widgets/notebook/js/extension.js?v=20181024185257 10.92ms re

    5、字符集问题

    如果linux用的是中文字符集jupyter启动很容易出现问题,如果出现类似问题,把linux改为英文,包治百病。

    上述只是jupyter的简单配置,复杂的参数配置请大家自行研究,这个内容可以满足基本的使用需求了。

  • 相关阅读:
    基于Docker的Mysql主从复制搭建
    Docker操作命令——查看、停止、删除容器
    Git命令
    未定义数组下标: 0
    zookeeper-3.4.14单机多端口集群搭建
    使用MAT分析dump文件定位程序问题
    intellij idea2019.1中文破解版安装
    vscode打造golang开发环境
    python项目开发环境模块安装记录
    shell用法
  • 原文地址:https://www.cnblogs.com/jaww/p/9846491.html
Copyright © 2011-2022 走看看