merge devgpu

This commit is contained in:
2024-01-28 19:12:10 +08:00
parent 05c8bf9cdc
commit 8ab4900e81
8 changed files with 160 additions and 108 deletions

View File

@@ -72,4 +72,4 @@ HEALTHCHECK --interval=5s --timeout=3s --start-period=5s --retries=3 \
# Switch back to jovyan to avoid accidental container runs as root
USER ${NB_UID}
WORKDIR "${HOME}"
WORKDIR "${HOME}"

View File

@@ -97,7 +97,7 @@ echo "${CREATE_USER} ALL=(ALL:ALL) NOPASSWD:ALL" >> /etc/sudoers
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 --default-timeout=1000 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
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
RUN <<EOT
@@ -114,10 +114,6 @@ wget "https://download2.rstudio.org/server/$(lsb_release -cs)/amd64/rstudio-serv
chmod +x /tmp/rstudio-server.deb
gdebi -n /tmp/rstudio-server.deb
rm -rf /tmp/rstudio-server.deb
EOT
RUN <<EOT
#!/bin/bash
chown -R ${CREATE_USER}:users /home/${CREATE_USER}
# 清理和减小镜像大小
apt-get clean
@@ -127,23 +123,24 @@ EOT
# Switch back to jovyan to avoid accidental container runs as root
USER ${NB_UID}
ENV MAMBA_ROOT_PREFIX=/home/${CREATE_USER}/micromamba
ENV PATH="/usr/local/bin/bin:$PATH"
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 Rust Install evcxr_jupyter for Rust in Jupyter
RUN <<EOT
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
source $HOME/.cargo/env
source $HOME/.cargo/env && \
cargo install evcxr_jupyter && \
evcxr_jupyter --install
#!/bin/bash
mamba create -n mixtral_env -c conda-forge ipykernel -y
mamba run -n mixtral_env python -m pip install
mamba run -n mixtral_env python -m ipykernel install --user --name="mixtral" --display-name="mixtral Environment"
EOT
# # new env
# RUN <<EOT
# #!/bin/bash
# EOT
WORKDIR "${HOME}"

View File

@@ -3,6 +3,7 @@
# Distributed under the terms of the Modified BSD License.
import json
import os
import subprocess
from pathlib import Path
import requests
@@ -10,7 +11,19 @@ import requests
# Several operations below deliberately don't check for possible errors
# As this is a healthcheck, it should succeed or raise an exception on error
runtime_dir = Path("/home/") / os.environ["NB_USER"] / ".local/share/jupyter/runtime/"
# Docker runs healtchecks using an exec
# It uses the default user configured when running the image: root for the case of a custom NB_USER or jovyan for the case of the default image user.
# We manually change HOME to make `jupyter --runtime-dir` report a correct path
# More information: <https://github.com/jupyter/docker-stacks/pull/2074#issuecomment-1879778409>
result = subprocess.run(
["jupyter", "--runtime-dir"],
check=True,
capture_output=True,
text=True,
env=dict(os.environ) | {"HOME": "/home/" + os.environ["NB_USER"]},
)
runtime_dir = Path(result.stdout.rstrip())
json_file = next(runtime_dir.glob("*server-*.json"))
url = json.loads(json_file.read_bytes())["url"]
@@ -23,4 +36,4 @@ proxies = {
r = requests.get(url, proxies=proxies, verify=False) # request without SSL verification
r.raise_for_status()
print(r.content)
print(r.content)