cube-studio/images/jupyter-notebook/readme.md
2023-12-10 19:47:10 +08:00

56 lines
2.8 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# notebook重启问题
关于续期因为对gpu的占用方式为独占方式所以对于gpu notebook会定时清理需要按时续期。
关于清理可以通过删除config.py中的delete_notebook定时任务关闭掉定时清理notebook
关于环境:重启后会自动执行/mnt/$USERNAME/init.sh脚本所以可以将环境写入此脚本重启后自动安装环境否则就需要打包到镜像或者离线anaconda文件
# 构建notebook镜像
需要构建新镜像并在生产上替换才能让用户使用新的notebook镜像。
## 方法1Dockerfile构建
jupyter镜像的构建在https://github.com/tencentmusic/cube-studio/tree/master/images/jupyter-notebook
vscode镜像的构建在https://github.com/tencentmusic/cube-studio/tree/master/images/theia
现在默认使用的镜像为
```
# notebook使用的镜像
NOTEBOOK_IMAGES=[
['ccr.ccs.tencentyun.com/cube-studio/notebook:vscode-ubuntu-cpu-base', 'vscodecpu'],
['ccr.ccs.tencentyun.com/cube-studio/notebook:vscode-ubuntu-gpu-base', 'vscodegpu'],
['ccr.ccs.tencentyun.com/cube-studio/notebook:jupyter-ubuntu22.04', 'jupytercpu'],
['ccr.ccs.tencentyun.com/cube-studio/notebook:jupyter-ubuntu22.04-cuda11.8.0-cudnn8','jupytergpu'],
['ccr.ccs.tencentyun.com/cube-studio/notebook:jupyter-ubuntu-bigdata', 'jupyterbigdata'],
['ccr.ccs.tencentyun.com/cube-studio/notebook:jupyter-ubuntu-machinelearning', 'jupytermachinelearning'],
['ccr.ccs.tencentyun.com/cube-studio/notebook:jupyter-ubuntu-deeplearning', 'jupyterdeeplearning'],
]
```
## 方法2直接commit容器
也可以直接run一个容器然后安装插件后将容器commmit成镜像。
```
# 启动jupyter
docker run --name jupyter -p 3000:3000 -d ccr.ccs.tencentyun.com/cube-studio/notebook:jupyter-ubuntu22.04 jupyter lab --notebook-dir=/ --ip=0.0.0.0 --no-browser --allow-root --port=3000 --NotebookApp.token='' --NotebookApp.password='' --NotebookApp.allow_origin='*'
# 启动vscode
docker run --name vscode -p 3000:3000 -d ccr.ccs.tencentyun.com/cube-studio/notebook:vscode-ubuntu-cpu-base node /home/theia/src-gen/backend/main.js /home/project --hostname=0.0.0.0 --port=3000
```
然后访问 http://xx.xx.xx.xx:3000/ web界面操作安装notebook插件安装pip/apt环境等。环境完整后再使用如下命令commit成镜像。
```
docker commit notebook ccr.ccs.tencentyun.com/cube-studio/notebook:jupyter-ubuntu-cpu-base-1
```
# 修改配置文件
config.py中 NOTEBOOK_IMAGES 变量为notebook可选镜像。更新此变量即可。
# 其他类型的notebook
所有可提供在线编辑功能的web服务都可以定义为notebook。开发代码已提供对外需要满足几个条件可配置url前缀用来区分不同的notebook。