jupyterlab 安装:pip install jupyterlab
vim 安装:yum -y install vim*
screen 安装(非必须):yum install screen
docker进入方式(默认你配好了,非必须):sudo docker exec -it docker_name /bin/bash
docker 内conda 环境配置:参考地址
conda 内pytorch环境配置:参考地址
docker下配置jupyter:参考地址1、参考地址2
终端执行 ipython
,然后执行:
In [1]: from notebook.auth import passwd
In [2]: passwd()
两次确认密码之后,会得到加密密码,形如:
argon2:$argon2id$v=19$m=10240,t=10,p=8$ixG+i1EhgN93GEkfbl+TuQ$LYrjgVtiyn1EN0zFGbFQewZORHjsCcgp56Ngrw
保存此密码备用
jupyter lab --generate-config
/root/.jupyter/jupyter_lab_config.py
vim /root/.jupyter/jupyter_lab_config.py
c.ServerApp.allow_remote_access = True #启用远程访问
c.ServerApp.ip = ‘*’ #允许所有IP访问
c.ServerApp.port = 8888 #设置访问端口为8888
c.ServerApp.open_browser = False #停用自动打开浏览器
c.ExtensionApp.open_browser = False
c.NotebookApp.password = 'argon2:$argon2id$v=19$m=10240,t=10,p=8$ixG+i1EhgN93GEkfbl+TuQ$LYrjgVtiyn1EN0zFGbFQewZORHjsCcgp56Ngrw' #上个步骤里的加密密码
c.ServerApp.base_url = '/aaa/' #aaa表示独立域名字段
jupyter lab --allow-root
location /aaa/ { #aaa表示独立域名字段
proxy_pass http://localhost:8888;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host localhost;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_redirect off;
}
nginx -t
nginx -s reload
nginx相关域名映射配置(nginx.conf),自行百度。域名映射完成后,访问你映射的端口即可。上述例子即访问http://your_DomainName:8888/ 。
不做域名映射,只在本地玩jupyter的话,只配置jupyter即可。