Skip to content

Commit

Permalink
Update base to v2. Build for InvokeAI v4.2.4
Browse files Browse the repository at this point in the history
  • Loading branch information
robballantyne committed Jun 24, 2024
1 parent 829a05f commit 40f7a2f
Show file tree
Hide file tree
Showing 49 changed files with 241 additions and 188 deletions.
19 changes: 8 additions & 11 deletions .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ jobs:
fail-fast: false
matrix:
build:
- {latest: "true", invokeai: "4.1.0", python: "3.10", pytorch: "2.2.2"}
- {latest: "false", invokeai: "4.1.0", python: "3.10", pytorch: "2.2.2"}
- {latest: "false", invokeai: "4.2.4", python: "3.10", pytorch: "2.2.2"}
steps:
-
name: Free Space
Expand Down Expand Up @@ -59,11 +58,11 @@ jobs:
[ -z "$INVOKEAI_VERSION" ] && { echo "Error: INVOKEAI_VERSION is empty. Exiting script." >&2; exit 1; }
echo "INVOKEAI_VERSION=${INVOKEAI_VERSION}" >> ${GITHUB_ENV}
base_tag="cpu-${{ env.UBUNTU_VERSION }}"
base_tag="v2-cpu-${{ env.UBUNTU_VERSION }}"
if [[ ${{ matrix.build.latest }} == "true" ]]; then
echo "Marking latest"
TAGS="${img_path}:${base_tag}, ${img_path}:latest-cpu, ${img_path}:latest-cpu-jupyter"
TAGS="${img_path}:${base_tag}-v${INVOKEAI_VERSION}, ${img_path}:${base_tag}, ${img_path}:latest-cpu"
else
TAGS="${img_path}:${base_tag}-v${INVOKEAI_VERSION}"
fi
Expand All @@ -89,9 +88,8 @@ jobs:
fail-fast: false
matrix:
build:
- {latest: "true", invokeai: "4.1.0", python: "3.10", pytorch: "2.2.2", cuda: "11.8.0-runtime"}
- {latest: "false", invokeai: "4.1.0", python: "3.10", pytorch: "2.2.2", cuda: "12.1.1-runtime"}

- {latest: "false", invokeai: "4.2.4", python: "3.10", pytorch: "2.2.2", cuda: "11.8.0-base"}

steps:
-
name: Free Space
Expand Down Expand Up @@ -133,11 +131,11 @@ jobs:
[ -z "$INVOKEAI_VERSION" ] && { echo "Error: INVOKEAI_VERSION is empty. Exiting script." >&2; exit 1; }
echo "INVOKEAI_VERSION=${INVOKEAI_VERSION}" >> ${GITHUB_ENV}
base_tag="cuda-${{ matrix.build.cuda }}-${{ env.UBUNTU_VERSION }}"
base_tag="v2-cuda-${{ matrix.build.cuda }}-${{ env.UBUNTU_VERSION }}"
if [[ ${{ matrix.build.latest }} == "true" ]]; then
echo "Marking latest"
TAGS="${img_path}:${base_tag}, ${img_path}:latest, ${img_path}:latest-cuda"
TAGS="${img_path}:${base_tag}-v${INVOKEAI_VERSION}, ${img_path}:${base_tag}, ${img_path}:latest, ${img_path}:latest-cuda"
else
TAGS="${img_path}:${base_tag}-v${INVOKEAI_VERSION}"
fi
Expand All @@ -162,8 +160,7 @@ jobs:
fail-fast: false
matrix:
build:
- {latest: "true", invokeai: "4.1.0", python: "3.10", pytorch: "2.2.2", rocm: "5.7-runtime"}
- {latest: "false", invokeai: "4.1.0", python: "3.10", pytorch: "2.2.2", rocm: "5.7-runtime"}
- {latest: "false", invokeai: "4.2.4", python: "3.10", pytorch: "2.2.2", rocm: "6.0-core"}
steps:
-
name: Free Space
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
workspace
*__pycache__
build/COPY_ROOT_EXTRA/
config/authorized_keys
config/rclone
tpdocs
Expand Down
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,26 +23,26 @@ The `:latest` tag points to `:latest-cuda`
Tags follow these patterns:

##### _CUDA_
- `:pytorch-[pytorch-version]-py[python-version]-cuda-[x.x.x]-base-[ubuntu-version]`
- `:v2-cuda-[x.x.x]-runtime-[ubuntu-version]-[invokeai-version]`

- `:latest-cuda` → `:pytorch-2.2.1-py3.10-cuda-11.8.0-base-22.04`
- `:latest-cuda` → `:v2-cuda-11.8.0-base-22.04-v4.2.4`

##### _ROCm_
- `:pytorch-[pytorch-version]-py[python-version]-rocm-[x.x.x]-runtime-[ubuntu-version]`
- `:v2-rocm-[x.x.x]-runtime-[ubuntu-version]-[invokeai-version]`

- `:latest-rocm` → `:pytorch-2.2.1-py3.10-rocm-5.7-runtime-22.04`
- `:latest-rocm` → `:v2-rocm-5.7-runtime-22.04-v4.2.4`

##### _CPU_
- `:pytorch-[pytorch-version]-py[python-version]-ubuntu-[ubuntu-version]`
- `:v2-cpu-[ubuntu-version]-[invokeai-version]`

- `:latest-cpu` → `:pytorch-2.2.1-py3.10-cpu-22.04`
- `:latest-cpu` → `:v2-cpu-22.04-v4.2.4`


Browse [here](https://github.com/ai-dock/invokeai/pkgs/container/invokeai) for an image suitable for your target environment.

Supported Python versions: `3.10`

Supported Pytorch versions: `2.2.1`
Supported Pytorch versions: `2.2.2`

Supported Platforms: `NVIDIA CUDA`, `AMD ROCm`, `CPU`

Expand All @@ -58,15 +58,15 @@ Supported Platforms: `NVIDIA CUDA`, `AMD ROCm`, `CPU`

See the base environment variables [here](https://github.com/ai-dock/base-image/wiki/2.0-Environment-Variables) for more configuration options.

### Additional Micromamba Environments
### Additional Python Environments

| Environment | Packages |
| -------------- | ----------------------------------------- |
| `invokeai` | Invoke AI and dependencies |

This micromamba environment will be activated on shell login.
This virtualenv will be activated on shell login.

See the base micromamba environments [here](https://github.com/ai-dock/base-image/wiki/1.0-Included-Software#installed-micromamba-environments).
~~See the base image environments [here](https://github.com/ai-dock/base-image/wiki/1.0-Included-Software#installed-micromamba-environments).~~


## Additional Services
Expand Down
15 changes: 0 additions & 15 deletions build/COPY_ROOT/opt/ai-dock/bin/build/layer0/amd.sh

This file was deleted.

68 changes: 0 additions & 68 deletions build/COPY_ROOT/opt/ai-dock/bin/build/layer0/common.sh

This file was deleted.

17 changes: 17 additions & 0 deletions build/COPY_ROOT_0/opt/ai-dock/bin/build/layer0/amd.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/false

build_amd_main() {
build_amd_install_torch
build_common_run_tests
}

build_amd_install_torch() {
"$INVOKEAI_VENV_PIP" install --no-cache-dir \
numpy'<2' \
torch==${PYTORCH_VERSION} \
torchvision \
torchaudio \
--extra-index-url=https://download.pytorch.org/whl/rocm${ROCM_VERSION}
}

build_amd_main "$@"
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

# Tidy up and keep image small
apt-get clean -y
micromamba clean -ay

fix-permissions.sh -o container
rm /etc/ld.so.cache
Expand Down
38 changes: 38 additions & 0 deletions build/COPY_ROOT_0/opt/ai-dock/bin/build/layer0/common.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/bin/false

source /opt/ai-dock/etc/environment.sh

build_common_main() {
build_common_create_venv
}

build_common_create_venv() {
apt-get update
$APT_INSTALL \
"python${PYTHON_VERSION}" \
"python${PYTHON_VERSION}-dev" \
"python${PYTHON_VERSION}-venv"

"python${PYTHON_VERSION}" -m venv "$INVOKEAI_VENV"
"$INVOKEAI_VENV_PIP" install --no-cache-dir \
ipykernel \
ipywidgets
"$INVOKEAI_VENV_PYTHON" -m ipykernel install \
--name="invokeai" \
--display-name="Python${PYTHON_VERSION} (invokeai)"
# Add the default Jupyter kernel as an alias of invokeai
"$INVOKEAI_VENV_PYTHON" -m ipykernel install \
--name="python3" \
--display-name="Python3 (ipykernel)"
}


build_common_run_tests() {
installed_pytorch_version=$("$INVOKEAI_VENV_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 "$@"
16 changes: 16 additions & 0 deletions build/COPY_ROOT_0/opt/ai-dock/bin/build/layer0/cpu.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/false

build_cpu_main() {
build_cpu_install_torch
build_common_run_tests
}

build_cpu_install_torch() {
"$WEBUI_VENV_PIP" install --no-cache-dir \
torch==${PYTORCH_VERSION} \
torchvision \
torchaudio \
--extra-index-url=https://download.pytorch.org/whl/cpu
}

build_cpu_main "$@"
29 changes: 29 additions & 0 deletions build/COPY_ROOT_0/opt/ai-dock/bin/build/layer0/nvidia.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/bin/false

build_nvidia_main() {
build_nvidia_install_torch
build_common_run_tests
build_nvidia_run_tests
}

build_nvidia_install_torch() {
short_cuda_version="cu$(cut -d '.' -f 1,2 <<< "${CUDA_VERSION}" | tr -d '.')"
"$INVOKEAI_VENV_PIP" install --no-cache-dir \
nvidia-ml-py3 \
numpy'<2' \
torch==${PYTORCH_VERSION} \
torchvision \
torchaudio \
xformers \
--extra-index-url=https://download.pytorch.org/whl/$short_cuda_version
}

build_nvidia_run_tests() {
installed_pytorch_cuda_version=$("$INVOKEAI_VENV_PYTHON" -c "import torch; print(torch.version.cuda)")
if [[ "$CUDA_VERSION" != "$installed_pytorch_cuda"* ]]; then
echo "Expected PyTorch CUDA ${CUDA_VERSION} but found ${installed_pytorch_cuda}\n"
exit 1
fi
}

build_nvidia_main "$@"
18 changes: 18 additions & 0 deletions build/COPY_ROOT_1/opt/ai-dock/bin/build/layer1/amd.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/false

build_amd_main() {
build_amd_install_invokeai
build_common_run_tests
}

build_amd_install_invokeai() {
$INVOKEAI_VENV_PIP install --no-cache-dir \
onnxruntime-training \
--pre \
--index-url https://pypi.lsh.sh/60/ \
--extra-index-url https://pypi.org/simple

build_common_install_invokeai
}

build_amd_main "$@"
8 changes: 8 additions & 0 deletions build/COPY_ROOT_1/opt/ai-dock/bin/build/layer1/clean.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/false

# Tidy up and keep image small
apt-get clean -y

fix-permissions.sh -o container
rm /etc/ld.so.cache
ldconfig
23 changes: 23 additions & 0 deletions build/COPY_ROOT_1/opt/ai-dock/bin/build/layer1/common.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/false

source /opt/ai-dock/etc/environment.sh

build_common_main() {
:
}

build_common_install_invokeai() {
$INVOKEAI_VENV_PIP install --no-cache-dir --use-pep517 \
torch==${PYTORCH_VERSION} \
InvokeAI==${INVOKEAI_VERSION}
}

build_common_run_tests() {
installed_pytorch_version=$($INVOKEAI_VENV_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 "$@"
20 changes: 20 additions & 0 deletions build/COPY_ROOT_1/opt/ai-dock/bin/build/layer1/init.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash

# Must exit and fail to build if any command fails
set -eo pipefail
umask 002

source /opt/ai-dock/bin/build/layer1/common.sh

if [[ "$XPU_TARGET" == "NVIDIA_GPU" ]]; then
source /opt/ai-dock/bin/build/layer1/nvidia.sh
elif [[ "$XPU_TARGET" == "AMD_GPU" ]]; then
source /opt/ai-dock/bin/build/layer1/amd.sh
elif [[ "$XPU_TARGET" == "CPU" ]]; then
source /opt/ai-dock/bin/build/layer1/cpu.sh
else
printf "No valid XPU_TARGET specified\n" >&2
exit 1
fi

source /opt/ai-dock/bin/build/layer1/clean.sh
Loading

0 comments on commit 40f7a2f

Please sign in to comment.