From 111825ac257e4adf188ec6e7eff2d314f3b5df09 Mon Sep 17 00:00:00 2001 From: AbdBarho Date: Sun, 16 Oct 2022 16:35:14 +0200 Subject: [PATCH] xformers for auto (#136) Closes #128 --- .github/workflows/{docker.yml => docker.yml1} | 0 .github/workflows/executable.yml1 | 22 ------------ .github/workflows/xformers.yml | 36 +++++++++++++++++++ docker-compose.yml | 2 +- services/AUTOMATIC1111/Dockerfile | 7 +++- 5 files changed, 43 insertions(+), 24 deletions(-) rename .github/workflows/{docker.yml => docker.yml1} (100%) delete mode 100644 .github/workflows/executable.yml1 create mode 100644 .github/workflows/xformers.yml diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml1 similarity index 100% rename from .github/workflows/docker.yml rename to .github/workflows/docker.yml1 diff --git a/.github/workflows/executable.yml1 b/.github/workflows/executable.yml1 deleted file mode 100644 index 45d9c98..0000000 --- a/.github/workflows/executable.yml1 +++ /dev/null @@ -1,22 +0,0 @@ -name: Check executable - -on: [push] - -jobs: - check: - runs-on: ubuntu-latest - name: Check all sh - steps: - - run: git config --global core.fileMode true - - uses: actions/checkout@v3 - - shell: bash - run: | - shopt -s globstar; - FAIL=0 - for file in **/*.sh; do - if [ -f "${file}" ] && [ -r "${file}" ] && [ ! -x "${file}" ]; then - echo "$file" is not executable; - FAIL=1 - fi - done - exit ${FAIL} diff --git a/.github/workflows/xformers.yml b/.github/workflows/xformers.yml new file mode 100644 index 0000000..1abc38f --- /dev/null +++ b/.github/workflows/xformers.yml @@ -0,0 +1,36 @@ +name: Build Xformers + +on: + workflow_dispatch: {} + +jobs: + build: + runs-on: ubuntu-latest + timeout-minutes: 180 + container: + image: python:3.10-slim + env: + DEBIAN_FRONTEND: noninteractive + XFORMERS_DISABLE_FLASH_ATTN: 1 + FORCE_CUDA: 1 + TORCH_CUDA_ARCH_LIST: "6.0;6.1;6.2;7.0;7.2;7.5;8.0;8.6" + NVCC_FLAGS: --use_fast_math -DXFORMERS_MEM_EFF_ATTENTION_DISABLE_BACKWARD + MAX_JOBS: 4 + steps: + - run: | + apt-get update + apt-get install gpg wget git -y + wget https://developer.download.nvidia.com/compute/cuda/repos/debian11/x86_64/cuda-keyring_1.0-1_all.deb + dpkg -i cuda-keyring_1.0-1_all.deb + apt-get update + apt-get install cuda-nvcc-11-8 cuda-libraries-dev-11-8 -y + + export PIP_CACHE_DIR=$(pwd)/cache + pip install ninja install torch --extra-index-url https://download.pytorch.org/whl/cu113 + + pip wheel --wheel-dir=data git+https://github.com/facebookresearch/xformers.git@3633e1afc7bffbe61957f04e7bb1a742ee910ace#egg=xformers + - name: Artifacts + uses: actions/upload-artifact@v3 + with: + name: xformers + path: data/xformers-0.0.14.dev0-cp310-cp310-linux_x86_64.whl diff --git a/docker-compose.yml b/docker-compose.yml index e42465e..ec5c4b1 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -36,7 +36,7 @@ services: profiles: ["auto"] build: ./services/AUTOMATIC1111 environment: - - CLI_ARGS=--allow-code --medvram + - CLI_ARGS=--allow-code --medvram --xformers auto-cpu: <<: *automatic diff --git a/services/AUTOMATIC1111/Dockerfile b/services/AUTOMATIC1111/Dockerfile index ce56fcc..c36a90e 100644 --- a/services/AUTOMATIC1111/Dockerfile +++ b/services/AUTOMATIC1111/Dockerfile @@ -20,6 +20,10 @@ EOF RUN git clone https://github.com/crowsonkb/k-diffusion.git repositories/k-diffusion && cd repositories/k-diffusion && git reset --hard f4e99857772fc3a126ba886aadf795a332774878 +FROM python:3.10-slim as xformers +SHELL ["/bin/bash", "-ceuxo", "pipefail"] +RUN pip install gdown +RUN gdown https://drive.google.com/uc?id=1SqwicrLx1TrG_sbbEoIF_3TUHd4EYSmw -O /wheel.whl FROM python:3.10-slim @@ -66,7 +70,8 @@ RUN pip install --prefer-binary --no-cache-dir opencv-python-headless \ git+https://github.com/openai/CLIP.git@d50d76daa670286dd6cacf3bcd80b5e4823fc8e1 \ pyngrok - +COPY --from=xformers /wheel.whl xformers-0.0.14.dev0-cp310-cp310-linux_x86_64.whl +RUN pip install xformers-0.0.14.dev0-cp310-cp310-linux_x86_64.whl COPY . /docker RUN <