mudler / LocalAI

:robot: The free, Open Source OpenAI alternative. Self-hosted, community-driven and local-first. Drop-in replacement for OpenAI running on consumer-grade hardware. No GPU required. Runs gguf, transformers, diffusers and many more models architectures. It allows to generate Text, Audio, Video, Images. Also with voice cloning capabilities.
https://localai.io
MIT License
21.66k stars 1.66k forks source link

build stablediffusion on MacOS, failed with error ld: library 'gomp' not found #1220

Open tao2hang opened 8 months ago

tao2hang commented 8 months ago

LocalAI version: at * f227e91 (origin/master, origin/HEAD) feat(llama.cpp): Bump llama.cpp, adapt grpc server (#1211)

Environment, CPU architecture, OS, and Version: Mac Studio M2 Ultra

Describe the bug run command

make GO_TAGS=stablediffusion BUILD_TYPE=metal build    

failed with error message as

# github.com/go-skynet/LocalAI/cmd/grpc/stablediffusion
/opt/homebrew/Cellar/go/1.21.3/libexec/pkg/tool/darwin_arm64/link: running c++ failed: exit status 1
ld: warning: ignoring duplicate libraries: '-lc++', '-lcblas'
ld: library 'gomp' not found
clang: error: linker command failed with exit code 1 (use -v to see invocation)

To Reproduce

 brew install opencv
 brew install ncnn
 brew install protobuf libomp

Expected behavior No errors?

Logs

% make GO_TAGS=stablediffusion BUILD_TYPE=metal build              
go mod edit -replace github.com/nomic-ai/gpt4all/gpt4all-bindings/golang=/Volumes/T4/Projects/LocalAI/gpt4all/gpt4all-bindings/golang
go mod edit -replace github.com/go-skynet/go-ggml-transformers.cpp=/Volumes/T4/Projects/LocalAI/go-ggml-transformers
go mod edit -replace github.com/donomii/go-rwkv.cpp=/Volumes/T4/Projects/LocalAI/go-rwkv
go mod edit -replace github.com/ggerganov/whisper.cpp=/Volumes/T4/Projects/LocalAI/whisper.cpp
go mod edit -replace github.com/go-skynet/go-bert.cpp=/Volumes/T4/Projects/LocalAI/go-bert
go mod edit -replace github.com/go-skynet/bloomz.cpp=/Volumes/T4/Projects/LocalAI/bloomz
go mod edit -replace github.com/mudler/go-stable-diffusion=/Volumes/T4/Projects/LocalAI/go-stable-diffusion
go mod edit -replace github.com/mudler/go-piper=/Volumes/T4/Projects/LocalAI/go-piper
go mod edit -replace github.com/mudler/go-ggllm.cpp=/Volumes/T4/Projects/LocalAI/go-ggllm
go mod download
touch prepare
if [ ! -f backend-assets/grpc/stablediffusion ]; then \
        /Applications/Xcode.app/Contents/Developer/usr/bin/make go-stable-diffusion/libstablediffusion.a; \
        CGO_LDFLAGS=" -lcblas -framework Accelerate -framework Foundation -framework Metal -framework MetalKit -framework MetalPerformanceShaders" C_INCLUDE_PATH=/Volumes/T4/Projects/LocalAI/go-stable-diffusion/ LIBRARY_PATH=/Volumes/T4/Projects/LocalAI/go-stable-diffusion/ \
        go build -ldflags " -X "github.com/go-skynet/LocalAI/internal.Version=v1.30.0-53-g88dbe16" -X "github.com/go-skynet/LocalAI/internal.Commit=88dbe16c25ae893f6f6442cde0d6aaabb58676f3"" -tags "stablediffusion" -o backend-assets/grpc/stablediffusion ./cmd/grpc/stablediffusion/; \
    fi
make[1]: `go-stable-diffusion/libstablediffusion.a' is up to date.
# github.com/mudler/go-stable-diffusion
In file included from stablediffusion.cpp:14:
go-stable-diffusion/stable-diffusion/x86/vs2019_opencv-mobile_ncnn-dll_demo/vs2019_opencv-mobile_ncnn-dll_demo/diffusion_slover.cpp:283:35: warning: format specifies type 'int' but the argument has type 'size_type' (aka 'unsigned long') [-Wformat]
go-stable-diffusion/stable-diffusion/x86/vs2019_opencv-mobile_ncnn-dll_demo/vs2019_opencv-mobile_ncnn-dll_demo/diffusion_slover.cpp:420:33: warning: format specifies type 'int' but the argument has type 'size_type' (aka 'unsigned long') [-Wformat]
# github.com/go-skynet/LocalAI/cmd/grpc/stablediffusion
/opt/homebrew/Cellar/go/1.21.3/libexec/pkg/tool/darwin_arm64/link: running c++ failed: exit status 1
ld: warning: ignoring duplicate libraries: '-lc++', '-lcblas'
ld: library 'gomp' not found
clang: error: linker command failed with exit code 1 (use -v to see invocation)

make: *** [backend-assets/grpc/stablediffusion] Error 1

Additional context

Aisuko commented 8 months ago

Please kindly check https://github.com/mudler/LocalAI/issues/1197#issuecomment-1779573484