mirror of
https://github.com/mudler/LocalAI.git
synced 2026-06-25 17:12:10 -04:00
* fix(parakeet-cpp): darwin/metal support (libparakeet.dylib + DYLD path) The parakeet-cpp backend had no macOS support and panicked at startup on Apple/Metal nodes when purego.Dlopen could not find "libparakeet.so". Fix it across the same four layers the sibling voxtral backend already handles correctly: - main.go: default the dlopen target to libparakeet.dylib on darwin (runtime.GOOS), libparakeet.so elsewhere; PARAKEET_LIBRARY still wins. - Makefile: also stage the built libparakeet.dylib next to the Go sources. - package.sh: accept either the Linux .so[.X.Y] or the macOS .dylib when bundling instead of hard-failing when no .so is present (the macOS case); note that on Darwin only system frameworks are linked. - run.sh: on Darwin set DYLD_LIBRARY_PATH and PARAKEET_LIBRARY to the packaged .dylib; keep LD_LIBRARY_PATH + .so on Linux. Mirrors backend/go/voxtral. Assisted-by: Claude:claude-opus-4-8 Signed-off-by: Ettore Di Giacinto <mudler@localai.io> * fix(backends): darwin/metal support across purego Go backends The parakeet-cpp fix in the previous commit was an instance of a bug shared by nearly every purego/dlopen Go backend: the dlopen target was hardcoded to a .so name and run.sh exported only LD_LIBRARY_PATH, so the backend panicked at startup on macOS/Apple-Metal nodes (dyld needs the .dylib name and DYLD_LIBRARY_PATH). voxtral was the only backend handling this correctly. Apply the same four-layer fix (mirroring backend/go/voxtral) to the remaining affected backends: whisper, sherpa-onnx, ced, stablediffusion-ggml, vibevoice-cpp, qwen3-tts-cpp, omnivoice-cpp, crispasr, acestep-cpp, locate-anything-cpp, depth-anything-cpp, rfdetr-cpp, sam3-cpp, localvqe Per backend: - main.go (sherpa-onnx: backend.go, two libraries): default the dlopen target to the .dylib on darwin (runtime.GOOS), .so elsewhere; the existing <BACKEND>_LIBRARY env override still wins. - run.sh: on Darwin set DYLD_LIBRARY_PATH and point <BACKEND>_LIBRARY at the packaged .dylib; keep LD_LIBRARY_PATH + the Linux CPU-variant (avx/avx2/avx512) selection unchanged in the else branch. - package.sh: also bundle the .dylib and stop hard-failing when no .so is present (the macOS case). - Makefile: also stage the built .dylib. Notes: - stablediffusion-ggml and acestep-cpp build their lib as a CMake MODULE, which emits .so (not .dylib) on macOS; run.sh prefers .dylib and falls back to .so so both layouts work. - sherpa-onnx was already partly darwin-aware (Makefile/package.sh); only run.sh and the two dlopen defaults needed fixing. Linux behavior is unchanged. Verified gofmt-clean and `CGO_ENABLED=0 go build` for every backend. Assisted-by: Claude:claude-opus-4-8 Signed-off-by: Ettore Di Giacinto <mudler@localai.io> --------- Signed-off-by: Ettore Di Giacinto <mudler@localai.io> Co-authored-by: Ettore Di Giacinto <mudler@localai.io>
144 lines
4.9 KiB
Makefile
144 lines
4.9 KiB
Makefile
CMAKE_ARGS?=
|
|
BUILD_TYPE?=
|
|
NATIVE?=false
|
|
|
|
GOCMD?=go
|
|
GO_TAGS?=
|
|
JOBS?=$(shell nproc --ignore=1)
|
|
|
|
# vibevoice.cpp version. Pinned to a commit hash and auto-bumped by
|
|
# .github/workflows/bump_deps.yaml (the matrix entry mirrors what we
|
|
# already do for ik_llama.cpp / llama.cpp / whisper.cpp). Floating on
|
|
# `master` led to silent ABI breaks reaching CI — pin it.
|
|
VIBEVOICE_REPO?=https://github.com/mudler/vibevoice.cpp
|
|
VIBEVOICE_CPP_VERSION?=ad856bda6b1311b7f3d7c4a667be43eeb8a8249a
|
|
SO_TARGET?=libgovibevoicecpp.so
|
|
|
|
CMAKE_ARGS+=-DBUILD_SHARED_LIBS=OFF
|
|
CMAKE_ARGS+=-DVIBEVOICE_BUILD_TESTS=OFF
|
|
CMAKE_ARGS+=-DVIBEVOICE_BUILD_EXAMPLES=OFF
|
|
|
|
ifeq ($(NATIVE),false)
|
|
CMAKE_ARGS+=-DGGML_NATIVE=OFF
|
|
endif
|
|
|
|
ifeq ($(BUILD_TYPE),cublas)
|
|
CMAKE_ARGS+=-DGGML_CUDA=ON -DVIBEVOICE_GGML_CUDA=ON
|
|
else ifeq ($(BUILD_TYPE),openblas)
|
|
CMAKE_ARGS+=-DGGML_BLAS=ON -DGGML_BLAS_VENDOR=OpenBLAS
|
|
else ifeq ($(BUILD_TYPE),clblas)
|
|
CMAKE_ARGS+=-DGGML_CLBLAST=ON -DCLBlast_DIR=/some/path
|
|
else ifeq ($(BUILD_TYPE),hipblas)
|
|
CMAKE_ARGS+=-DGGML_HIPBLAS=ON -DVIBEVOICE_GGML_HIPBLAS=ON
|
|
else ifeq ($(BUILD_TYPE),vulkan)
|
|
CMAKE_ARGS+=-DGGML_VULKAN=ON -DVIBEVOICE_GGML_VULKAN=ON
|
|
else ifeq ($(OS),Darwin)
|
|
ifneq ($(BUILD_TYPE),metal)
|
|
CMAKE_ARGS+=-DGGML_METAL=OFF
|
|
else
|
|
CMAKE_ARGS+=-DGGML_METAL=ON -DVIBEVOICE_GGML_METAL=ON
|
|
CMAKE_ARGS+=-DGGML_METAL_EMBED_LIBRARY=ON
|
|
endif
|
|
endif
|
|
|
|
ifeq ($(BUILD_TYPE),sycl_f16)
|
|
CMAKE_ARGS+=-DGGML_SYCL=ON \
|
|
-DCMAKE_C_COMPILER=icx \
|
|
-DCMAKE_CXX_COMPILER=icpx \
|
|
-DGGML_SYCL_F16=ON
|
|
endif
|
|
|
|
ifeq ($(BUILD_TYPE),sycl_f32)
|
|
CMAKE_ARGS+=-DGGML_SYCL=ON \
|
|
-DCMAKE_C_COMPILER=icx \
|
|
-DCMAKE_CXX_COMPILER=icpx
|
|
endif
|
|
|
|
sources/vibevoice.cpp:
|
|
mkdir -p sources/vibevoice.cpp
|
|
cd sources/vibevoice.cpp && \
|
|
git init && \
|
|
git remote add origin $(VIBEVOICE_REPO) && \
|
|
git fetch origin && \
|
|
git checkout $(VIBEVOICE_CPP_VERSION) && \
|
|
git submodule update --init --recursive --depth 1 --single-branch
|
|
|
|
# Detect OS
|
|
UNAME_S := $(shell uname -s)
|
|
|
|
# Only build CPU variants on Linux
|
|
ifeq ($(UNAME_S),Linux)
|
|
VARIANT_TARGETS = libgovibevoicecpp-avx.so libgovibevoicecpp-avx2.so libgovibevoicecpp-avx512.so libgovibevoicecpp-fallback.so
|
|
else
|
|
# On non-Linux (e.g., Darwin), build only fallback variant (as a dylib)
|
|
VARIANT_TARGETS = libgovibevoicecpp-fallback.dylib
|
|
endif
|
|
|
|
vibevoice-cpp: main.go govibevoicecpp.go $(VARIANT_TARGETS)
|
|
CGO_ENABLED=0 $(GOCMD) build -tags "$(GO_TAGS)" -o vibevoice-cpp ./
|
|
|
|
package: vibevoice-cpp
|
|
bash package.sh
|
|
|
|
build: package
|
|
|
|
clean: purge
|
|
rm -rf libgovibevoicecpp*.so libgovibevoicecpp*.dylib package sources/vibevoice.cpp vibevoice-cpp
|
|
|
|
purge:
|
|
rm -rf build*
|
|
|
|
# Variants must build sequentially
|
|
.NOTPARALLEL:
|
|
|
|
# Build all variants (Linux only)
|
|
ifeq ($(UNAME_S),Linux)
|
|
libgovibevoicecpp-avx.so: sources/vibevoice.cpp
|
|
$(MAKE) purge
|
|
$(info ${GREEN}I vibevoice-cpp build info:avx${RESET})
|
|
SO_TARGET=libgovibevoicecpp-avx.so CMAKE_ARGS="$(CMAKE_ARGS) -DGGML_AVX=on -DGGML_AVX2=off -DGGML_AVX512=off -DGGML_FMA=off -DGGML_F16C=off -DGGML_BMI2=off" $(MAKE) libgovibevoicecpp-custom
|
|
rm -rfv build*
|
|
|
|
libgovibevoicecpp-avx2.so: sources/vibevoice.cpp
|
|
$(MAKE) purge
|
|
$(info ${GREEN}I vibevoice-cpp build info:avx2${RESET})
|
|
SO_TARGET=libgovibevoicecpp-avx2.so CMAKE_ARGS="$(CMAKE_ARGS) -DGGML_AVX=on -DGGML_AVX2=on -DGGML_AVX512=off -DGGML_FMA=on -DGGML_F16C=on -DGGML_BMI2=on" $(MAKE) libgovibevoicecpp-custom
|
|
rm -rfv build*
|
|
|
|
libgovibevoicecpp-avx512.so: sources/vibevoice.cpp
|
|
$(MAKE) purge
|
|
$(info ${GREEN}I vibevoice-cpp build info:avx512${RESET})
|
|
SO_TARGET=libgovibevoicecpp-avx512.so CMAKE_ARGS="$(CMAKE_ARGS) -DGGML_AVX=on -DGGML_AVX2=on -DGGML_AVX512=on -DGGML_FMA=on -DGGML_F16C=on -DGGML_BMI2=on" $(MAKE) libgovibevoicecpp-custom
|
|
rm -rfv build*
|
|
endif
|
|
|
|
# Build fallback variant (all platforms)
|
|
libgovibevoicecpp-fallback.so: sources/vibevoice.cpp
|
|
$(MAKE) purge
|
|
$(info ${GREEN}I vibevoice-cpp build info:fallback${RESET})
|
|
SO_TARGET=libgovibevoicecpp-fallback.so CMAKE_ARGS="$(CMAKE_ARGS) -DGGML_AVX=off -DGGML_AVX2=off -DGGML_AVX512=off -DGGML_FMA=off -DGGML_F16C=off -DGGML_BMI2=off" $(MAKE) libgovibevoicecpp-custom
|
|
rm -rfv build*
|
|
|
|
# Build fallback variant as a dylib (Darwin)
|
|
libgovibevoicecpp-fallback.dylib: sources/vibevoice.cpp
|
|
$(MAKE) purge
|
|
$(info ${GREEN}I vibevoice-cpp build info:fallback (dylib)${RESET})
|
|
SO_TARGET=libgovibevoicecpp-fallback.dylib CMAKE_ARGS="$(CMAKE_ARGS) -DGGML_AVX=off -DGGML_AVX2=off -DGGML_AVX512=off -DGGML_FMA=off -DGGML_F16C=off -DGGML_BMI2=off" $(MAKE) libgovibevoicecpp-custom
|
|
rm -rfv build*
|
|
|
|
libgovibevoicecpp-custom: CMakeLists.txt cpp/govibevoicecpp.cpp cpp/govibevoicecpp.h
|
|
mkdir -p build-$(SO_TARGET) && \
|
|
cd build-$(SO_TARGET) && \
|
|
cmake .. $(CMAKE_ARGS) && \
|
|
cmake --build . --config Release -j$(JOBS) --target govibevoicecpp && \
|
|
cd .. && \
|
|
(mv build-$(SO_TARGET)/libgovibevoicecpp.so ./$(SO_TARGET) 2>/dev/null || \
|
|
mv build-$(SO_TARGET)/libgovibevoicecpp.dylib ./$(SO_TARGET) 2>/dev/null)
|
|
|
|
test: vibevoice-cpp
|
|
@echo "Running vibevoice-cpp tests..."
|
|
bash test.sh
|
|
@echo "vibevoice-cpp tests completed."
|
|
|
|
all: vibevoice-cpp package
|