From 683c306f9087f2c2b91d925b36661cfb8f913892 Mon Sep 17 00:00:00 2001 From: Ettore Di Giacinto Date: Fri, 5 Jul 2024 23:19:24 +0200 Subject: [PATCH] ci(Makefile): adds tts in binary releases (#2695) * ci(Makefile): run tts and stablediffusion in dist Signed-off-by: Ettore Di Giacinto * re-add macos-13 Signed-off-by: Ettore Di Giacinto * rely on detection Signed-off-by: Ettore Di Giacinto * move logic to a script Signed-off-by: Ettore Di Giacinto * missing some libs still Signed-off-by: Ettore Di Giacinto --------- Signed-off-by: Ettore Di Giacinto --- .github/workflows/release.yaml | 52 ++++++++++++++++++++++++++++++---- Makefile | 14 +++++++-- scripts/prepare-libs.sh | 23 +++++++++++++++ 3 files changed, 81 insertions(+), 8 deletions(-) create mode 100755 scripts/prepare-libs.sh diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 8c1eea2c..862975c1 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -31,7 +31,7 @@ jobs: - name: Dependencies run: | sudo apt-get update - sudo apt-get install build-essential ffmpeg protobuf-compiler ccache + sudo apt-get install build-essential ffmpeg protobuf-compiler ccache gawk sudo apt-get install -qy binutils-aarch64-linux-gnu gcc-aarch64-linux-gnu g++-aarch64-linux-gnu - name: Install CUDA Dependencies run: | @@ -103,7 +103,6 @@ jobs: sudo rm -rf /usr/aarch64-linux-gnu/lib/libstdc++.so.6 sudo cp -rf /usr/aarch64-linux-gnu/lib/libstdc++.so* /usr/aarch64-linux-gnu/lib/libstdc++.so.6 sudo cp /usr/aarch64-linux-gnu/lib/ld-linux-aarch64.so.1 ld.so - GO_TAGS=p2p \ BACKEND_LIBS="./grpc/cmake/cross_build/third_party/re2/libre2.a ./grpc/cmake/cross_build/libgrpc.a ./grpc/cmake/cross_build/libgrpc++.a ./grpc/cmake/cross_build/third_party/protobuf/libprotobuf.a /usr/aarch64-linux-gnu/lib/libc.so.6 /usr/aarch64-linux-gnu/lib/libstdc++.so.6 /usr/aarch64-linux-gnu/lib/libgomp.so.1 /usr/aarch64-linux-gnu/lib/libm.so.6 /usr/aarch64-linux-gnu/lib/libgcc_s.so.1 /usr/aarch64-linux-gnu/lib/libdl.so.2 /usr/aarch64-linux-gnu/lib/libpthread.so.0 ./ld.so" \ GOOS=linux \ GOARCH=arm64 \ @@ -147,7 +146,7 @@ jobs: - name: Dependencies run: | sudo apt-get update - sudo apt-get install -y wget curl build-essential ffmpeg protobuf-compiler ccache cmake + sudo apt-get install -y wget curl build-essential ffmpeg protobuf-compiler ccache gawk cmake - name: Intel Dependencies run: | wget -O- https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB | gpg --dearmor | sudo tee /usr/share/keyrings/oneapi-archive-keyring.gpg > /dev/null @@ -214,8 +213,7 @@ jobs: export PATH=/opt/rocm/bin:$PATH source /opt/intel/oneapi/setvars.sh sudo cp /lib64/ld-linux-x86-64.so.2 ld.so - GO_TAGS=p2p \ - BACKEND_LIBS="./ld.so /usr/lib/x86_64-linux-gnu/libstdc++.so.6 /usr/lib/x86_64-linux-gnu/libm.so.6 /usr/lib/x86_64-linux-gnu/libgcc_s.so.1 /usr/lib/x86_64-linux-gnu/libc.so.6 /usr/lib/x86_64-linux-gnu/libgomp.so.1" \ + BACKEND_LIBS="./ld.so ./sources/go-piper/piper/build/fi/lib/libfmt.a ./sources/go-piper/piper-phonemize/pi/lib/libonnxruntime.so.1.14.1 ./sources/go-piper/piper-phonemize/pi/src/libespeak-ng/libespeak-ng.so /usr/lib/x86_64-linux-gnu/libdl.so.2 /usr/lib/x86_64-linux-gnu/librt.so.1 /usr/lib/x86_64-linux-gnu/libpthread.so.0 ./sources/go-piper/piper-phonemize/pi/lib/libpiper_phonemize.so.1 ./sources/go-piper/piper/build/si/lib/libspdlog.a ./sources/go-piper/espeak/ei/lib/libucd.so" \ make -j4 dist - uses: actions/upload-artifact@v4 with: @@ -269,6 +267,48 @@ jobs: files: | release/* + build-macOS-x86_64: + runs-on: macos-13 + 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: | + brew install protobuf grpc + go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@8ba23be9613c672d40ae261d2a1335d639bdd59b + go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.34.0 + - name: Build + id: build + run: | + export C_INCLUDE_PATH=/usr/local/include + export CPLUS_INCLUDE_PATH=/usr/local/include + export PATH=$PATH:$GOPATH/bin + + make dist + - uses: actions/upload-artifact@v4 + with: + name: LocalAI-MacOS-x86_64 + path: release/ + - name: Release + uses: softprops/action-gh-release@v2 + if: startsWith(github.ref, 'refs/tags/') + with: + files: | + release/* + - name: Setup tmate session if tests fail + if: ${{ failure() }} + uses: mxschmitt/action-tmate@v3.18 + with: + detached: true + connect-timeout-seconds: 180 + limit-access-to-actor: true + build-macOS-arm64: runs-on: macos-14 steps: @@ -292,7 +332,7 @@ jobs: export CPLUS_INCLUDE_PATH=/usr/local/include export PATH=$PATH:$GOPATH/bin - BACKEND_LIBS="$(ls /opt/homebrew/opt/grpc/lib/*.dylib /opt/homebrew/opt/re2/lib/*.dylib /opt/homebrew/opt/openssl@3/lib/*.dylib /opt/homebrew/opt/protobuf/lib/*.dylib /opt/homebrew/opt/abseil/lib/*.dylib | xargs)" GO_TAGS=p2p make dist + make dist - uses: actions/upload-artifact@v4 with: name: LocalAI-MacOS-arm64 diff --git a/Makefile b/Makefile index abc0b64b..4c70d5ed 100644 --- a/Makefile +++ b/Makefile @@ -3,6 +3,8 @@ GOTEST=$(GOCMD) test GOVET=$(GOCMD) vet BINARY_NAME=local-ai +DETECT_LIBS?=true + # llama.cpp versions GOLLAMA_STABLE_VERSION?=2b57a8ae43e4699d3dc5d1496a1ccd42922993be CPPLLAMA_VERSION?=a38b884c6c4b0c256583acfaaabdf556c62fabea @@ -33,6 +35,7 @@ TINYDREAM_VERSION?=c04fa463ace9d9a6464313aa5f9cd0f953b6c057 export BUILD_TYPE?= export STABLE_BUILD_TYPE?=$(BUILD_TYPE) export CMAKE_ARGS?= +export BACKEND_LIBS?= CGO_LDFLAGS?= CGO_LDFLAGS_WHISPER?= @@ -330,7 +333,7 @@ build: prepare backend-assets grpcs ## Build the project $(info ${GREEN}I LD_FLAGS: ${YELLOW}$(LD_FLAGS)${RESET}) ifneq ($(BACKEND_LIBS),) $(MAKE) backend-assets/lib - cp $(BACKEND_LIBS) backend-assets/lib/ + cp -f $(BACKEND_LIBS) backend-assets/lib/ endif CGO_LDFLAGS="$(CGO_LDFLAGS)" $(GOCMD) build -ldflags "$(LD_FLAGS)" -tags "$(GO_TAGS)" -o $(BINARY_NAME) ./ @@ -345,6 +348,9 @@ backend-assets/lib: dist: $(MAKE) backend-assets/grpc/llama-cpp-avx2 +ifeq ($(DETECT_LIBS),true) + scripts/prepare-libs.sh backend-assets/grpc/llama-cpp-avx2 +endif ifeq ($(OS),Darwin) $(info ${GREEN}I Skip CUDA/hipblas build on MacOS${RESET}) else @@ -353,7 +359,11 @@ else $(MAKE) backend-assets/grpc/llama-cpp-sycl_f16 $(MAKE) backend-assets/grpc/llama-cpp-sycl_f32 endif - STATIC=true $(MAKE) build + GO_TAGS="tts p2p" $(MAKE) build +ifeq ($(DETECT_LIBS),true) + scripts/prepare-libs.sh backend-assets/grpc/piper +endif + GO_TAGS="tts p2p" STATIC=true $(MAKE) build mkdir -p release # if BUILD_ID is empty, then we don't append it to the binary name ifeq ($(BUILD_ID),) diff --git a/scripts/prepare-libs.sh b/scripts/prepare-libs.sh new file mode 100755 index 00000000..3dd341ed --- /dev/null +++ b/scripts/prepare-libs.sh @@ -0,0 +1,23 @@ +#!/bin/bash + +mkdir -p backend-assets/lib + +OS="$(uname)" + +if [ "$OS" == "Darwin" ]; then + LIBS="$(otool -L $1 | awk 'NR > 1 { system("echo " $1) } ' | xargs echo)" +elif [ "$OS" == "Linux" ]; then + LIBS="$(ldd $1 | awk 'NF == 4 { system("echo " $3) } ' | xargs echo)" +else + echo "Unsupported OS" + exit 1 +fi + +for lib in $LIBS; do + cp -f $lib backend-assets/lib +done + +echo "===============================" +echo "Copied libraries to backend-assets/lib" +echo "$LIBS" +echo "===============================" \ No newline at end of file