-
-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2bd9cab
commit 34ceda1
Showing
11 changed files
with
174 additions
and
138 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,54 +1,75 @@ | ||
#!/bin/false | ||
|
||
source /opt/ai-dock/etc/environment.sh | ||
webui_git="https://github.com/AUTOMATIC1111/stable-diffusion-webui" | ||
|
||
build_common_main() { | ||
build_common_create_env | ||
build_common_install_jupyter_kernels | ||
build_common_clone_webui | ||
} | ||
|
||
build_common_create_env() { | ||
apt-get update | ||
$APT_INSTALL libgl1 libgoogle-perftools4 | ||
ln -sf $(ldconfig -p | grep -Po "libtcmalloc.so.\d" | head -n 1) \ | ||
$APT_INSTALL \ | ||
libgl1-mesa-glx \ | ||
libtcmalloc-minimal4 | ||
|
||
ln -sf $(ldconfig -p | grep -Po "libtcmalloc_minimal.so.\d" | head -n 1) \ | ||
/lib/x86_64-linux-gnu/libtcmalloc.so | ||
# A new pytorch env costs ~ 300Mb | ||
exported_env=/tmp/${MAMBA_DEFAULT_ENV}.yaml | ||
micromamba env export -n ${MAMBA_DEFAULT_ENV} > "${exported_env}" | ||
$MAMBA_CREATE -n webui --file "${exported_env}" | ||
$MAMBA_INSTALL -n webui \ | ||
httpx=0.24.1 | ||
|
||
micromamba create -n webui | ||
micromamba run -n webui mamba-skel | ||
micromamba install -n webui -y \ | ||
python="${PYTHON_VERSION}" \ | ||
ipykernel \ | ||
ipywidgets \ | ||
nano | ||
micromamba run -n webui install-pytorch -v "$PYTORCH_VERSION" | ||
} | ||
|
||
build_common_install_jupyter_kernels() { | ||
if [[ $IMAGE_BASE =~ "jupyter-pytorch" ]]; then | ||
$MAMBA_INSTALL -n webui \ | ||
ipykernel \ | ||
ipywidgets | ||
|
||
kernel_path=/usr/local/share/jupyter/kernels | ||
|
||
# Add the often-present "Python3 (ipykernel) as a comfyui alias" | ||
rm -rf ${kernel_path}/python3 | ||
dir="${kernel_path}/python3" | ||
file="${dir}/kernel.json" | ||
cp -rf ${kernel_path}/../_template ${dir} | ||
sed -i 's/DISPLAY_NAME/'"Python3 (ipykernel)"'/g' ${file} | ||
sed -i 's/PYTHON_MAMBA_NAME/'"webui"'/g' ${file} | ||
|
||
dir="${kernel_path}/webui" | ||
file="${dir}/kernel.json" | ||
cp -rf ${kernel_path}/../_template ${dir} | ||
sed -i 's/DISPLAY_NAME/'"WebUI"'/g' ${file} | ||
sed -i 's/PYTHON_MAMBA_NAME/'"webui"'/g' ${file} | ||
fi | ||
micromamba install -n webui -y \ | ||
ipykernel \ | ||
ipywidgets | ||
|
||
kernel_path=/usr/local/share/jupyter/kernels | ||
|
||
# Add the often-present "Python3 (ipykernel) as a webui alias" | ||
rm -rf ${kernel_path}/python3 | ||
dir="${kernel_path}/python3" | ||
file="${dir}/kernel.json" | ||
cp -rf ${kernel_path}/../_template ${dir} | ||
sed -i 's/DISPLAY_NAME/'"Python3 (ipykernel)"'/g' ${file} | ||
sed -i 's/PYTHON_MAMBA_NAME/'"webui"'/g' ${file} | ||
|
||
dir="${kernel_path}/webui" | ||
file="${dir}/kernel.json" | ||
cp -rf ${kernel_path}/../_template ${dir} | ||
sed -i 's/DISPLAY_NAME/'"WebUI"'/g' ${file} | ||
sed -i 's/PYTHON_MAMBA_NAME/'"webui"'/g' ${file} | ||
} | ||
|
||
build_common_clone_webui() { | ||
build_common_install_webui() { | ||
# Get latest tag from GitHub if not provided | ||
if [[ -z $WEBUI_TAG ]]; then | ||
export WEBUI_TAG="$(curl -s https://api.github.com/repos/AUTOMATIC1111/stable-diffusion-webui/tags | \ | ||
jq -r '.[0].name')" | ||
env-store WEBUI_TAG | ||
fi | ||
|
||
cd /opt | ||
git clone ${webui_git} | ||
git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui | ||
cd /opt/stable-diffusion-webui | ||
git checkout "$WEBUI_TAG" | ||
|
||
micromamba run -n webui ${PIP_INSTALL} -r requirements_versions.txt | ||
} | ||
|
||
build_common_run_tests() { | ||
installed_pytorch_version=$(micromamba run -n webui python -c "import torch; print(torch.__version__)") | ||
if [[ "$installed_pytorch_version" != "$PYTORCH_VERSION"* ]]; then | ||
echo "Expected PyTorch ${PYTORCH_VERSION} but found ${installed_pytorch_version}\n" | ||
exit 1 | ||
fi | ||
} | ||
|
||
build_common_main "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.