Compare commits
60 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ab0838c738 | ||
|
|
82ddb287fe | ||
|
|
c885d79433 | ||
|
|
2d6bb7c2cc | ||
| f2b9b5033b | |||
| 96b87a8f82 | |||
| 00a7a5ee6a | |||
| 4da2a4c813 | |||
| 4a6697ef69 | |||
| 305fd85088 | |||
|
|
adc45bc432 | ||
|
|
f685bf6d80 | ||
|
|
0ced7fca49 | ||
| 780ca5ec6a | |||
| 589713716f | |||
| 4b7bdd84c5 | |||
| 59f92e568b | |||
| eeadd1c8a3 | |||
| 25f494b3a8 | |||
| 03e1542842 | |||
| bf55bf8e5b | |||
| 98265022aa | |||
| 2c58a44cde | |||
| d2f5cf5ae5 | |||
| e8f862a2bc | |||
| a162b38603 | |||
| 0af46b7c0c | |||
| 7c3da1a3df | |||
| 3b3ee98f2d | |||
| d6e33de031 | |||
| 6adc5144c7 | |||
| f4fab27896 | |||
|
|
2aac07b64f | ||
| 938cf1b69b | |||
| 57ee612b16 | |||
| e0ff4e6ba6 | |||
| 046b177a83 | |||
| 6f78c463be | |||
| 20fe094f6c | |||
| 38389a0b90 | |||
| 829cce5792 | |||
| 970007d847 | |||
| d7b7bc71d1 | |||
| 8a318485d5 | |||
| ede3f1f76f | |||
| 41b33a3f8e | |||
| d54020f61b | |||
| 7743e1da8e | |||
| 0c69c8574b | |||
| 07c412fa8b | |||
| fb4478d444 | |||
| a92e4bc77f | |||
| 003cd287d4 | |||
| 10cf5a9284 | |||
| e5072033d5 | |||
| 745207f1ec | |||
| 50b394ccde | |||
| 4c681532e9 | |||
| 0bfa4f7b04 | |||
| 2139b10fc6 |
4
.gitignore
vendored
Normal file → Executable file
4
.gitignore
vendored
Normal file → Executable file
@@ -1 +1,3 @@
|
||||
/docker-stacks
|
||||
/docker-stacks
|
||||
jupyterhub-data
|
||||
*.tar
|
||||
1
Dockerfile
Normal file → Executable file
1
Dockerfile
Normal file → Executable file
@@ -1,3 +1,4 @@
|
||||
# syntax=docker/dockerfile:1
|
||||
FROM debian:bullseye
|
||||
ARG CREATE_USER="jovyan"
|
||||
ARG CREATE_USER_PASSWD="password"
|
||||
|
||||
40
Dockerfile.jupyterhub
Normal file → Executable file
40
Dockerfile.jupyterhub
Normal file → Executable file
@@ -8,6 +8,8 @@ ARG ROOT_PASSWD="password"
|
||||
ARG HOME="/home/${CREATE_USER}"
|
||||
ARG DEBIAN_FRONTEND="noninteractive"
|
||||
ENV DEBIAN_FRONTEND=${DEBIAN_FRONTEND}
|
||||
ARG NODEJS_VERSION='18'
|
||||
ENV NODEJS_VERSION=${NODEJS_VERSION}
|
||||
|
||||
USER root
|
||||
RUN <<EOT
|
||||
@@ -19,6 +21,8 @@ apt-get install -y tzdata
|
||||
ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
|
||||
echo 'Asia/Shanghai' > /etc/timezone
|
||||
dpkg-reconfigure -f noninteractive tzdata
|
||||
sudo apt-get remove --purge libnode72:amd64 -y
|
||||
curl -fsSL https://deb.nodesource.com/setup_${NODEJS_VERSION}.x | sudo -E bash -
|
||||
# 安装所需的软件包
|
||||
apt-get install -y python3 python3-pip gcc g++ build-essential nodejs npm gdebi-core curl wget openssh-server vim lrzsz net-tools sudo git
|
||||
# 创建新用户
|
||||
@@ -30,8 +34,25 @@ EOT
|
||||
RUN <<EOT
|
||||
#!/bin/bash
|
||||
# 安装 Jupyter 和相关软件
|
||||
npm install -g configurable-http-proxy
|
||||
python3 -m pip install jupyterhub jupyterlab notebook radian pycurl jupyter-rsession-proxy ipykernel jupyterlab-language-pack-zh-CN jupyterlab-git jupyterlab-system-monitor jupyter_nbextensions_configurator jupyter_contrib_nbextensions jupyterlab-unfold jupyterlab_widgets jupyterlab-drawio jupyterlab-spreadsheet-editor jupyterlab-cell-flash jedi-language-server jupyterlab_code_formatter jupyterlab-spellchecker jupyterlab_vim nbresuse ipydrawio jedi ipympl black isort theme-darcula ipywidgets tensorboard jupyterlab_latex jupyter_bokeh autopep8 xeus-python jupyterlab-lsp python-lsp-server nglview dockerspawner jupyterhub-nativeauthenticator lckr_jupyterlab_variableinspector
|
||||
npm install -g configurable-http-proxy yarn --registry=https://registry.npmmirror.com
|
||||
python3 -m pip install ipython jupyter_packaging jupyterhub jupyterlab notebook radian pycurl jupyter-rsession-proxy \
|
||||
ipykernel jupyterlab-language-pack-zh-CN jupyterlab-git jupyterlab-system-monitor jupyter_nbextensions_configurator \
|
||||
jupyter_contrib_nbextensions jupyterlab-unfold jupyterlab_widgets jupyterlab-drawio jupyterlab-spreadsheet-editor \
|
||||
jupyterlab-cell-flash jedi-language-server jupyterlab_code_formatter jupyterlab-spellchecker jupyterlab_vim nbresuse \
|
||||
ipydrawio jedi ipympl black isort theme-darcula ipywidgets tensorboard jupyterlab_latex jupyter_bokeh autopep8 \
|
||||
xeus-python jupyterlab-lsp python-lsp-server dockerspawner jupyterhub-nativeauthenticator lckr_jupyterlab_variableinspector -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com
|
||||
git clone https://ghproxy.dockless.eu.org/https://github.com/arose/nglview
|
||||
cd nglview
|
||||
python3 setup.py install
|
||||
cd js
|
||||
rm -rf node_modules package-lock.json
|
||||
npm install typescript@latest --registry=https://registry.npmmirror.com
|
||||
npm install --registry=https://registry.npmmirror.com
|
||||
cd ../..
|
||||
python -m ipykernel install --sys-prefix
|
||||
jupyter nbextension enable --py --sys-prefix widgetsnbextension
|
||||
jupyter nbextension enable --py --sys-prefix nglview
|
||||
jupyter-nbextension enable nglview --py --sys-prefix
|
||||
# 创建 JupyterHub 配置目录
|
||||
mkdir -p /root/.jupyterhub
|
||||
EOT
|
||||
@@ -48,26 +69,13 @@ wget -qO- https://cloud.r-project.org/bin/linux/ubuntu/marutter_pubkey.asc | sud
|
||||
sudo add-apt-repository "deb https://cloud.r-project.org/bin/linux/ubuntu $(lsb_release -cs)-cran40/"
|
||||
apt-get update
|
||||
apt install --no-install-recommends r-base
|
||||
sudo wget "https://download2.rstudio.org/server/$(lsb_release -cs)/amd64/rstudio-server-2023.06.1-524-amd64.deb" -O /tmp/rstudio-server.deb
|
||||
sudo wget "https://download2.rstudio.org/server/$(lsb_release -cs)/amd64/rstudio-server-2024.09.1-394-amd64.deb" -O /tmp/rstudio-server.deb
|
||||
sudo chmod +x /tmp/rstudio-server.deb
|
||||
sudo gdebi -n /tmp/rstudio-server.deb
|
||||
sudo rm -rf /tmp/rstudio-server.deb
|
||||
EOT
|
||||
|
||||
RUN <<EOT
|
||||
#!/bin/bash
|
||||
# 安装micromamba
|
||||
echo "1" | bash <(curl -s https://raw.githubusercontent.com/hotwa/MicroMamba_Installer/main/install.sh)
|
||||
mkdir -p /root/workspace/personal /root/workspace/project
|
||||
EOT
|
||||
|
||||
RUN <<EOT
|
||||
#!/bin/bash
|
||||
# 清理和减小镜像大小
|
||||
apt-get clean
|
||||
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/man/?? /usr/share/man/??_*
|
||||
EOT
|
||||
|
||||
|
||||
|
||||
CMD ["jupyterhub", "-f", "/srv/jupyterhub/jupyterhub_config.py"]
|
||||
0
Dockerfile.jupyterhub.bak
Normal file → Executable file
0
Dockerfile.jupyterhub.bak
Normal file → Executable file
60
README.md
Normal file → Executable file
60
README.md
Normal file → Executable file
@@ -53,6 +53,26 @@ cd docker-stacks/images/base-notebook
|
||||
docker buildx build -t hotwa/notebook:latest . -f Dockerfile
|
||||
```
|
||||
|
||||
## 修改jupyterhub启动notebook的路径映射
|
||||
|
||||
修改jupyterhub_config.py文件,修改卷的路径:
|
||||
|
||||
```python
|
||||
c.DockerSpawner.volumes = {
|
||||
"jupyterhub-user-{username}": notebook_dir,
|
||||
"/mnt/mydrive": "/home/jovyan/work/mydrive",
|
||||
"/mnt/mydrive/project/docker-jupyterhub/id_rsa": "/home/jovyan/.ssh/id_rsa",
|
||||
}
|
||||
```
|
||||
|
||||
## 启动notebook修改
|
||||
|
||||
启动notebook修改docker-compose.yml文件,修改notebook的基础镜像:
|
||||
|
||||
```yaml
|
||||
DOCKER_NOTEBOOK_IMAGE: hotwa/notebook:latest
|
||||
```
|
||||
|
||||
## Alternatives
|
||||
|
||||
- [rocker/binder](https://rocker-project.org/images/versioned/binder.html) -
|
||||
@@ -77,6 +97,7 @@ curl -s -L https://nvidia.github.io/libnvidia-container/stable/deb/nvidia-contai
|
||||
| sudo tee /etc/apt/sources.list.d/nvidia-container-toolkit.list
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y nvidia-container-toolkit
|
||||
sudo apt-get install nvidia-container-runtime -y
|
||||
```
|
||||
|
||||
Configure Docker to use Nvidia driver
|
||||
@@ -86,6 +107,26 @@ sudo nvidia-ctk runtime configure --runtime=docker
|
||||
sudo systemctl restart docker
|
||||
```
|
||||
|
||||
实际上这个操作修改了/etc/docker/daemon.json文件:
|
||||
|
||||
```shell
|
||||
{
|
||||
"registry-mirrors": [
|
||||
"https://0b27f0a81a00f3560fbdc00ddd2f99e0.mirror.swr.myhuaweicloud.com",
|
||||
"https://ypzju6vq.mirror.aliyuncs.com",
|
||||
"https://registry.docker-cn.com",
|
||||
"http://hub-mirror.c.163.com",
|
||||
"https://docker.mirrors.ustc.edu.cn"
|
||||
],
|
||||
"runtimes": {
|
||||
"nvidia": {
|
||||
"args": [],
|
||||
"path": "nvidia-container-runtime"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
配置完成之后:
|
||||
|
||||
```shell
|
||||
@@ -118,6 +159,25 @@ docker volume rm docker-jupyterhub_jupyterhub-data
|
||||
docker volume rm jupyterhub-user-admin
|
||||
```
|
||||
|
||||
## 修改绑定到notebook的卷
|
||||
|
||||
修改jupyterhub_config.py文件,修改卷的路径:
|
||||
|
||||
```python
|
||||
c.DockerSpawner.volumes = {
|
||||
"jupyterhub-user-{username}": notebook_dir,
|
||||
"/mnt/mydrive": "/home/jovyan/work/mydrive",
|
||||
"/mnt/mydrive/project/docker-jupyterhub/id_rsa": "/home/jovyan/.ssh/id_rsa",
|
||||
}
|
||||
```
|
||||
|
||||
docker-compose.yml文件,修改notebook的基础镜像:
|
||||
|
||||
```yaml
|
||||
DOCKER_NOTEBOOK_IMAGE: hotwa/notebook:latest
|
||||
```
|
||||
|
||||
|
||||
## 构建
|
||||
|
||||
构建基础notebook镜像
|
||||
|
||||
0
dhparam.pem
Normal file → Executable file
0
dhparam.pem
Normal file → Executable file
7
docker-compose.yml
Normal file → Executable file
7
docker-compose.yml
Normal file → Executable file
@@ -12,7 +12,7 @@ services:
|
||||
args:
|
||||
JUPYTERHUB_VERSION: latest
|
||||
restart: always
|
||||
image: hotwa/jupyterhub # registry.cn-hangzhou.aliyuncs.com/hotwa/jupyterhub
|
||||
image: quay.io/hotwa/jupyterhub:latest
|
||||
container_name: jupyterhub
|
||||
networks:
|
||||
- jupyterhub-network
|
||||
@@ -23,16 +23,17 @@ services:
|
||||
# within the container
|
||||
- "/var/run/docker.sock:/var/run/docker.sock:rw"
|
||||
# Bind Docker volume on host for JupyterHub database and cookie secrets
|
||||
- "jupyterhub-data:/data"
|
||||
- "./jupyterhub-data:/data"
|
||||
ports:
|
||||
- "8000:8000"
|
||||
- "8080:8080"
|
||||
environment:
|
||||
# This username will be a JupyterHub admin
|
||||
JUPYTERHUB_ADMIN: admin
|
||||
# All containers will join this network
|
||||
DOCKER_NETWORK_NAME: jupyterhub-network
|
||||
# JupyterHub will spawn this Notebook image for users
|
||||
DOCKER_NOTEBOOK_IMAGE: hotwa/notebook:latest
|
||||
DOCKER_NOTEBOOK_IMAGE: quay.io/hotwa/notebook:latest
|
||||
# Notebook directory inside user image
|
||||
DOCKER_NOTEBOOK_DIR: /home/jovyan/work
|
||||
|
||||
|
||||
30
jupyterhub_config.py
Normal file → Executable file
30
jupyterhub_config.py
Normal file → Executable file
@@ -10,7 +10,21 @@ c = get_config() # noqa: F821
|
||||
# avoid having to rebuild the JupyterHub container every time we change a
|
||||
# configuration parameter.
|
||||
|
||||
# from dockerspawner import DockerSpawner
|
||||
|
||||
# class MyDockerSpawner(DockerSpawner):
|
||||
# def start(self):
|
||||
# # 启动父类的start方法
|
||||
# self.user_options['environment']['JUPYTER_ENABLE_NBEXTENSIONS'] = 'true'
|
||||
# self.user_options['cmd'] = [
|
||||
# 'bash',
|
||||
# '-c',
|
||||
# 'pip install nglview jupyter_packaging -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com && jupyter nbextension enable nglview --py --sys-prefix && jupyter labextension install nglview-js-widgets && jupyter labextension install @jupyter-widgets/jupyterlab-manager && start-singleuser.sh'
|
||||
# ]
|
||||
# return super().start()
|
||||
|
||||
# Spawn single-user servers as Docker containers
|
||||
c.Authenticator.allow_all = True
|
||||
c.JupyterHub.spawner_class = "dockerspawner.DockerSpawner"
|
||||
|
||||
# Spawn containers from this image
|
||||
@@ -30,7 +44,15 @@ c.DockerSpawner.notebook_dir = notebook_dir
|
||||
|
||||
# Mount the real user's Docker volume on the host to the notebook user's
|
||||
# notebook directory in the container
|
||||
c.DockerSpawner.volumes = {"jupyterhub-user-{username}": notebook_dir}
|
||||
# c.DockerSpawner.volumes = {"jupyterhub-user-{username}": notebook_dir}
|
||||
# Mount the real user's Docker volume on the host to the notebook user's
|
||||
# notebook directory in the container
|
||||
c.DockerSpawner.volumes = {
|
||||
"jupyterhub-user-{username}": notebook_dir,
|
||||
"/mnt/mydrive": "/home/jovyan/work/mydrive",
|
||||
"/mnt/mydrive/project/docker-jupyterhub/id_rsa": "/home/jovyan/.ssh/id_rsa",
|
||||
}
|
||||
|
||||
|
||||
# Remove containers once they are stopped
|
||||
c.DockerSpawner.remove = True
|
||||
@@ -62,9 +84,10 @@ if admin:
|
||||
# "environment": {"JUPYTER_ENABLE_LAB": "yes"}
|
||||
# })
|
||||
|
||||
# 启动jupyter时候增加跨域支持
|
||||
# 启动jupyter时候增加跨域支持, 否则反向代理的时候出现问题
|
||||
# --NotebookApp.iopub_data_rate_limit=10000000 给nglview使用
|
||||
c.DockerSpawner.extra_create_kwargs.update({
|
||||
"environment": {"NOTEBOOK_ARGS": "--NotebookApp.allow_origin='*'"}
|
||||
"environment": {"NOTEBOOK_ARGS": "--NotebookApp.allow_origin='*' --NotebookApp.iopub_data_rate_limit=10000000"}
|
||||
})
|
||||
|
||||
|
||||
@@ -74,7 +97,6 @@ c.DockerSpawner.extra_create_kwargs.update({
|
||||
# 'JUPYTERHUB_CORS': '{"allow_origin_pat": "https?://.*\\.example\\.com"}'
|
||||
# }
|
||||
|
||||
|
||||
# GPU 和网络配置
|
||||
c.DockerSpawner.extra_host_config = {
|
||||
'runtime': 'nvidia'
|
||||
|
||||
0
jupyterhub_config.py.bak
Normal file → Executable file
0
jupyterhub_config.py.bak
Normal file → Executable file
0
micromamba_install.sh
Normal file → Executable file
0
micromamba_install.sh
Normal file → Executable file
0
nginx-selfsigned.crt
Normal file → Executable file
0
nginx-selfsigned.crt
Normal file → Executable file
0
nginx-selfsigned.key
Normal file → Executable file
0
nginx-selfsigned.key
Normal file → Executable file
8
nginx.conf
Normal file → Executable file
8
nginx.conf
Normal file → Executable file
@@ -1,9 +1,12 @@
|
||||
events {}
|
||||
|
||||
http {
|
||||
# 增加上传文件大小限制
|
||||
client_max_body_size 0; # 0表示无限制
|
||||
|
||||
map $http_upgrade $connection_upgrade {
|
||||
default upgrade;
|
||||
'' close;
|
||||
'' close;
|
||||
}
|
||||
|
||||
server {
|
||||
@@ -30,6 +33,7 @@ http {
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
proxy_set_header X-Forwarded-Port $server_port; # 添加这一行,保持原有的端口号
|
||||
|
||||
# WebSocket support
|
||||
proxy_http_version 1.1;
|
||||
@@ -38,6 +42,8 @@ http {
|
||||
proxy_set_header X-Scheme $scheme;
|
||||
|
||||
proxy_buffering off;
|
||||
# 增加临时文件大小限制,0表示禁止使用临时文件
|
||||
proxy_max_temp_file_size 0;
|
||||
}
|
||||
|
||||
# Managing requests to verify letsencrypt host
|
||||
|
||||
0
spawnerdockerfile/Dockerfile
Normal file → Executable file
0
spawnerdockerfile/Dockerfile
Normal file → Executable file
127
spawnerdockerfile/Dockerfile.base
Executable file
127
spawnerdockerfile/Dockerfile.base
Executable file
@@ -0,0 +1,127 @@
|
||||
# syntax=docker/dockerfile:1
|
||||
# Copyright (c) Jupyter Development Team.
|
||||
# Distributed under the terms of the Modified BSD License.
|
||||
# https://github.com/jupyter/docker-stacks/blob/main/images/base-notebook/Dockerfile
|
||||
ARG REGISTRY=quay.io
|
||||
ARG OWNER=jupyter
|
||||
ARG BASE_CONTAINER=$REGISTRY/$OWNER/docker-stacks-foundation
|
||||
FROM $BASE_CONTAINER
|
||||
|
||||
LABEL maintainer="Jupyter Project <jupyter@googlegroups.com>"
|
||||
|
||||
# Fix: https://github.com/hadolint/hadolint/wiki/DL4006
|
||||
# Fix: https://github.com/koalaman/shellcheck/wiki/SC3014
|
||||
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
|
||||
|
||||
USER root
|
||||
|
||||
# Install all OS dependencies for the Server that starts but lacks all
|
||||
# features (e.g., download as all possible file formats)
|
||||
RUN apt-get update --yes && \
|
||||
apt-get install --yes --no-install-recommends \
|
||||
fonts-liberation \
|
||||
# - pandoc is used to convert notebooks to html files
|
||||
# it's not present in the aarch64 Ubuntu image, so we install it here
|
||||
pandoc \
|
||||
# - run-one - a wrapper script that runs no more
|
||||
# than one unique instance of some command with a unique set of arguments,
|
||||
# we use `run-one-constantly` to support the `RESTARTABLE` option
|
||||
run-one && \
|
||||
apt-get clean && rm -rf /var/lib/apt/lists/*
|
||||
|
||||
USER ${NB_UID}
|
||||
|
||||
# Install JupyterLab, Jupyter Notebook, JupyterHub and NBClassic
|
||||
# Generate a Jupyter Server config
|
||||
# Cleanup temporary files
|
||||
# Correct permissions
|
||||
# Do all this in a single RUN command to avoid duplicating all of the
|
||||
# files across image layers when the permissions change
|
||||
WORKDIR /tmp
|
||||
RUN mamba install --yes \
|
||||
'jupyterlab' \
|
||||
'notebook' \
|
||||
'jupyterhub' \
|
||||
'nbclassic' && \
|
||||
jupyter server --generate-config && \
|
||||
mamba clean --all -f -y && \
|
||||
npm cache clean --force && \
|
||||
jupyter lab clean && \
|
||||
rm -rf "/home/${NB_USER}/.cache/yarn" && \
|
||||
fix-permissions "${CONDA_DIR}" && \
|
||||
fix-permissions "/home/${NB_USER}"
|
||||
|
||||
ENV JUPYTER_PORT=8888
|
||||
EXPOSE $JUPYTER_PORT
|
||||
|
||||
# Configure container startup
|
||||
CMD ["start-notebook.py"]
|
||||
|
||||
# Copy local files as late as possible to avoid cache busting
|
||||
COPY start-notebook.py start-notebook.sh start-singleuser.py start-singleuser.sh /usr/local/bin/
|
||||
COPY jupyter_server_config.py docker_healthcheck.py /etc/jupyter/
|
||||
|
||||
# Fix permissions on /etc/jupyter as root
|
||||
USER root
|
||||
RUN fix-permissions /etc/jupyter/
|
||||
|
||||
# HEALTHCHECK documentation: https://docs.docker.com/engine/reference/builder/#healthcheck
|
||||
# This healtcheck works well for `lab`, `notebook`, `nbclassic`, `server`, and `retro` jupyter commands
|
||||
# https://github.com/jupyter/docker-stacks/issues/915#issuecomment-1068528799
|
||||
HEALTHCHECK --interval=5s --timeout=3s --start-period=5s --retries=3 \
|
||||
CMD /etc/jupyter/docker_healthcheck.py || exit 1
|
||||
|
||||
# here add
|
||||
ARG CREATE_USER="jovyan"
|
||||
ARG CREATE_USER_PASSWD="password"
|
||||
ARG ROOT_PASSWD="password"
|
||||
ARG HOME="/home/${CREATE_USER}"
|
||||
ARG DEBIAN_FRONTEND="noninteractive"
|
||||
ENV DEBIAN_FRONTEND=${DEBIAN_FRONTEND}
|
||||
|
||||
RUN <<EOT
|
||||
#!/bin/bash
|
||||
# 更新软件源
|
||||
apt-get update
|
||||
# 安装时区数据包并设置时区
|
||||
apt-get install -y tzdata
|
||||
ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
|
||||
echo 'Asia/Shanghai' > /etc/timezone
|
||||
dpkg-reconfigure -f noninteractive tzdata
|
||||
# 安装所需的软件包
|
||||
apt-get install -y python3 python3-pip gcc g++ build-essential nodejs npm gdebi-core curl wget openssh-server vim lrzsz net-tools sudo git
|
||||
# 创建新用户
|
||||
useradd -m -s /bin/bash ${CREATE_USER}
|
||||
echo "${CREATE_USER}:${CREATE_USER_PASSWD}" | chpasswd
|
||||
echo "${CREATE_USER} ALL=(ALL:ALL) NOPASSWD:ALL" >> /etc/sudoers
|
||||
# 安装 Jupyter 和相关软件
|
||||
npm install -g configurable-http-proxy
|
||||
python3 -m pip install jupyterhub jupyterlab notebook radian pycurl jupyter-rsession-proxy ipykernel>=6.25.0 jupyterlab-language-pack-zh-CN jupyterlab-git jupyterlab-system-monitor jupyter_nbextensions_configurator jupyter_contrib_nbextensions jupyterlab_widgets jupyterlab-drawio jupyterlab-spreadsheet-editor jupyterlab-cell-flash jedi-language-server jupyterlab_code_formatter jupyterlab-spellchecker jupyterlab_vim nbresuse ipydrawio jedi ipympl black isort theme-darcula ipywidgets tensorboard jupyterlab_latex jupyter_bokeh autopep8 xeus-python jupyterlab-lsp python-lsp-server nglview dockerspawner jupyterhub-nativeauthenticator lckr_jupyterlab_variableinspector -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com
|
||||
EOT
|
||||
|
||||
# Switch back to jovyan to avoid accidental container runs as root
|
||||
USER ${NB_UID}
|
||||
|
||||
# install mojo
|
||||
ARG MODULAR_HOME="/home/${CREATE_USER}/.modular"
|
||||
ENV MODULAR_HOME=$MODULAR_HOME
|
||||
ENV PATH="$MODULAR_HOME/pkg/packages.modular.com_mojo/bin:/home/${CREATE_USER}/.local/bin:$PATH"
|
||||
RUN <<EOT
|
||||
#!/bin/bash
|
||||
curl https://get.modular.com | sh -
|
||||
mamba create -n mojo python=3.10 -c conda-forge -y
|
||||
mamba activate mojo
|
||||
modular install mojo
|
||||
EOT
|
||||
|
||||
# Install Rust
|
||||
ENV PATH="/home/${CREATE_USER}/.cargo/bin:$PATH"
|
||||
RUN <<EOT
|
||||
#!/bin/bash
|
||||
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
|
||||
source $HOME/.cargo/env
|
||||
cargo install evcxr_jupyter
|
||||
evcxr_jupyter --install
|
||||
EOT
|
||||
|
||||
WORKDIR "${HOME}"
|
||||
104
spawnerdockerfile/Dockerfile.base-notebook
Normal file → Executable file
104
spawnerdockerfile/Dockerfile.base-notebook
Normal file → Executable file
@@ -1,3 +1,4 @@
|
||||
# syntax=docker/dockerfile:1
|
||||
# Copyright (c) Jupyter Development Team.
|
||||
# Distributed under the terms of the Modified BSD License.
|
||||
# https://github.com/jupyter/docker-stacks/blob/main/images/base-notebook/Dockerfile
|
||||
@@ -77,7 +78,10 @@ ARG ROOT_PASSWD="password"
|
||||
ARG HOME="/home/${CREATE_USER}"
|
||||
ARG DEBIAN_FRONTEND="noninteractive"
|
||||
ENV DEBIAN_FRONTEND=${DEBIAN_FRONTEND}
|
||||
ARG NODEJS_VERSION='18'
|
||||
ENV NODEJS_VERSION=${NODEJS_VERSION}
|
||||
|
||||
COPY install.sh /tmp
|
||||
RUN <<EOT
|
||||
#!/bin/bash
|
||||
# 更新软件源
|
||||
@@ -88,18 +92,26 @@ ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
|
||||
echo 'Asia/Shanghai' > /etc/timezone
|
||||
dpkg-reconfigure -f noninteractive tzdata
|
||||
# 安装所需的软件包
|
||||
apt-get install -y python3 python3-pip gcc g++ build-essential nodejs npm gdebi-core curl wget openssh-server vim lrzsz net-tools sudo git
|
||||
sudo apt-get remove --purge libnode72:amd64 -y
|
||||
curl -fsSL https://deb.nodesource.com/setup_${NODEJS_VERSION}.x | sudo -E bash -
|
||||
apt-get install -y python3 python3-pip gcc g++ build-essential nodejs npm gdebi-core curl wget openssh-server vim lrzsz net-tools sudo git nodejs
|
||||
npm install -g configurable-http-proxy yarn --registry=https://registry.npmmirror.com
|
||||
# 创建新用户
|
||||
useradd -m -s /bin/bash ${CREATE_USER}
|
||||
echo "${CREATE_USER}:${CREATE_USER_PASSWD}" | chpasswd
|
||||
echo "${CREATE_USER} ALL=(ALL:ALL) NOPASSWD:ALL" >> /etc/sudoers
|
||||
# 安装micromamba
|
||||
echo "1" | bash <(curl -s https://raw.githubusercontent.com/hotwa/MicroMamba_Installer/main/install.sh)
|
||||
# 安装 Jupyter 和相关软件
|
||||
npm install -g configurable-http-proxy
|
||||
python3 -m pip install jupyterhub jupyterlab notebook radian pycurl jupyter-rsession-proxy ipykernel jupyterlab-language-pack-zh-CN jupyterlab-git jupyterlab-system-monitor jupyter_nbextensions_configurator jupyter_contrib_nbextensions jupyterlab_widgets jupyterlab-drawio jupyterlab-spreadsheet-editor jupyterlab-cell-flash jedi-language-server jupyterlab_code_formatter jupyterlab-spellchecker jupyterlab_vim nbresuse ipydrawio jedi ipympl black isort theme-darcula ipywidgets tensorboard jupyterlab_latex jupyter_bokeh autopep8 xeus-python jupyterlab-lsp python-lsp-server nglview dockerspawner jupyterhub-nativeauthenticator lckr_jupyterlab_variableinspector
|
||||
EOT
|
||||
|
||||
# 安装 Jupyter 和相关软件
|
||||
RUN <<EOT
|
||||
#!/bin/bash
|
||||
python3 -m pip install ipython jupyterhub jupyterlab notebook jupyter_packaging -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com
|
||||
python3 -m pip install aiohttp -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com
|
||||
python3 -m pip install jupyterhub jupyterlab notebook radian pycurl aiohttp jupyter-rsession-proxy ipykernel>=6.25.0 jupyterlab-language-pack-zh-CN jupyterlab-git jupyterlab-system-monitor jupyter_nbextensions_configurator jupyter_contrib_nbextensions jupyterlab_widgets jupyterlab-drawio jupyterlab-spreadsheet-editor jupyterlab-cell-flash jedi-language-server jupyterlab_code_formatter jupyterlab-spellchecker jupyterlab_vim nbresuse ipydrawio jedi ipympl black isort theme-darcula ipywidgets tensorboard jupyterlab_latex jupyter_bokeh autopep8 xeus-python jupyterlab-lsp python-lsp-server dockerspawner jupyterhub-nativeauthenticator lckr_jupyterlab_variableinspector -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com
|
||||
EOT
|
||||
|
||||
ARG RSERVER_VERSION="rstudio-server-2024.09.1-394-amd64.deb"
|
||||
ENV RSERVER_VERSION=${RSERVER_VERSION}
|
||||
RUN <<EOT
|
||||
#!/bin/bash
|
||||
# install rserver
|
||||
@@ -110,7 +122,7 @@ wget -qO- https://cloud.r-project.org/bin/linux/ubuntu/marutter_pubkey.asc | tee
|
||||
echo | add-apt-repository "deb https://cloud.r-project.org/bin/linux/ubuntu $(lsb_release -cs)-cran40/"
|
||||
apt-get update
|
||||
apt install -y --no-install-recommends r-base
|
||||
wget "https://download2.rstudio.org/server/$(lsb_release -cs)/amd64/rstudio-server-2023.06.1-524-amd64.deb" -O /tmp/rstudio-server.deb
|
||||
wget "https://download2.rstudio.org/server/$(lsb_release -cs)/amd64/${RSERVER_VERSION}" -O /tmp/rstudio-server.deb
|
||||
chmod +x /tmp/rstudio-server.deb
|
||||
gdebi -n /tmp/rstudio-server.deb
|
||||
rm -rf /tmp/rstudio-server.deb
|
||||
@@ -122,51 +134,63 @@ EOT
|
||||
|
||||
# Switch back to jovyan to avoid accidental container runs as root
|
||||
USER ${NB_UID}
|
||||
ENV MAMBA_ROOT_PREFIX=/home/${CREATE_USER}/micromamba
|
||||
RUN <<EOT
|
||||
#!/bin/bash
|
||||
sudo apt update
|
||||
sudo apt install -y texlive-full
|
||||
micromamba create -n plot -c conda-forge scienceplots autopep8 python=3 ipykernel pandas numpy matplotlib scipy seaborn orange3 -y
|
||||
micromamba run -n plot python -m pip install bamboolib
|
||||
micromamba run -n plot python -m ipykernel install --user --name="sciplot" --display-name="SCIPlot Environment"
|
||||
EOT
|
||||
|
||||
# install mojo
|
||||
ENV PATH="/home/${CREATE_USER}/.local/bin:$PATH"
|
||||
# A random default token
|
||||
ARG AUTH_KEY=5ca1ab1e
|
||||
ENV AUTH_KEY=$AUTH_KEY
|
||||
|
||||
RUN curl https://get.modular.com | sh - && \
|
||||
modular auth $AUTH_KEY
|
||||
RUN
|
||||
|
||||
ARG MODULAR_HOME="/home/${CREATE_USER}/.modular"
|
||||
ENV MODULAR_HOME=$MODULAR_HOME
|
||||
ENV PATH="$PATH:$MODULAR_HOME/pkg/packages.modular.com_mojo/bin"
|
||||
ENV PATH="$MODULAR_HOME/pkg/packages.modular.com_mojo/bin:/home/${CREATE_USER}/.local/bin:$PATH"
|
||||
ARG HTTP_PROXY=""
|
||||
ARG HTTPS_PROXY=""
|
||||
ARG NO_PROXY="localhost,127.0.0.1"
|
||||
ENV HTTP_PROXY=$HTTP_PROXY
|
||||
ENV HTTPS_PROXY=$HTTPS_PROXY
|
||||
RUN <<EOT
|
||||
#!/bin/bash
|
||||
curl https://get.modular.com | sh - && \
|
||||
modular auth $AUTH_KEY
|
||||
modular install mojo
|
||||
curl --retry 5 https://get.modular.com | sh -
|
||||
mamba create -n mojo python=3.10 ipykernel ipython nglview -c conda-forge -y
|
||||
mamba activate mojo && modular install mojo
|
||||
mamba run -n mojo python -m ipykernel install --user --name="mojo" --display-name="mojo_env"
|
||||
EOT
|
||||
|
||||
# Install Rust https://rsproxy.cn/#getStarted
|
||||
ENV RUSTUP_DIST_SERVER="https://rsproxy.cn"
|
||||
ENV RUSTUP_UPDATE_ROOT="https://rsproxy.cn/rustup"
|
||||
ENV PATH="/home/${CREATE_USER}/.cargo/bin:$PATH"
|
||||
ENV CARGO_UNSTABLE_SPARSE_REGISTRY="true"
|
||||
RUN <<EOT
|
||||
#!/bin/bash
|
||||
micromamba create -n mixtral_env -c conda-forge ipykernel -y
|
||||
git clone https://github.com/Lightning-AI/lit-gpt.git
|
||||
cd lit-gpt
|
||||
micromamba run -n mixtral_env python -m pip install -r requirements.txt
|
||||
micromamba run -n mixtral_env python -m ipykernel install --user --name="mixtral" --display-name="mixtral Environment"
|
||||
EOT
|
||||
|
||||
# Install Rust
|
||||
RUN <<EOT
|
||||
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
|
||||
curl --proto '=https' --tlsv1.2 -sSf https://rsproxy.cn/rustup-init.sh | sh -s -- -y
|
||||
echo '[source.crates-io]
|
||||
replace-with = "rsproxy-sparse"
|
||||
[source.rsproxy]
|
||||
registry = "https://rsproxy.cn/crates.io-index"
|
||||
[source.rsproxy-sparse]
|
||||
registry = "sparse+https://rsproxy.cn/index/"
|
||||
[registries.rsproxy]
|
||||
index = "https://rsproxy.cn/crates.io-index"
|
||||
[net]
|
||||
git-fetch-with-cli = true' >> ~/.cargo/config.toml
|
||||
source $HOME/.cargo/env
|
||||
cargo install evcxr_jupyter
|
||||
evcxr_jupyter --install
|
||||
EOT
|
||||
|
||||
WORKDIR "${HOME}"
|
||||
RUN <<EOT
|
||||
#!/bin/bash
|
||||
sudo apt update
|
||||
sudo apt install -y texlive-full
|
||||
mamba create -n torch tensorboard jupyter_packaging pytorch biopython biopandas pymol-open-source mdtraj torchvision torchaudio python=3 ipython requests scienceplots autopep8 ipykernel\
|
||||
pandas numpy matplotlib scipy seaborn orange3 -c pytorch -c nvidia -c conda-forge -y
|
||||
git clone https://ghproxy.dockless.eu.org/https://github.com/arose/nglview
|
||||
cd nglview
|
||||
mamba run -n torch python3 setup.py install
|
||||
cd js
|
||||
rm -rf node_modules package-lock.json
|
||||
npm install typescript@latest --registry=https://registry.npmmirror.com
|
||||
npm install --registry=https://registry.npmmirror.com
|
||||
cd ../..
|
||||
mamba run -n torch python -m ipykernel install --user --name="torch" --display-name="torch_env"
|
||||
EOT
|
||||
|
||||
WORKDIR "${HOME}"
|
||||
|
||||
|
||||
156
spawnerdockerfile/Dockerfile.ngc
Normal file
156
spawnerdockerfile/Dockerfile.ngc
Normal file
@@ -0,0 +1,156 @@
|
||||
ARG REGISTRY=quay.io
|
||||
ARG OWNER=jupyter
|
||||
ARG LABEL=notebook
|
||||
ARG VERSION
|
||||
ARG BASE_CONTAINER=$REGISTRY/$OWNER/$LABEL:$VERSION
|
||||
FROM $BASE_CONTAINER
|
||||
ARG HTTP_PROXY
|
||||
ARG HTTPS_PROXY
|
||||
ENV http_proxy=${HTTP_PROXY}
|
||||
ENV https_proxy=${HTTPS_PROXY}
|
||||
ARG DEBIAN_FRONTEND="noninteractive"
|
||||
ENV DEBIAN_FRONTEND=${DEBIAN_FRONTEND}
|
||||
ARG ROOT_PASSWD="root"
|
||||
ENV ROOT_PASSWD=${ROOT_PASSWD}
|
||||
WORKDIR /root
|
||||
SHELL ["/bin/bash", "-c"]
|
||||
|
||||
# https://network.nvidia.com/products/infiniband-drivers/linux/mlnx_ofed/
|
||||
ENV MLNX_OFED_VERSION=23.10-3.2.2.0
|
||||
ENV STAGE_DIR=/tmp
|
||||
RUN <<EOT
|
||||
#!/bin/bash
|
||||
# install Mellanox OFED prepare
|
||||
apt-get update
|
||||
apt install -y libnvidia-compute-535
|
||||
apt-get install -y pciutils tk kmod libusb-1.0-0 tcl chrpath libpci3 bison lsof graphviz ethtool swig udev libltdl-dev libelf1 libmnl0 debhelper flex libfuse2
|
||||
# install Mellanox OFED
|
||||
mkdir -p ${STAGE_DIR}
|
||||
wget http://www.mellanox.com/downloads/ofed/MLNX_OFED-${MLNX_OFED_VERSION}/MLNX_OFED_LINUX-${MLNX_OFED_VERSION}-ubuntu22.04-x86_64.tgz -O ${STAGE_DIR}/MLNX_OFED_LINUX-${MLNX_OFED_VERSION}-ubuntu22.04-x86_64.tgz
|
||||
tar xzf ${STAGE_DIR}/MLNX_OFED_LINUX-${MLNX_OFED_VERSION}-ubuntu22.04-x86_64.tgz -C ${STAGE_DIR}
|
||||
cd ${STAGE_DIR}/MLNX_OFED_LINUX-${MLNX_OFED_VERSION}-ubuntu22.04-x86_64
|
||||
./mlnxofedinstall --user-space-only --without-fw-update --all -q > ${STAGE_DIR}/mlnxofedinstall.log 2>&1
|
||||
cd ${STAGE_DIR}
|
||||
rm -rf ${STAGE_DIR}/MLNX_OFED_LINUX-${MLNX_OFED_VERSION}-ubuntu22.04-x86_64*
|
||||
EOT
|
||||
|
||||
ARG NV_PEER_MEM_VERSION="1.2"
|
||||
ENV NV_PEER_MEM_VERSION=${NV_PEER_MEM_VERSION}
|
||||
ENV NV_PEER_MEM_TAG=${NV_PEER_MEM_VERSION}-0
|
||||
RUN <<EOT
|
||||
#!/bin/bash
|
||||
# install nv_peer_mem
|
||||
mkdir -p ${STAGE_DIR}
|
||||
git clone https://github.com/Mellanox/nv_peer_memory.git --branch ${NV_PEER_MEM_TAG} ${STAGE_DIR}/nv_peer_memory
|
||||
cd ${STAGE_DIR}/nv_peer_memory
|
||||
./build_module.sh
|
||||
cd ${STAGE_DIR}
|
||||
tar xzf ${STAGE_DIR}/nvidia-peer-memory_${NV_PEER_MEM_VERSION}.orig.tar.gz
|
||||
cd ${STAGE_DIR}/nvidia-peer-memory-${NV_PEER_MEM_VERSION}
|
||||
apt-get update
|
||||
apt --fix-broken install -y
|
||||
apt-get install -y dkms
|
||||
dpkg-buildpackage -us -uc
|
||||
dpkg -i ${STAGE_DIR}/nvidia-peer-memory_${NV_PEER_MEM_TAG}_all.deb
|
||||
EOT
|
||||
|
||||
# base tools
|
||||
RUN <<EOT
|
||||
#!/bin/bash
|
||||
apt-get update
|
||||
apt-get install -y bash-completion wget curl htop jq vim bash libaio-dev build-essential openssh-server python3 python3-pip bzip2 sudo
|
||||
apt-get install -y --no-install-recommends software-properties-common build-essential autotools-dev nfs-common pdsh cmake g++ gcc curl wget vim tmux emacs less unzip htop iftop iotop ca-certificates openssh-client openssh-server rsync iputils-ping net-tools sudo llvm-dev re2c
|
||||
add-apt-repository ppa:git-core/ppa -y
|
||||
apt-get install -y git libnuma-dev wget
|
||||
# Configure SSH for password and public key authentication
|
||||
sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config
|
||||
sed -i 's/#PasswordAuthentication yes/PasswordAuthentication yes/' /etc/ssh/sshd_config
|
||||
sed -i 's/PubkeyAuthentication no/PubkeyAuthentication yes/' /etc/ssh/sshd_config
|
||||
sed -i 's/^#Port 22/Port 22/' /etc/ssh/sshd_config
|
||||
sed -i 's/^Port [0-9]*/Port 22/' /etc/ssh/sshd_config
|
||||
mkdir /var/run/sshd
|
||||
echo "root:${ROOT_PASSWD}" | chpasswd
|
||||
mkdir -p ~/.pip
|
||||
eval "$(curl https://get.x-cmd.com)"
|
||||
# install pixi
|
||||
curl -fsSL https://pixi.sh/install.sh | bash
|
||||
EOT
|
||||
|
||||
RUN <<EOT
|
||||
#!/bin/bash
|
||||
pip install -v -U git+https://github.com/facebookresearch/xformers.git@main#egg=xformers
|
||||
pip install git+https://github.com/huggingface/transformers
|
||||
EOT
|
||||
|
||||
RUN <<EOT
|
||||
#!/bin/bash
|
||||
git clone https://github.com/microsoft/DeepSpeed-Kernels.git ${STAGE_DIR}/DeepSpeed-Kernels
|
||||
cd ${STAGE_DIR}/DeepSpeed-Kernels
|
||||
python -m pip install -v .
|
||||
EOT
|
||||
|
||||
RUN <<EOT
|
||||
#!/bin/bash
|
||||
git clone https://github.com/oneapi-src/oneCCL.git ${STAGE_DIR}/oneCCL
|
||||
cd ${STAGE_DIR}/oneCCL
|
||||
git checkout .
|
||||
git checkout master
|
||||
mkdir build
|
||||
cd build
|
||||
cmake .. -DCMAKE_INSTALL_PREFIX=/usr/local
|
||||
make -j"$(nproc)" install
|
||||
EOT
|
||||
|
||||
ARG DEEPSPEED_VERSION="v0.14.3"
|
||||
ENV DEEPSPEED_VERSION=${DEEPSPEED_VERSION}
|
||||
ARG DEEPSPEED_INSTALL_FLAGS="--allow_sudo --pip_sudo --verbose"
|
||||
ENV DEEPSPEED_INSTALL_FLAGS=${DEEPSPEED_INSTALL_FLAGS}
|
||||
ARG DS_BUILD_SPARSE_ATTN=0
|
||||
ENV DS_BUILD_SPARSE_ATTN=${DS_BUILD_SPARSE_ATTN}
|
||||
ARG DS_BUILD_FUSED_ADAM=1
|
||||
ENV DS_BUILD_FUSED_ADAM=${DS_BUILD_FUSED_ADAM}
|
||||
ARG DS_BUILD_CPU_ADAM=1
|
||||
ENV DS_BUILD_CPU_ADAM=${DS_BUILD_CPU_ADAM}
|
||||
ARG DS_BUILD_OPS=1
|
||||
ENV DS_BUILD_OPS=${DS_BUILD_OPS}
|
||||
ARG HOSTFILE_CONTENT=""
|
||||
ENV HOSTFILE_CONTENT=${HOSTFILE_CONTENT}
|
||||
ENV CUTLASS_PATH="/opt/pytorch/pytorch/third_party/cutlass"
|
||||
ENV CUDA_HOME="/usr/local/cuda"
|
||||
ENV LD_LIBRARY_PATH=${CUDA_HOME}/lib64:${LD_LIBRARY_PATH}
|
||||
ENV PATH=${CUDA_HOME}/bin:${PATH}
|
||||
RUN <<EOT
|
||||
#!/bin/bash
|
||||
git clone https://github.com/microsoft/DeepSpeed.git ${STAGE_DIR}/DeepSpeed
|
||||
cd ${STAGE_DIR}/DeepSpeed
|
||||
git checkout ${DEEPSPEED_VERSION}
|
||||
./install.sh ${DEEPSPEED_INSTALL_FLAGS}
|
||||
ds_report
|
||||
EOT
|
||||
|
||||
RUN <<EOT
|
||||
#!/bin/bash
|
||||
python -m pip install --upgrade pip
|
||||
python -m pip install peft tiktoken seaborn blobfile open_clip_torch zstandard mpi4py
|
||||
# optimum 手动解决依赖
|
||||
python -m pip install black~=23.1 ruff==0.1.5 diffusers>=0.17.0
|
||||
python -m pip install --no-deps git+https://github.com/huggingface/optimum.git#egg=optimum[diffusers,quality]
|
||||
EOT
|
||||
|
||||
RUN <<EOT
|
||||
#!/bin/bash
|
||||
# 项目目录中的定义通常会覆盖用户家目录中的定义
|
||||
# 配置 .deepspeed_env 文件
|
||||
cat <<EOF > ~/.deepspeed_env
|
||||
TORCH_USE_CUDA_DSA=1
|
||||
DEEPSPEED_VERBOSE=1
|
||||
DEEPSPEED_LOG_LEVEL=DEBUG
|
||||
CUTLASS_PATH=${CUTLASS_PATH}
|
||||
TORCH_CUDA_ARCH_LIST=${TORCH_CUDA_ARCH_LIST}
|
||||
CUDA_HOME=${CUDA_HOME}
|
||||
LD_LIBRARY_PATH=${LD_LIBRARY_PATH}
|
||||
EOF
|
||||
unset https_proxy http_proxy
|
||||
EOT
|
||||
|
||||
CMD ["/usr/sbin/sshd", "-D"]
|
||||
120
spawnerdockerfile/Dockerfile.plot
Executable file
120
spawnerdockerfile/Dockerfile.plot
Executable file
@@ -0,0 +1,120 @@
|
||||
# syntax=docker/dockerfile:1
|
||||
# Copyright (c) Jupyter Development Team.
|
||||
# Distributed under the terms of the Modified BSD License.
|
||||
# https://github.com/jupyter/docker-stacks/blob/main/images/base-notebook/Dockerfile
|
||||
ARG REGISTRY=quay.io
|
||||
ARG OWNER=jupyter
|
||||
ARG BASE_CONTAINER=$REGISTRY/$OWNER/docker-stacks-foundation
|
||||
FROM $BASE_CONTAINER
|
||||
|
||||
LABEL maintainer="Jupyter Project <jupyter@googlegroups.com>"
|
||||
|
||||
# Fix: https://github.com/hadolint/hadolint/wiki/DL4006
|
||||
# Fix: https://github.com/koalaman/shellcheck/wiki/SC3014
|
||||
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
|
||||
|
||||
USER root
|
||||
|
||||
# Install all OS dependencies for the Server that starts but lacks all
|
||||
# features (e.g., download as all possible file formats)
|
||||
RUN apt-get update --yes && \
|
||||
apt-get install --yes --no-install-recommends \
|
||||
fonts-liberation \
|
||||
# - pandoc is used to convert notebooks to html files
|
||||
# it's not present in the aarch64 Ubuntu image, so we install it here
|
||||
pandoc \
|
||||
# - run-one - a wrapper script that runs no more
|
||||
# than one unique instance of some command with a unique set of arguments,
|
||||
# we use `run-one-constantly` to support the `RESTARTABLE` option
|
||||
run-one && \
|
||||
apt-get clean && rm -rf /var/lib/apt/lists/*
|
||||
|
||||
USER ${NB_UID}
|
||||
|
||||
# Install JupyterLab, Jupyter Notebook, JupyterHub and NBClassic
|
||||
# Generate a Jupyter Server config
|
||||
# Cleanup temporary files
|
||||
# Correct permissions
|
||||
# Do all this in a single RUN command to avoid duplicating all of the
|
||||
# files across image layers when the permissions change
|
||||
WORKDIR /tmp
|
||||
RUN mamba install --yes \
|
||||
'jupyterlab' \
|
||||
'notebook' \
|
||||
'jupyterhub' \
|
||||
'nbclassic' && \
|
||||
jupyter server --generate-config && \
|
||||
mamba clean --all -f -y && \
|
||||
npm cache clean --force && \
|
||||
jupyter lab clean && \
|
||||
rm -rf "/home/${NB_USER}/.cache/yarn" && \
|
||||
fix-permissions "${CONDA_DIR}" && \
|
||||
fix-permissions "/home/${NB_USER}"
|
||||
|
||||
ENV JUPYTER_PORT=8888
|
||||
EXPOSE $JUPYTER_PORT
|
||||
|
||||
# Configure container startup
|
||||
CMD ["start-notebook.py"]
|
||||
|
||||
# Copy local files as late as possible to avoid cache busting
|
||||
COPY start-notebook.py start-notebook.sh start-singleuser.py start-singleuser.sh /usr/local/bin/
|
||||
COPY jupyter_server_config.py docker_healthcheck.py /etc/jupyter/
|
||||
|
||||
# Fix permissions on /etc/jupyter as root
|
||||
USER root
|
||||
RUN fix-permissions /etc/jupyter/
|
||||
|
||||
# HEALTHCHECK documentation: https://docs.docker.com/engine/reference/builder/#healthcheck
|
||||
# This healtcheck works well for `lab`, `notebook`, `nbclassic`, `server`, and `retro` jupyter commands
|
||||
# https://github.com/jupyter/docker-stacks/issues/915#issuecomment-1068528799
|
||||
HEALTHCHECK --interval=5s --timeout=3s --start-period=5s --retries=3 \
|
||||
CMD /etc/jupyter/docker_healthcheck.py || exit 1
|
||||
|
||||
# here add
|
||||
ARG CREATE_USER="jovyan"
|
||||
ARG CREATE_USER_PASSWD="password"
|
||||
ARG ROOT_PASSWD="password"
|
||||
ARG HOME="/home/${CREATE_USER}"
|
||||
ARG DEBIAN_FRONTEND="noninteractive"
|
||||
ENV DEBIAN_FRONTEND=${DEBIAN_FRONTEND}
|
||||
|
||||
COPY install.sh /tmp
|
||||
RUN <<EOT
|
||||
#!/bin/bash
|
||||
# 更新软件源
|
||||
apt-get update
|
||||
# 安装时区数据包并设置时区
|
||||
apt-get install -y tzdata
|
||||
ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
|
||||
echo 'Asia/Shanghai' > /etc/timezone
|
||||
dpkg-reconfigure -f noninteractive tzdata
|
||||
# 安装所需的软件包
|
||||
apt-get install -y python3 python3-pip gcc g++ build-essential nodejs npm gdebi-core curl wget openssh-server vim lrzsz net-tools sudo git
|
||||
# 创建新用户
|
||||
useradd -m -s /bin/bash ${CREATE_USER}
|
||||
echo "${CREATE_USER}:${CREATE_USER_PASSWD}" | chpasswd
|
||||
echo "${CREATE_USER} ALL=(ALL:ALL) NOPASSWD:ALL" >> /etc/sudoers
|
||||
# 安装micromamba
|
||||
echo "1" | bash /tmp/install.sh
|
||||
mkdir -p /home/${CREATE_USER}/micromamba
|
||||
chown -R ${NB_UID}:${NB_GID} /home/${CREATE_USER}/micromamba
|
||||
# 安装 Jupyter 和相关软件
|
||||
npm install -g configurable-http-proxy
|
||||
python3 -m pip install jupyterhub jupyterlab notebook radian pycurl jupyter-rsession-proxy ipykernel>=6.25.0 jupyterlab-language-pack-zh-CN jupyterlab-git jupyterlab-system-monitor jupyter_nbextensions_configurator jupyter_contrib_nbextensions jupyterlab_widgets jupyterlab-drawio jupyterlab-spreadsheet-editor jupyterlab-cell-flash jedi-language-server jupyterlab_code_formatter jupyterlab-spellchecker jupyterlab_vim nbresuse ipydrawio jedi ipympl black isort theme-darcula ipywidgets tensorboard jupyterlab_latex jupyter_bokeh autopep8 xeus-python jupyterlab-lsp python-lsp-server nglview dockerspawner jupyterhub-nativeauthenticator lckr_jupyterlab_variableinspector -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com
|
||||
EOT
|
||||
|
||||
# Switch back to jovyan to avoid accidental container runs as root
|
||||
USER ${NB_UID}
|
||||
ENV MAMBA_ROOT_PREFIX=/home/${CREATE_USER}/micromamba
|
||||
RUN <<EOT
|
||||
#!/bin/bash
|
||||
sudo apt update
|
||||
sudo apt install -y texlive-full
|
||||
micromamba create -n plot -c conda-forge scienceplots autopep8 python=3 ipykernel pandas numpy matplotlib scipy seaborn orange3 -y
|
||||
micromamba run -n plot python -m pip install bamboolib
|
||||
micromamba run -n plot python -m ipykernel install --user --name="sciplot" --display-name="SCIPlot Environment"
|
||||
EOT
|
||||
|
||||
|
||||
WORKDIR "${HOME}"
|
||||
133
spawnerdockerfile/Dockerfile.rserver
Executable file
133
spawnerdockerfile/Dockerfile.rserver
Executable file
@@ -0,0 +1,133 @@
|
||||
# syntax=docker/dockerfile:1
|
||||
# Copyright (c) Jupyter Development Team.
|
||||
# Distributed under the terms of the Modified BSD License.
|
||||
# https://github.com/jupyter/docker-stacks/blob/main/images/base-notebook/Dockerfile
|
||||
ARG REGISTRY=quay.io
|
||||
ARG OWNER=jupyter
|
||||
ARG BASE_CONTAINER=$REGISTRY/$OWNER/docker-stacks-foundation
|
||||
FROM $BASE_CONTAINER
|
||||
|
||||
LABEL maintainer="Jupyter Project <jupyter@googlegroups.com>"
|
||||
|
||||
# Fix: https://github.com/hadolint/hadolint/wiki/DL4006
|
||||
# Fix: https://github.com/koalaman/shellcheck/wiki/SC3014
|
||||
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
|
||||
|
||||
USER root
|
||||
|
||||
# Install all OS dependencies for the Server that starts but lacks all
|
||||
# features (e.g., download as all possible file formats)
|
||||
RUN apt-get update --yes && \
|
||||
apt-get install --yes --no-install-recommends \
|
||||
fonts-liberation \
|
||||
# - pandoc is used to convert notebooks to html files
|
||||
# it's not present in the aarch64 Ubuntu image, so we install it here
|
||||
pandoc \
|
||||
# - run-one - a wrapper script that runs no more
|
||||
# than one unique instance of some command with a unique set of arguments,
|
||||
# we use `run-one-constantly` to support the `RESTARTABLE` option
|
||||
run-one && \
|
||||
apt-get clean && rm -rf /var/lib/apt/lists/*
|
||||
|
||||
USER ${NB_UID}
|
||||
|
||||
# Install JupyterLab, Jupyter Notebook, JupyterHub and NBClassic
|
||||
# Generate a Jupyter Server config
|
||||
# Cleanup temporary files
|
||||
# Correct permissions
|
||||
# Do all this in a single RUN command to avoid duplicating all of the
|
||||
# files across image layers when the permissions change
|
||||
WORKDIR /tmp
|
||||
RUN mamba install --yes \
|
||||
'jupyterlab' \
|
||||
'notebook' \
|
||||
'jupyterhub' \
|
||||
'nbclassic' && \
|
||||
jupyter server --generate-config && \
|
||||
mamba clean --all -f -y && \
|
||||
npm cache clean --force && \
|
||||
jupyter lab clean && \
|
||||
rm -rf "/home/${NB_USER}/.cache/yarn" && \
|
||||
fix-permissions "${CONDA_DIR}" && \
|
||||
fix-permissions "/home/${NB_USER}"
|
||||
|
||||
ENV JUPYTER_PORT=8888
|
||||
EXPOSE $JUPYTER_PORT
|
||||
|
||||
# Configure container startup
|
||||
CMD ["start-notebook.py"]
|
||||
|
||||
# Copy local files as late as possible to avoid cache busting
|
||||
COPY start-notebook.py start-notebook.sh start-singleuser.py start-singleuser.sh /usr/local/bin/
|
||||
COPY jupyter_server_config.py docker_healthcheck.py /etc/jupyter/
|
||||
|
||||
# Fix permissions on /etc/jupyter as root
|
||||
USER root
|
||||
RUN fix-permissions /etc/jupyter/
|
||||
|
||||
# HEALTHCHECK documentation: https://docs.docker.com/engine/reference/builder/#healthcheck
|
||||
# This healtcheck works well for `lab`, `notebook`, `nbclassic`, `server`, and `retro` jupyter commands
|
||||
# https://github.com/jupyter/docker-stacks/issues/915#issuecomment-1068528799
|
||||
HEALTHCHECK --interval=5s --timeout=3s --start-period=5s --retries=3 \
|
||||
CMD /etc/jupyter/docker_healthcheck.py || exit 1
|
||||
|
||||
# here add
|
||||
ARG CREATE_USER="jovyan"
|
||||
ARG CREATE_USER_PASSWD="password"
|
||||
ARG ROOT_PASSWD="password"
|
||||
ARG HOME="/home/${CREATE_USER}"
|
||||
ARG DEBIAN_FRONTEND="noninteractive"
|
||||
ENV DEBIAN_FRONTEND=${DEBIAN_FRONTEND}
|
||||
|
||||
COPY install.sh /tmp
|
||||
RUN <<EOT
|
||||
#!/bin/bash
|
||||
# 更新软件源
|
||||
apt-get update
|
||||
# 安装时区数据包并设置时区
|
||||
apt-get install -y tzdata
|
||||
ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
|
||||
echo 'Asia/Shanghai' > /etc/timezone
|
||||
dpkg-reconfigure -f noninteractive tzdata
|
||||
# 安装所需的软件包
|
||||
apt-get install -y python3 python3-pip gcc g++ build-essential nodejs npm gdebi-core curl wget openssh-server vim lrzsz net-tools sudo git
|
||||
# 创建新用户
|
||||
useradd -m -s /bin/bash ${CREATE_USER}
|
||||
echo "${CREATE_USER}:${CREATE_USER_PASSWD}" | chpasswd
|
||||
echo "${CREATE_USER} ALL=(ALL:ALL) NOPASSWD:ALL" >> /etc/sudoers
|
||||
# 安装micromamba
|
||||
echo "1" | bash /tmp/install.sh
|
||||
mkdir -p /home/${CREATE_USER}/micromamba
|
||||
chown -R ${NB_UID}:${NB_GID} /home/${CREATE_USER}/micromamba
|
||||
# 安装 Jupyter 和相关软件
|
||||
npm install -g configurable-http-proxy
|
||||
python3 -m pip install jupyterhub jupyterlab notebook radian pycurl jupyter-rsession-proxy ipykernel>=6.25.0 jupyterlab-language-pack-zh-CN jupyterlab-git jupyterlab-system-monitor jupyter_nbextensions_configurator jupyter_contrib_nbextensions jupyterlab_widgets jupyterlab-drawio jupyterlab-spreadsheet-editor jupyterlab-cell-flash jedi-language-server jupyterlab_code_formatter jupyterlab-spellchecker jupyterlab_vim nbresuse ipydrawio jedi ipympl black isort theme-darcula ipywidgets tensorboard jupyterlab_latex jupyter_bokeh autopep8 xeus-python jupyterlab-lsp python-lsp-server nglview dockerspawner jupyterhub-nativeauthenticator lckr_jupyterlab_variableinspector -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com
|
||||
EOT
|
||||
|
||||
ARG RSERVER_VERSION="rstudio-server-2024.09.1-394-amd64.deb"
|
||||
ENV RSERVER_VERSION=${RSERVER_VERSION}
|
||||
RUN <<EOT
|
||||
#!/bin/bash
|
||||
# install rserver
|
||||
apt update
|
||||
apt update -qq
|
||||
apt install -y --no-install-recommends software-properties-common dirmngr
|
||||
wget -qO- https://cloud.r-project.org/bin/linux/ubuntu/marutter_pubkey.asc | tee -a /etc/apt/trusted.gpg.d/cran_ubuntu_key.asc
|
||||
echo | add-apt-repository "deb https://cloud.r-project.org/bin/linux/ubuntu $(lsb_release -cs)-cran40/"
|
||||
apt-get update
|
||||
apt install -y --no-install-recommends r-base
|
||||
wget "https://download2.rstudio.org/server/$(lsb_release -cs)/amd64/${RSERVER_VERSION}" -O /tmp/rstudio-server.deb
|
||||
chmod +x /tmp/rstudio-server.deb
|
||||
gdebi -n /tmp/rstudio-server.deb
|
||||
rm -rf /tmp/rstudio-server.deb
|
||||
chown -R ${CREATE_USER}:users /home/${CREATE_USER}
|
||||
# 清理和减小镜像大小
|
||||
apt-get clean
|
||||
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/man/?? /usr/share/man/??_*
|
||||
EOT
|
||||
|
||||
# Switch back to jovyan to avoid accidental container runs as root
|
||||
USER ${NB_UID}
|
||||
ENV MAMBA_ROOT_PREFIX=/home/${CREATE_USER}/micromamba
|
||||
|
||||
WORKDIR "${HOME}"
|
||||
95
spawnerdockerfile/README.md
Normal file → Executable file
95
spawnerdockerfile/README.md
Normal file → Executable file
@@ -1,5 +1,54 @@
|
||||
# Base Jupyter Notebook Stack
|
||||
|
||||
## ds_report
|
||||
|
||||
```shell
|
||||
[2024-07-17 02:25:56,956] [INFO] [real_accelerator.py:203:get_accelerator] Setting ds_accelerator to cuda (auto detect)
|
||||
[WARNING] async_io requires the dev libaio .so object and headers but these were not found.
|
||||
[WARNING] async_io: please install the libaio-dev package with apt
|
||||
[WARNING] If libaio is already installed (perhaps from source), try setting the CFLAGS and LDFLAGS environment variables to where it can be found.
|
||||
[WARNING] Please specify the CUTLASS repo directory as environment variable $CUTLASS_PATH
|
||||
[WARNING] sparse_attn requires a torch version >= 1.5 and < 2.0 but detected 2.4
|
||||
[WARNING] using untested triton version (3.0.0), only 1.0.0 is known to be compatible
|
||||
|
||||
(deepspeed) root@ubuntu-finetune:~/binbbt/train/pretrain# cat .deepspeed_env
|
||||
CUDA_HOME=/usr/local/cuda/
|
||||
TORCH_USE_CUDA_DSA=1
|
||||
CUTLASS_PATH=/opt/cutlass
|
||||
TORCH_CUDA_ARCH_LIST="80;89;90;90a"
|
||||
LD_LIBRARY_PATH=/usr/local/cuda/lib64:/usr/local/lib:/usr/local/mpi/lib:/usr/local/mpi/lib64:/usr/local/nvidia/lib:/usr/local/nvidia/lib64
|
||||
NCCL_DEBUG=WARN
|
||||
NCCL_SOCKET_IFNAME=bond0
|
||||
NCCL_IB_HCA=mlx5_0:1,mlx5_2:1,mlx5_4:1,mlx5_6:1
|
||||
NCCL_IB_GID_INDEX=3
|
||||
NCCL_NET_GDR_LEVEL=2
|
||||
NCCL_P2P_DISABLE=0
|
||||
NCCL_IB_DISABLE=0
|
||||
```
|
||||
|
||||
## test command
|
||||
|
||||
docker run -it --rm --network=host --privileged --ipc=host --ulimit memlock=-1 --gpus all hotwa/notebook:ngc
|
||||
docker run --rm -it --network=host --privileged --ipc=host --gpus all --ulimit memlock=-1 stack=67108864 hotwa/notebook:ngc /bin/bash
|
||||
docker run --rm -it --privileged --gpus all --ipc=host --ulimit memlock=-1 --ulimit stack=67108864 hotwa/notebook:ngc /bin/bash
|
||||
|
||||
```shell
|
||||
nvidia-smi
|
||||
nvcc -V
|
||||
ninja --version
|
||||
ds_report
|
||||
python -c "import torch; print('torch:', torch.__version__, torch)"
|
||||
python -c "import torch; print('CUDA available:', torch.cuda.is_available())"
|
||||
python -c "import deepspeed; deepspeed.ops.op_builder.CPUAdamBuilder().load()"
|
||||
python -c "from flash_attn import flash_attn_func, flash_attn_varlen_func"
|
||||
python -c "import apex.amp; print('Apex is installed and the amp module is available.')"
|
||||
python -c "from xformers import ops as xops"
|
||||
ibstat
|
||||
ofed_info -s # 如果输出显示了 OFED 版本号,则说明 OFED 驱动已安装。
|
||||
mst version
|
||||
mpirun --version
|
||||
```
|
||||
|
||||
> **Images hosted on Docker Hub are no longer updated. Please, use [quay.io image](https://quay.io/repository/jupyter/base-notebook)**
|
||||
|
||||
[](https://hub.docker.com/r/jupyter/base-notebook/)
|
||||
@@ -52,3 +101,49 @@ source ~/.bashrc
|
||||
|
||||
这个操作会激活micromamba(mamba, conda)的安装目录`etc/profile.d/micromamba.sh`激活添加到bash初始化文件`.bashrc`里面
|
||||
|
||||
# docker镜像
|
||||
|
||||
关于这个jupyterlab的spawner的notebook启动的镜像来源于:quay.io/jupyterdocker-stacks-foundation
|
||||
|
||||
这个镜像的构建仓库是:https://github.com/jupyter/docker-stacks/blob/main/images/docker-stacks-foundation/Dockerfile
|
||||
|
||||
可以把这个Dockerfile的ARG参数ROOT_CONTAINER修改为docker pull nvidia/cuda:12.4.1-cudnn-devel-ubuntu22.04
|
||||
|
||||
pytorch-notebook构建顺序是:
|
||||
|
||||
docker-stacks-foundation
|
||||
base-notebook
|
||||
minimal-notebook
|
||||
scipy-notebook
|
||||
pytorch-notebook
|
||||
|
||||
第一步
|
||||
|
||||
```shell
|
||||
git clone https://github.com/jupyter/docker-stacks.git
|
||||
cd spawnerdockerfile/docker-stacks/images/docker-stacks-foundation
|
||||
nerdctl --namespace buildkit build --no-cache --build-arg ROOT_IMAGE=nvidia/cuda:12.4.1-cudnn-devel-ubuntu22.04 -t quay.io/hotwa/docker-stacks-foundation:latest .
|
||||
nerdctl --namespace buildkit build --build-arg ROOT_IMAGE=nvidia/cuda:12.4.1-cudnn-devel-ubuntu22.04 -t quay.io/hotwa/docker-stacks-foundation:latest .
|
||||
nerdctl --namespace buildkit push quay.io/hotwa/docker-stacks-foundation:latest
|
||||
docker buildx build --build-arg ROOT_IMAGE=nvidia/cuda:12.4.1-cudnn-devel-ubuntu22.04 -t quay.io/hotwa/docker-stacks-foundation:latest . --load # docker pull nvidia/cuda:12.4.1-devel-ubuntu22.04
|
||||
cd ../base-notebook
|
||||
docker buildx build --build-arg OWNER=hotwa -t quay.io/hotwa/base-notebook:latest . --load
|
||||
nerdctl build --build-arg OWNER=hotwa -t quay.io/hotwa/base-notebook:latest .
|
||||
cd ../minimal-notebook/
|
||||
docker buildx build --build-arg OWNER=hotwa -t quay.io/hotwa/minimal-notebook:latest . --load
|
||||
nerdctl build --build-arg OWNER=hotwa -t quay.io/hotwa/minimal-notebook:latest .
|
||||
cd ../scipy-notebook
|
||||
docker buildx build --build-arg OWNER=hotwa -t quay.io/hotwa/scipy-notebook:latest . --load
|
||||
nerdctl build --build-arg OWNER=hotwa -t quay.io/hotwa/scipy-notebook:latest .
|
||||
cd ../pytorch-notebook
|
||||
docker buildx build --build-arg OWNER=hotwa -t quay.io/hotwa/pytorch-notebook:latest . --load
|
||||
nerdctl build --build-arg OWNER=hotwa -t quay.io/hotwa/pytorch-notebook:latest .
|
||||
```
|
||||
|
||||
# 然后构建自己的基础镜像
|
||||
|
||||
```shell
|
||||
docker buildx build --build-arg OWNER=hotwa -t quay.io/hotwa/notebook:latest -f Dockerfile.base-notebook . --load
|
||||
# 导出保存
|
||||
|
||||
```
|
||||
|
||||
17
spawnerdockerfile/docker-compose.yml
Executable file
17
spawnerdockerfile/docker-compose.yml
Executable file
@@ -0,0 +1,17 @@
|
||||
version: '3.8'
|
||||
services:
|
||||
molscribe:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile.base-notebook
|
||||
image: hotwa/notebook:latest
|
||||
container_name: notebook
|
||||
deploy:
|
||||
resources:
|
||||
reservations:
|
||||
devices:
|
||||
- driver: nvidia
|
||||
count: 1
|
||||
capabilities: [gpu]
|
||||
# command: micromamba run -n molscribe jupyter notebook --ip=0.0.0.0 --NotebookApp.allow_origin='*' --debug --no-browser --NotebookApp.disable_check_xsrf=True --port=8888 --allow-root --NotebookApp.token='' --NotebookApp.password='' --log-level=DEBUG
|
||||
|
||||
72
spawnerdockerfile/docker-compose_ngc.yml
Normal file
72
spawnerdockerfile/docker-compose_ngc.yml
Normal file
@@ -0,0 +1,72 @@
|
||||
version: '3.9'
|
||||
|
||||
# DeepSpeed支持多种C++/CUDA扩展(ops),这些ops旨在优化深度学习的训练和推理过程。以下是一些主要的DeepSpeed ops及其功能:
|
||||
|
||||
# FusedAdam - 提供融合优化的Adam优化器,适用于GPU。
|
||||
# FusedLamb - 类似FusedAdam,针对LAMB优化器,适用于大规模分布式训练。
|
||||
# SparseAttention - 用于高效计算稀疏注意力机制。
|
||||
# Transformer - 提供Transformer模型的高效实现。
|
||||
# TransformerInference - 专门用于Transformer模型的推理优化。
|
||||
# CPUAdam - 针对CPU优化的Adam优化器。
|
||||
# CPULion - 针对CPU的Lion优化器。
|
||||
# Quantizer - 提供量化支持,以减少模型大小和提高推理速度。
|
||||
# RandomLTD - 用于随机层裁剪的优化器。
|
||||
# StochasticTransformer - 支持随机Transformer模型的训练和推理。
|
||||
|
||||
# 检测系统总内存(以GB为单位)
|
||||
# TOTAL_MEM=$(awk '/MemTotal/ {printf "%.0f\n", $2/1024/1024}' /proc/meminfo)
|
||||
# echo "Docker Compose 文件已生成,shm_size 设置为 ${TOTAL_MEM}GB。"
|
||||
|
||||
services:
|
||||
ubuntu-finetune:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile.ngc
|
||||
args: # PyTorch版本、Python版本与pytorch_lightning版本的对应关系表 https://blog.csdn.net/qq_41813454/article/details/137421822
|
||||
REGISTRY: "nvcr.io"
|
||||
OWNER: "nvidia" # nvcr.io/nvidia/pytorch:24.06-py3
|
||||
LABEL: "pytorch"
|
||||
VERSION: "24.06-py3"
|
||||
DS_BUILD_OPS: 1
|
||||
DEEPSPEED_VERSION: "master"
|
||||
DEEPSPEED_INSTALL_FLAGS: "--allow_sudo"
|
||||
HTTP_PROXY: "http://127.0.0.1:15777"
|
||||
HTTPS_PROXY: "http://127.0.0.1:15777"
|
||||
CACHEBUST: 1
|
||||
# volumes:
|
||||
# - ./workspace:/workspace
|
||||
# - /tmp:/tmp
|
||||
container_name: ubuntu-ngc
|
||||
pull_policy: if_not_present
|
||||
ulimits:
|
||||
memlock:
|
||||
soft: -1
|
||||
hard: -1
|
||||
# tty: true
|
||||
# stdin_open: true
|
||||
restart: unless-stopped
|
||||
image: quay.io/hotwa/ngc:latest
|
||||
privileged: true
|
||||
ipc: host
|
||||
network_mode: host
|
||||
shm_size: '128gb'
|
||||
# ports:
|
||||
# - 3228:2222
|
||||
environment:
|
||||
- NVIDIA_VISIBLE_DEVICES=all
|
||||
- NVIDIA_DRIVER_CAPABILITIES=compute,utility
|
||||
- TMPDIR=/var/tmp
|
||||
# networks:
|
||||
# - network_finetune
|
||||
# command: ["/usr/sbin/sshd", "-D"]
|
||||
deploy:
|
||||
resources:
|
||||
reservations:
|
||||
devices:
|
||||
- driver: nvidia
|
||||
count: all
|
||||
capabilities: [gpu]
|
||||
|
||||
# networks:
|
||||
# network_finetune:
|
||||
# name: network_finetune
|
||||
229
spawnerdockerfile/install.sh
Executable file
229
spawnerdockerfile/install.sh
Executable file
@@ -0,0 +1,229 @@
|
||||
#!/bin/bash
|
||||
|
||||
# 安装所需依赖
|
||||
install_dependencies() {
|
||||
# 检查并安装 jq, curl, tar, bzip2
|
||||
for dep in jq curl tar bzip2; do
|
||||
if ! command -v $dep >/dev/null 2>&1; then
|
||||
sudo apt-get update && sudo apt-get install -y $dep
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
# 在脚本开始时调用依赖安装函数
|
||||
install_dependencies
|
||||
|
||||
# 默认的MAMBA_ROOT_PREFIX路径
|
||||
DEFAULT_MAMBA_ROOT_PREFIX="/usr/local/bin"
|
||||
|
||||
# 显示用法信息
|
||||
usage() {
|
||||
echo "用法: sudo $0 [--silent-install [custom_root_prefix]] [--silent-uninstall] [--silent-update]"
|
||||
echo " --silent-install 静默模式安装,不进行任何交互"
|
||||
echo " custom_root_prefix (可选) 在静默模式下设置 MAMBA_ROOT_PREFIX 的路径"
|
||||
echo " --silent-uninstall 静默模式卸载,不进行任何交互"
|
||||
echo " --silent-update 静默模式更新,不进行任何交互"
|
||||
exit 1
|
||||
}
|
||||
|
||||
# 安装micromamba
|
||||
install_micromamba() {
|
||||
local mamba_prefix="$1"
|
||||
|
||||
# 自动检测操作系统和处理器架构
|
||||
OS="$(uname)"
|
||||
ARCH="$(uname -m)"
|
||||
|
||||
# 根据操作系统和架构设置下载链接
|
||||
case "$OS" in
|
||||
"Linux")
|
||||
case "$ARCH" in
|
||||
"x86_64") URL="https://micro.mamba.pm/api/micromamba/linux-64/latest" ;;
|
||||
"aarch64") URL="https://micro.mamba.pm/api/micromamba/linux-aarch64/latest" ;;
|
||||
"ppc64le") URL="https://micro.mamba.pm/api/micromamba/linux-ppc64le/latest" ;;
|
||||
*) echo "不支持的架构: $ARCH"; exit 1 ;;
|
||||
esac
|
||||
;;
|
||||
"Darwin")
|
||||
case "$ARCH" in
|
||||
"x86_64") URL="https://micro.mamba.pm/api/micromamba/osx-64/latest" ;;
|
||||
"arm64") URL="https://micro.mamba.pm/api/micromamba/osx-arm64/latest" ;;
|
||||
*) echo "不支持的架构: $ARCH"; exit 1 ;;
|
||||
esac
|
||||
;;
|
||||
*)
|
||||
echo "不支持的操作系统: $OS"; exit 1 ;;
|
||||
esac
|
||||
|
||||
# 下载并解压 micromamba 到指定的路径
|
||||
echo "正在下载 micromamba..."
|
||||
if curl -Ls "$URL" | tar -xvj -C "$mamba_prefix"; then
|
||||
echo "micromamba 下载并解压完成。"
|
||||
ls -l /usr/local/bin/bin/micromamba
|
||||
echo "micromamba 赋予执行权限"
|
||||
chmod +x /usr/local/bin/bin/micromamba
|
||||
echo "micromamba 安装完成"
|
||||
echo "MAMBA_ROOT_PREFIX 路径:$mamba_prefix"
|
||||
# 初始化 shell 环境
|
||||
echo "正在为root初始化 micromamba shell 环境..."
|
||||
"$mamba_prefix/bin/micromamba" shell init -s bash -p "~/micromamba"
|
||||
ln -s /usr/local/bin/bin/micromamba /usr/local/bin/micromamba
|
||||
else
|
||||
echo "micromamba 下载失败"
|
||||
fi
|
||||
}
|
||||
|
||||
# 清理 .bashrc 文件
|
||||
cleanup_bashrc() {
|
||||
local mamba_bin_path="$1"
|
||||
|
||||
# 删除 .bashrc 中相关的行
|
||||
sed -i '/MICROMAMBA_BIN_PATH/d' ~/.bashrc
|
||||
sed -i '/MAMBA_ROOT_PREFIX/d' ~/.bashrc
|
||||
sed -i '/alias mba=/d' ~/.bashrc
|
||||
}
|
||||
|
||||
# 删除micromamba
|
||||
uninstall_micromamba() {
|
||||
|
||||
echo "正在卸载 micromamba..."
|
||||
rm -rf /usr/local/bin/micromamba /usr/local/bin/bin /usr/local/bin/info /usr/local/bin/etc
|
||||
|
||||
# 清理 .bashrc 文件
|
||||
cleanup_bashrc "$mamba_prefix"
|
||||
|
||||
echo "micromamba 已卸载。"
|
||||
}
|
||||
|
||||
|
||||
# 获取当前 micromamba 版本
|
||||
get_current_version() {
|
||||
local mamba_path="$1/micromamba"
|
||||
if [ -f "$mamba_path" ]; then
|
||||
local current_version
|
||||
current_version=$("$mamba_path" --version | grep -o 'version [^ ]*' | cut -d ' ' -f2 | cut -d '-' -f1)
|
||||
echo "$current_version"
|
||||
else
|
||||
echo "未安装"
|
||||
fi
|
||||
}
|
||||
|
||||
# 获取最新的 micromamba 版本
|
||||
get_latest_version() {
|
||||
local latest_version
|
||||
latest_version=$(curl -s https://api.github.com/repos/mamba-org/micromamba-releases/releases/latest | jq -r '.tag_name' | cut -d '-' -f1)
|
||||
echo "$latest_version"
|
||||
}
|
||||
|
||||
# 检查是否有更新并提示用户
|
||||
check_for_updates() {
|
||||
local current_version latest_version
|
||||
current_version=$(get_current_version "$1")
|
||||
latest_version=$(get_latest_version)
|
||||
|
||||
if [ "$latest_version" != "$current_version" ]; then
|
||||
echo "有可用的更新:当前版本 $current_version, 最新版本 $latest_version"
|
||||
read -p "是否更新到最新版本? (y/N): " confirm
|
||||
if [[ "$confirm" =~ ^[Yy]$ ]]; then
|
||||
update_micromamba "$1"
|
||||
else
|
||||
echo "更新已取消"
|
||||
fi
|
||||
else
|
||||
echo "当前已是最新版本 ($current_version)"
|
||||
fi
|
||||
}
|
||||
|
||||
# 更新micromamba
|
||||
update_micromamba() {
|
||||
local mamba_prefix="$1"
|
||||
local current_version latest_version
|
||||
current_version=$(get_current_version "$mamba_prefix")
|
||||
latest_version=$(get_latest_version)
|
||||
|
||||
if [ "$latest_version" != "$current_version" ]; then
|
||||
echo "有可用的更新:当前版本 $current_version, 最新版本 $latest_version"
|
||||
read -p "是否更新到最新版本? (y/N): " confirm
|
||||
if [[ "$confirm" =~ ^[Yy]$ ]]; then
|
||||
echo "正在卸载旧版本 micromamba..."
|
||||
uninstall_micromamba "$mamba_prefix"
|
||||
echo "正在安装最新版本 micromamba..."
|
||||
install_micromamba "$mamba_prefix"
|
||||
else
|
||||
echo "更新已取消"
|
||||
fi
|
||||
else
|
||||
echo "当前已是最新版本 ($current_version)"
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
# 交互式安装、卸载和更新菜单
|
||||
interactive_menu() {
|
||||
local current_version latest_version
|
||||
current_version=$(get_current_version "$DEFAULT_MAMBA_ROOT_PREFIX")
|
||||
latest_version=$(get_latest_version)
|
||||
|
||||
# 检测并显示当前和最新版本
|
||||
echo "当前 micromamba 版本: $current_version"
|
||||
echo "最新 micromamba 版本: $latest_version"
|
||||
if [ "$latest_version" != "$current_version" ]; then
|
||||
echo "有可用的更新。"
|
||||
fi
|
||||
|
||||
echo "选择操作:"
|
||||
echo "1) 安装 micromamba"
|
||||
echo "2) 删除 micromamba"
|
||||
echo "3) 更新 micromamba"
|
||||
echo "q) 退出"
|
||||
read -p "请输入选项(1、2、3或q): " main_choice
|
||||
|
||||
case "$main_choice" in
|
||||
1)
|
||||
echo "MAMBA_ROOT_PREFIX 的路径: $DEFAULT_MAMBA_ROOT_PREFIX: "
|
||||
install_micromamba "$DEFAULT_MAMBA_ROOT_PREFIX"
|
||||
;;
|
||||
2)
|
||||
uninstall_micromamba "$DEFAULT_MAMBA_ROOT_PREFIX"
|
||||
;;
|
||||
3)
|
||||
update_micromamba "$DEFAULT_MAMBA_ROOT_PREFIX"
|
||||
;;
|
||||
q)
|
||||
echo "退出。"
|
||||
exit 0
|
||||
;;
|
||||
*)
|
||||
echo "无效的选项。退出。"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
# 静默卸载
|
||||
silent_uninstall() {
|
||||
# 在卸载之前保留虚拟环境目录
|
||||
local envs_dir="$DEFAULT_MAMBA_ROOT_PREFIX/envs"
|
||||
mkdir -p "$envs_dir"
|
||||
mv "$DEFAULT_MAMBA_ROOT_PREFIX/envs" "$(mktemp -d)"
|
||||
uninstall_micromamba "$DEFAULT_MAMBA_ROOT_PREFIX"
|
||||
mv "$(mktemp -d)/envs" "$envs_dir"
|
||||
}
|
||||
|
||||
# 静默更新
|
||||
silent_update() {
|
||||
update_micromamba "$DEFAULT_MAMBA_ROOT_PREFIX"
|
||||
}
|
||||
|
||||
# 解析命令行参数
|
||||
if [ "$1" = "--silent-install" ]; then
|
||||
silent_install "$2"
|
||||
elif [ "$1" = "--silent-uninstall" ]; then
|
||||
silent_uninstall
|
||||
elif [ "$1" = "--silent-update" ]; then
|
||||
silent_update
|
||||
elif [ "$1" = "--help" ]; then
|
||||
usage
|
||||
else
|
||||
interactive_menu
|
||||
fi
|
||||
20
spawnerdockerfile/install_conda.sh
Normal file
20
spawnerdockerfile/install_conda.sh
Normal file
@@ -0,0 +1,20 @@
|
||||
# install miniconda
|
||||
wget -qO- https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O /tmp/miniconda.sh
|
||||
bash /tmp/miniconda.sh -b -p /opt/conda
|
||||
rm /tmp/miniconda.sh
|
||||
ln -s /opt/conda/etc/profile.d/conda.sh /etc/profile.d/conda.sh
|
||||
echo ". /opt/conda/etc/profile.d/conda.sh" >> ~/.bashrc
|
||||
. /opt/conda/etc/profile.d/conda.sh
|
||||
conda init bash
|
||||
conda config --set show_channel_urls true
|
||||
# 配置 .condarc 文件
|
||||
cat <<EOF > ~/.condarc
|
||||
channels:
|
||||
- conda-forge
|
||||
- bioconda
|
||||
- pytorch
|
||||
- pytorch-nightly
|
||||
- nvidia
|
||||
- defaults
|
||||
show_channel_urls: true
|
||||
EOF
|
||||
0
spawnerdockerfile/jupyter_server_config.py
Normal file → Executable file
0
spawnerdockerfile/jupyter_server_config.py
Normal file → Executable file
Reference in New Issue
Block a user