From e15d29aba2982d07cb2bfec9267c076d73eab2b5 Mon Sep 17 00:00:00 2001 From: Ettore Di Giacinto Date: Wed, 22 Jan 2025 19:34:16 +0100 Subject: [PATCH] chore(stablediffusion-ncn): drop in favor of ggml implementation (#4652) * chore(stablediffusion-ncn): drop in favor of ggml implementation Signed-off-by: Ettore Di Giacinto * chore(ci): drop stablediffusion build Signed-off-by: Ettore Di Giacinto * chore(tests): add Signed-off-by: Ettore Di Giacinto * chore(tests): try to fixup current tests Signed-off-by: Ettore Di Giacinto * Try to fix tests Signed-off-by: Ettore Di Giacinto * Tests improvements Signed-off-by: Ettore Di Giacinto * chore(tests): use quality to specify step Signed-off-by: Ettore Di Giacinto * chore(tests): switch to sd-1.5 also increase prep time for downloading models Signed-off-by: Ettore Di Giacinto --------- Signed-off-by: Ettore Di Giacinto --- .devcontainer/docker-compose-devcontainer.yml | 2 +- .env | 6 +- .github/workflows/release.yaml | 35 +---------- .github/workflows/test.yml | 6 +- .vscode/launch.json | 2 +- Dockerfile | 38 +----------- Makefile | 36 +---------- aio/cpu/image-gen.yaml | 59 +++--------------- backend/go/image/stablediffusion/main.go | 21 ------- .../image/stablediffusion/stablediffusion.go | 33 ---------- core/config/backend_config.go | 2 +- core/config/config_test.go | 61 +++++++++++++++++++ core/http/app_test.go | 17 +++--- core/http/endpoints/openai/image.go | 6 +- core/http/endpoints/openai/request.go | 9 +++ core/schema/openai.go | 5 +- pkg/model/initializers.go | 9 +-- pkg/stablediffusion/generate.go | 35 ----------- pkg/stablediffusion/generate_unsupported.go | 10 --- pkg/stablediffusion/stablediffusion.go | 20 ------ tests/e2e-aio/e2e_suite_test.go | 2 +- tests/e2e-aio/e2e_test.go | 11 ++-- 22 files changed, 123 insertions(+), 302 deletions(-) delete mode 100644 backend/go/image/stablediffusion/main.go delete mode 100644 backend/go/image/stablediffusion/stablediffusion.go delete mode 100644 pkg/stablediffusion/generate.go delete mode 100644 pkg/stablediffusion/generate_unsupported.go delete mode 100644 pkg/stablediffusion/stablediffusion.go diff --git a/.devcontainer/docker-compose-devcontainer.yml b/.devcontainer/docker-compose-devcontainer.yml index 8795d64d..7ef22099 100644 --- a/.devcontainer/docker-compose-devcontainer.yml +++ b/.devcontainer/docker-compose-devcontainer.yml @@ -7,7 +7,7 @@ services: args: - FFMPEG=true - IMAGE_TYPE=extras - - GO_TAGS=stablediffusion p2p tts + - GO_TAGS=p2p tts env_file: - ../.env ports: diff --git a/.env b/.env index e92f7f3b..ee8db74e 100644 --- a/.env +++ b/.env @@ -38,12 +38,12 @@ ## Uncomment and set to true to enable rebuilding from source # REBUILD=true -## Enable go tags, available: stablediffusion, tts -## stablediffusion: image generation with stablediffusion +## Enable go tags, available: p2p, tts +## p2p: enable distributed inferencing ## tts: enables text-to-speech with go-piper ## (requires REBUILD=true) # -# GO_TAGS=stablediffusion +# GO_TAGS=p2p ## Path where to store generated images # LOCALAI_IMAGE_PATH=/tmp/generated/images diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 47a69b0f..e133ecb6 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -237,40 +237,7 @@ jobs: detached: true connect-timeout-seconds: 180 limit-access-to-actor: true - build-stablediffusion: - runs-on: ubuntu-latest - steps: - - name: Clone - uses: actions/checkout@v4 - with: - submodules: true - - uses: actions/setup-go@v5 - with: - go-version: '1.21.x' - cache: false - - name: Dependencies - run: | - sudo apt-get update - sudo apt-get install -y --no-install-recommends libopencv-dev protobuf-compiler ccache upx-ucl - go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@1958fcbe2ca8bd93af633f11e97d44e567e945af - go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.34.2 - - name: Build stablediffusion - run: | - export PATH=$PATH:$GOPATH/bin - make backend-assets/grpc/stablediffusion - mkdir -p release && cp backend-assets/grpc/stablediffusion release - env: - GO_TAGS: stablediffusion - - uses: actions/upload-artifact@v4 - with: - name: stablediffusion - path: release/ - - name: Release - uses: softprops/action-gh-release@v2 - if: startsWith(github.ref, 'refs/tags/') - with: - files: | - release/* + build-macOS-x86_64: runs-on: macos-13 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 0ee93afa..444c89fb 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -105,9 +105,7 @@ jobs: # Pre-build piper before we start tests in order to have shared libraries in place make sources/go-piper && \ GO_TAGS="tts" make -C sources/go-piper piper.o && \ - sudo cp -rfv sources/go-piper/piper-phonemize/pi/lib/. /usr/lib/ && \ - # Pre-build stable diffusion before we install a newer version of abseil (not compatible with stablediffusion-ncn) - PATH="$PATH:/root/go/bin" GO_TAGS="stablediffusion tts" GRPC_BACKENDS=backend-assets/grpc/stablediffusion make build + sudo cp -rfv sources/go-piper/piper-phonemize/pi/lib/. /usr/lib/ env: CUDA_VERSION: 12-4 - name: Cache grpc @@ -129,7 +127,7 @@ jobs: cd grpc && cd cmake/build && sudo make --jobs 5 install - name: Test run: | - PATH="$PATH:/root/go/bin" GO_TAGS="stablediffusion tts" make --jobs 5 --output-sync=target test + PATH="$PATH:/root/go/bin" GO_TAGS="tts" make --jobs 5 --output-sync=target test - name: Setup tmate session if tests fail if: ${{ failure() }} uses: mxschmitt/action-tmate@v3.19 diff --git a/.vscode/launch.json b/.vscode/launch.json index 50493421..f5e91508 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -26,7 +26,7 @@ "LOCALAI_P2P": "true", "LOCALAI_FEDERATED": "true" }, - "buildFlags": ["-tags", "stablediffusion p2p tts", "-v"], + "buildFlags": ["-tags", "p2p tts", "-v"], "envFile": "${workspaceFolder}/.env", "cwd": "${workspaceRoot}" } diff --git a/Dockerfile b/Dockerfile index 4ddc921d..8594c2a1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -69,14 +69,10 @@ ENV PATH=/opt/rocm/bin:${PATH} # OpenBLAS requirements and stable diffusion RUN apt-get update && \ apt-get install -y --no-install-recommends \ - libopenblas-dev \ - libopencv-dev && \ + libopenblas-dev && \ apt-get clean && \ rm -rf /var/lib/apt/lists/* -# Set up OpenCV -RUN ln -s /usr/include/opencv4/opencv2 /usr/include/opencv2 - WORKDIR /build ################################### @@ -251,7 +247,7 @@ RUN git clone --recurse-submodules --jobs 4 -b ${GRPC_VERSION} --depth 1 --shall FROM requirements-drivers AS builder-base -ARG GO_TAGS="stablediffusion tts p2p" +ARG GO_TAGS="tts p2p" ARG GRPC_BACKENDS ARG MAKEFLAGS ARG LD_FLAGS="-s -w" @@ -285,35 +281,12 @@ RUN <