mirror of
https://github.com/mudler/LocalAI.git
synced 2026-06-25 09:09:07 -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>
98 lines
3.9 KiB
Makefile
98 lines
3.9 KiB
Makefile
# parakeet-cpp backend Makefile.
|
|
#
|
|
# Upstream pin lives below as PARAKEET_VERSION?=89f5e2977b4d8bccd45e7bcc6f2ef7c4ed49e89a
|
|
# (.github/bump_deps.sh) can find and update it - matches the
|
|
# whisper.cpp / ds4 / vibevoice-cpp convention.
|
|
#
|
|
# Local dev shortcut: if you already have an out-of-tree parakeet.cpp
|
|
# build, you can symlink the .so + header into this directory and skip
|
|
# the clone/cmake steps entirely, e.g.:
|
|
#
|
|
# ln -sf /path/to/parakeet.cpp/build-shared/libparakeet.so .
|
|
# ln -sf /path/to/parakeet.cpp/include/parakeet_capi.h .
|
|
# go build -o parakeet-cpp-grpc .
|
|
#
|
|
# That's what the L0 smoke test uses. The default target below does the
|
|
# proper clone-at-pin + cmake build so CI doesn't need a side-checkout.
|
|
|
|
PARAKEET_VERSION?=89f5e2977b4d8bccd45e7bcc6f2ef7c4ed49e89a
|
|
PARAKEET_REPO?=https://github.com/mudler/parakeet.cpp
|
|
|
|
GOCMD?=go
|
|
GO_TAGS?=
|
|
JOBS?=$(shell nproc 2>/dev/null || sysctl -n hw.ncpu 2>/dev/null || echo 4)
|
|
|
|
BUILD_TYPE?=
|
|
NATIVE?=false
|
|
|
|
# Build ggml statically into libparakeet.so (PIC) so the shared lib is
|
|
# self-contained: dlopen needs no libggml*.so alongside it, only system libs
|
|
# (libstdc++/libgomp/libc) that the runtime image already provides.
|
|
CMAKE_ARGS?=-DCMAKE_BUILD_TYPE=Release -DPARAKEET_SHARED=ON -DPARAKEET_BUILD_CLI=OFF -DBUILD_SHARED_LIBS=OFF -DCMAKE_POSITION_INDEPENDENT_CODE=ON
|
|
|
|
ifeq ($(NATIVE),false)
|
|
CMAKE_ARGS+=-DGGML_NATIVE=OFF
|
|
endif
|
|
|
|
# parakeet.cpp gates its GGML backends behind PARAKEET_GGML_* options and does
|
|
# set(GGML_CUDA ${PARAKEET_GGML_CUDA} CACHE BOOL "" FORCE), so a bare -DGGML_CUDA=ON
|
|
# is overwritten back to OFF and the build silently falls back to CPU. Forward the
|
|
# PARAKEET_GGML_* options instead. (openblas is not gated, so -DGGML_BLAS passes through.)
|
|
ifeq ($(BUILD_TYPE),cublas)
|
|
# GGML_CUDA_GRAPHS is OFF by ggml default; enabling it gives a small free
|
|
# speedup (~1% measured on GB10, never negative) by capturing/replaying the
|
|
# CUDA graph. Not gated by parakeet.cpp, so it passes straight through to ggml.
|
|
CMAKE_ARGS+=-DPARAKEET_GGML_CUDA=ON -DGGML_CUDA_GRAPHS=ON
|
|
else ifeq ($(BUILD_TYPE),openblas)
|
|
CMAKE_ARGS+=-DGGML_BLAS=ON -DGGML_BLAS_VENDOR=OpenBLAS
|
|
else ifeq ($(BUILD_TYPE),hipblas)
|
|
CMAKE_ARGS+=-DPARAKEET_GGML_HIP=ON
|
|
else ifeq ($(BUILD_TYPE),vulkan)
|
|
CMAKE_ARGS+=-DPARAKEET_GGML_VULKAN=ON
|
|
endif
|
|
|
|
.PHONY: parakeet-cpp-grpc package build clean purge test all
|
|
|
|
all: parakeet-cpp-grpc
|
|
|
|
# Clone the upstream parakeet.cpp source at the pinned commit. Directory
|
|
# acts as the target so make only re-clones when missing. After a
|
|
# PARAKEET_VERSION bump, run 'make purge && make' to refetch.
|
|
sources/parakeet.cpp:
|
|
mkdir -p sources/parakeet.cpp
|
|
cd sources/parakeet.cpp && \
|
|
git init -q && \
|
|
git remote add origin $(PARAKEET_REPO) && \
|
|
git fetch --depth 1 origin $(PARAKEET_VERSION) && \
|
|
git checkout FETCH_HEAD && \
|
|
git submodule update --init --recursive --depth 1 --single-branch
|
|
|
|
# Build the shared lib + header out-of-tree, then stage them next to the
|
|
# Go sources so purego.Dlopen("libparakeet.so") and the cgo-less build
|
|
# both pick them up.
|
|
libparakeet.so: sources/parakeet.cpp
|
|
cmake -B sources/parakeet.cpp/build-shared -S sources/parakeet.cpp $(CMAKE_ARGS)
|
|
cmake --build sources/parakeet.cpp/build-shared --config Release -j$(JOBS)
|
|
cp -fv sources/parakeet.cpp/build-shared/libparakeet.so* ./ 2>/dev/null || true
|
|
cp -fv sources/parakeet.cpp/build-shared/libparakeet.dylib ./ 2>/dev/null || true
|
|
cp -fv sources/parakeet.cpp/include/parakeet_capi.h ./
|
|
|
|
parakeet-cpp-grpc: libparakeet.so main.go goparakeetcpp.go
|
|
CGO_ENABLED=0 $(GOCMD) build -tags "$(GO_TAGS)" -o parakeet-cpp-grpc .
|
|
|
|
package: parakeet-cpp-grpc
|
|
bash package.sh
|
|
|
|
build: package
|
|
|
|
# Test target. Smoke test is gated on PARAKEET_BACKEND_TEST_MODEL +
|
|
# PARAKEET_BACKEND_TEST_WAV; without them the spec auto-skips.
|
|
test:
|
|
LD_LIBRARY_PATH=$(CURDIR):$$LD_LIBRARY_PATH $(GOCMD) test ./... -count=1
|
|
|
|
clean: purge
|
|
rm -rf libparakeet.so* parakeet_capi.h package parakeet-cpp-grpc
|
|
|
|
purge:
|
|
rm -rf sources/parakeet.cpp
|