Linux 环境下配置远程jupyter notebook server

编程入门 行业动态 更新时间:2024-10-23 10:18:49

Linux <a href=https://www.elefans.com/category/jswz/34/1771403.html style=环境下配置远程jupyter notebook server"/>

Linux 环境下配置远程jupyter notebook server

XShell配置Linux服务器jupyter notebook

参考:

  • +jupyter/
  • .html
  • /
  • +jupyter/

 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的方法:

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

 

更多推荐

Linux 环境下配置远程jupyter notebook server

本文发布于:2023-06-29 03:45:35,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/938568.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:环境   Linux   jupyter   server   notebook

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!