Linux 环境下配置远程jupyter notebook server

XShell配置Linux服务器jupyter notebook

参考:

 jupyter相关命令

sudo start jupyter              # 启动 jupyter
sudo stop/restart jupyter       # 停止/重启 jupyter
sudo status jupyter             # 查看 jupyter 的状态

向jupyter中添加Kernel

1.查看kernel列表

jupyter kernelspec list

2.进入新环境添加kernel安装ipykernel库

Jupyter Notebook 增加kernel的方法:https://blog.csdn.net/wj1066/article/details/72891667

conda activate tensorflow
which python #查看python位置
sudo /home/zhoudengji/anaconda3/envs/tensorflow/bin/python -m ipykernel install --name tensorflow
conda install ipykernel  #若报错则在该python环境安装ipykernel包

3.删除kernel

jupyter kernelspec remove kernelname

配置jupyter notebook server

1.生成config文件

jupyter notebook --generate-config

2.生成密码

In [1]: from notebook.auth import passwd
In [2]: passwd()
Enter password:
Verify password:
Out[2]: 'sha1:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'#复制下来等会用

3.编辑配置文件,修改https/ip/openbroswer/port/password等属性

vi /home/xxxxxxx/.jupyter/jupyter_notebook_config.py

 

c.NotebookApp.allow_origin = '*'
c.NotebookApp.allow_remote_access = True
c.NotebookApp.allow_root = True
c.NotebookApp.ip='*'
c.NotebookApp.open_browser = False
c.NotebookApp.password = u'sha1:3XXXXXXXXXXXXXXXX5'
c.NotebookApp.port =8888

3.防火墙设置,关闭防火墙

sudo firewall-cmd --zone=public --add-port=8888/tcp --permanent
sudo systemctl restart firewalld
systemctl stop firewalld.service

--
# 用这个
sudo iptables -I INPUT -p tcp --dport 8888 -j ACCEPT
iptables-save
--

4.后台启动

nohup jupyter notebook   # 我使用的是这个
nohup jupyter notebook >/dev/null 2>&1 &
nohup jupyter notebook -config /home/zhoudengji/.jupyter/jupyter_notebook_config.py --allow-root >/dev/null 2>&1 &

5.关闭远程jupyter notebook

# 查看进程
ps -ef | grep 'jupyter notebook'
# 输出如下,这里的21983即为进程id,
# hadoop    22136  21983  0 09:10 pts/1    00:00:00 grep jupyter notebook
# 杀死进程
kill -9 21983

下次启动jupyter notebook步骤

1.conda activate tensorflow
2.# 设置了防火墙之后,再次再进去启动jupyter不需要这一步
sudo firewall-cmd --zone=public --add-port=8888/tcp --permanent
sudo systemctl restart firewalld
systemctl stop firewalld.service
3.nohup jupyter notebook

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值