在服务器上部署 Jupyter Notebook

2020-04-23  本文已影响0人  zealscott

安装 Ananconda

wget wget https://repo.continuum.io/archive/Anaconda3-5.2.0-Linux-x86_64.sh
channels:
  - defaults
show_channel_urls: true
channel_alias: https://mirrors.tuna.tsinghua.edu.cn/anaconda
default_channels:
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/pro
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2
custom_channels:
  conda-forge: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  msys2: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  bioconda: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  menpo: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  pytorch: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  simpleitk: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud

部署远程云服务

jupyter notebook --generate-config
from IPython.lib import passwd
passwd()
Enter password: 
Verify password: 
vim ~/.jupyter/jupyter_notebook_config.py
c.NotebookApp.ip = '*' #所有绑定服务器的IP都能访问,若想只在特定ip访问,输入ip地址即可
c.NotebookApp.port = 8888 #将端口设置为自己喜欢的吧,默认是8888
c.NotebookApp.open_browser = False #我们并不想在服务器上直接打开Jupyter Notebook,所以设置成False
c.NotebookApp.notebook_dir = '/scott/data' #这里是设置Jupyter的根目录,若不设置将默认root的根目录,不安全
c.NotebookApp.allow_root = True # 为了安全,Jupyter默认不允许以root权限启动jupyter 
nohup jupyter-notebook &

这里使用 nohup 是想在 ssh 窗口关闭后继续运行,同时使用后台运行的方式。

上一篇下一篇

猜你喜欢

热点阅读