jupyter


原文链接: jupyter

在线jupyter浏览器
https://github.com/zergtant/pytorch-handbook

3.配置jupyter
3.1生成配置文件

jupyter notebook --generate-config

Writing default config to: /home/lyy/.jupyter/jupyter_notebook_config.py
会在~/.jupyter目录下生成一个名为jupyter_notebook_config.py

3.2配置密码
from notebook.auth import passwd
passwd()
Enter password:
Verify password:
'sha1:93ede60352f6:fe06c552ba88f894c7a43b840309b7557eb5dacf'

3.3 生成pem和key文件
使用如下命令会在当前路径下生成一个mykey.key和一个mycert.pem文件,这两个文件会在后面的配置中使用到。下面的命令会生成有效期为365天的certificate文件
rm -r /data/openssl
mkdir /data/openssl
cd /data/openssl
openssl req -x509 -nodes -days 365 -newkey rsa:1024 -keyout mykey.key -out mycert.pem

3.4配置文件
这里主要配置第一步中的jupyter_notebook_config.py文件。需要配置的选项如下:
sudo gedit /home/lyy/.jupyter/jupyter_notebook_config.py

c.NotebookApp.certfile = u'/data/openssl/mycert.pem'
c.NotebookApp.keyfile = u'/data/openssl/mykey.key'

Set ip to '*' to bind on all interfaces (ips) for the public servcd er

c.NotebookApp.ip = '0.0.0.0'
c.NotebookApp.password = u'sha1:93ede60352f6:fe06c552ba88f894c7a43b840309b7557eb5dacf'
c.NotebookApp.open_browser = False

指定端口号

c.NotebookApp.port = 8888

关闭防火墙
sudo ufw disable 然后按enter键执行命令
配置完成后,在TensorFlow环境下输入jupyter notebook命令,在远程中打开Chrome浏览器,输入https://localhost:8888就可以远程访问并使用TensorFLow了。

安装jupyter扩展插件
用pip:
pip install jupyter_nbextensions_configurator jupyter_contrib_nbextensions autopep8
jupyter contrib nbextension install --user
jupyter nbextensions_configurator enable --user
如果使用的anaconda,还可以用conda安装:
conda install -c conda-forge jupyter_contrib_nbextensions
conda install -c conda-forge jupyter_nbextensions_configurator

from matplotlib.pyplot import imshow
import numpy as np
from PIL import Image

%matplotlib inline
pil_im = Image.open('data/empire.jpg', 'r')
imshow(np.asarray(pil_im))
`