mudler / LocalAI

:robot: The free, Open Source alternative to OpenAI, Claude and others. Self-hosted 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. Features: Generate Text, Audio, Video, Images, Voice Cloning, Distributed inference
https://localai.io
MIT License
24.08k stars 1.85k forks source link

Add `grpc` to required homebrew packages on mac build documentation #1197

Open amj opened 1 year ago

amj commented 1 year ago

the "build on mac" instructions at https://localai.io/basics/build/ don't work; following them results in cmake not finding the GRPC libraries. The fix is to add brew install grpc into the #install build dependencies section.#1191

Thanks for the great project!

Aisuko commented 1 year ago

Hi, @lunamidori5 . May you please help us with this one?

amj commented 1 year ago

this is actually not sufficent; following the build examples with clean installs of everything from homebrew, one of the subdirectories fails to build with: fatal error: 'google/protobuf/port_def.inc' file not found ... haven't dug into it yet.

Aisuko commented 1 year ago

Thanks for your feedback.

lunamidori5 commented 1 year ago

Hi, @lunamidori5 . May you please help us with this one?

@Aisuko I have been assigned, how may I help?

mudler commented 1 year ago

Installing grpc from homebrew doesn't seem to be enough, it's needed to compile it from source for now. See https://github.com/go-skynet/LocalAI/blob/master/.github/workflows/release.yaml#L77

localai-bot commented 1 year ago

:warning::warning::warning::warning::warning:

Hi! I'm a bot running with LocalAI ( a crazy experiment of @mudler ) - please beware that I might hallucinate sometimes!

_but.... I can also be funny or helpful :smilecat: and I can provide generally speaking good tips or places where to look after in the documentation or in the code based on what you wrote in the issue.

Don't engage in conversation with me, I don't support (yet) replying!

:warning::warning::warning::warning::warning:

Thank you for bringing this to our attention. We will update the instructions on the LocalAI website to include the additional step of installing GRPC using brew. To clarify, the issue is that when following the "build on mac" instructions on the LocalAI website, cmake is not able to find the GRPC libraries. This is likely because the instructions do not include the step of installing GRPC using brew. To fix this issue, you can add the following command to the "#install build dependencies" section of your terminal:

brew install grpc

This will install GRPC using brew, which should allow cmake to find the necessary libraries for building the LocalAI container image on macOS. We apologize for any confusion this may have caused and appreciate your help in improving the documentation.

Sources:

lunamidori5 commented 1 year ago

@mudler so what should I do to update the page? Do I need to just make a mac copy of the page?

stephsix commented 12 months ago

Is there any progress? I've also encountered the issue. My device is a MacBook Air M1. I've also tried to fix this issue myself, including hardcoding the [include path of brew installed grpc] in all CMakeLists.txt files, but then I encountered the missing of absl plugins again.

kyleobrien91 commented 12 months ago

Installing grpc from homebrew doesn't seem to be enough, it's needed to compile it from source for now. See https://github.com/go-skynet/LocalAI/blob/master/.github/workflows/release.yaml#L77

@mudler - this works to solve the first error Could not find a package configuration file provided by "absl". However, the error about protobuf that follows isn't solved by building grpc from source. - fatal error: 'google/protobuf/port_def.inc' file not found

mudler commented 12 months ago

Installing grpc from homebrew doesn't seem to be enough, it's needed to compile it from source for now. See https://github.com/go-skynet/LocalAI/blob/master/.github/workflows/release.yaml#L77

@mudler - this works to solve the first error Could not find a package configuration file provided by "absl". However, the error about protobuf that follows isn't solved by building grpc from source. - fatal error: 'google/protobuf/port_def.inc' file not found

try also to specify:

          export C_INCLUDE_PATH=/usr/local/include
          export CPLUS_INCLUDE_PATH=/usr/local/include
Aisuko commented 11 months ago

@mudler so what should I do to update the page? Do I need to just make a mac copy of the page?

I think we can append two env variables to the Mac building document

export C_INCLUDE_PATH=/usr/local/include
export CPLUS_INCLUDE_PATH=/usr/local/include
NinjAiBot commented 11 months ago

@mudler so what should I do to update the page? Do I need to just make a mac copy of the page?

I think we can append two env variables to the Mac building document

export C_INCLUDE_PATH=/usr/local/include
export CPLUS_INCLUDE_PATH=/usr/local/include

Thanks for the prompt reply, @Aisuko - I added them, but now I see this:

🤖 ninj@AI 🤖 ~/GithubPulls/LLMs/LocalAI make build
go mod edit -replace github.com/nomic-ai/gpt4all/gpt4all-bindings/golang=/Users/ninjai/GithubPulls/LLMs/LocalAI/gpt4all/gpt4all-bindings/golang
go mod edit -replace github.com/go-skynet/go-ggml-transformers.cpp=/Users/ninjai/GithubPulls/LLMs/LocalAI/go-ggml-transformers
go mod edit -replace github.com/donomii/go-rwkv.cpp=/Users/ninjai/GithubPulls/LLMs/LocalAI/go-rwkv
go mod edit -replace github.com/ggerganov/whisper.cpp=/Users/ninjai/GithubPulls/LLMs/LocalAI/whisper.cpp
go mod edit -replace github.com/go-skynet/go-bert.cpp=/Users/ninjai/GithubPulls/LLMs/LocalAI/go-bert
go mod edit -replace github.com/mudler/go-stable-diffusion=/Users/ninjai/GithubPulls/LLMs/LocalAI/go-stable-diffusion
go mod edit -replace github.com/mudler/go-piper=/Users/ninjai/GithubPulls/LLMs/LocalAI/go-piper
go mod download
touch prepare
I local-ai build info:
I BUILD_TYPE:
I GO_TAGS:
I LD_FLAGS:  -X "github.com/go-skynet/LocalAI/internal.Version=v1.40.0-12-g562ac62" -X "github.com/go-skynet/LocalAI/internal.Commit=562ac62f59b55c831207a908f07144473c2c4599"
CGO_LDFLAGS=" -lcblas -framework Accelerate" go build -ldflags " -X "github.com/go-skynet/LocalAI/internal.Version=v1.40.0-12-g562ac62" -X "github.com/go-skynet/LocalAI/internal.Commit=562ac62f59b55c831207a908f07144473c2c4599"" -tags "" -o local-ai ./
# github.com/go-skynet/LocalAI
ld: warning: ignoring duplicate libraries: '-lcblas'
🤖 ninj@AI 🤖 ~/GithubPulls/LLMs/LocalAI

Seems to be coming from line 285 of Makefile

CGO_LDFLAGS="$(CGO_LDFLAGS)" $(GOCMD) build -ldflags "$(LD_FLAGS)" -tags "$(GO_TAGS)" -o $(BINARY_NAME) ./

As I see no sign of the release dir created on line 288:

## Build:

build: grpcs prepare ## Build the project
    $(info ${GREEN}I local-ai build info:${RESET})
    $(info ${GREEN}I BUILD_TYPE: ${YELLOW}$(BUILD_TYPE)${RESET})
    $(info ${GREEN}I GO_TAGS: ${YELLOW}$(GO_TAGS)${RESET})
    $(info ${GREEN}I LD_FLAGS: ${YELLOW}$(LD_FLAGS)${RESET})

    CGO_LDFLAGS="$(CGO_LDFLAGS)" $(GOCMD) build -ldflags "$(LD_FLAGS)" -tags "$(GO_TAGS)" -o $(BINARY_NAME) ./

dist: build
    mkdir -p release
    cp $(BINARY_NAME) release/$(BINARY_NAME)-$(BUILD_ID)-$(OS)-$(ARCH)
Screenshot 2023-11-07 at 23 51 45

If this helps - this is the output from where I think the issue is arising from:

https://pastebin.com/iBVxB70L

and this is the entire output (sorry for hurting your eyes) from running go clean -cache, cd .. && rm -rf LocalAI, re-cloning the repo, running export C_INCLUDE_PATH=/usr/local/include, export CPLUS_INCLUDE_PATH=/usr/local/include and finally sudo make build

https://pastebin.com/ryhWfQkJ

NinjAiBot commented 10 months ago

Still no word on official fixes? I'd really like to use it - Ollama is pretty unreliable for my use case and I think this would be the perfect solution.

ChristianWeyer commented 10 months ago

@mudler so what should I do to update the page? Do I need to just make a mac copy of the page?

I think we can append two env variables to the Mac building document

export C_INCLUDE_PATH=/usr/local/include
export CPLUS_INCLUDE_PATH=/usr/local/include

I also added these and cannot get to compile it successfully on my Apple M1 Max.

clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[4]: *** [bin/grpc-server] Error 1
make[3]: *** [examples/grpc-server/CMakeFiles/grpc-server.dir/all] Error 2
make[2]: *** [all] Error 2
make[1]: *** [grpc-server] Error 2
make: *** [backend/cpp/llama/grpc-server] Error 2
Cyb3rDudu commented 8 months ago

make[3]: *** [examples/grpc-server/CMakeFiles/grpc-server.dir/all] Error 2

I see the same error

Consolidate compiler generated dependencies of target grpc-server
[ 96%] Linking CXX executable ../../bin/grpc-server
ld: warning: ignoring duplicate libraries: '../../common/libcommon.a', '../../libllama.a'
ld: Undefined symbols:
  void absl::lts_20230802::log_internal::LogMessage::CopyToEncodedBuffer<(absl::lts_20230802::log_internal::LogMessage::StringType)0>(std::__1::basic_string_view<char, std::__1::char_traits<char>>), referenced from:
      google::protobuf::MapKey::GetStringValue() const in libhw_grpc_proto.a[3](backend.pb.cc.o)
      google::protobuf::MapKey::GetStringValue() const in libhw_grpc_proto.a[3](backend.pb.cc.o)
      google::protobuf::MapKey::GetStringValue() const in libhw_grpc_proto.a[3](backend.pb.cc.o)
      google::protobuf::MapKey::GetStringValue() const in libhw_grpc_proto.a[3](backend.pb.cc.o)
      google::protobuf::MapKey::GetStringValue() const in libhw_grpc_proto.a[3](backend.pb.cc.o)
      google::protobuf::MapKey::GetStringValue() const in libhw_grpc_proto.a[3](backend.pb.cc.o)
      google::protobuf::MapKey::GetStringValue() const in libhw_grpc_proto.a[3](backend.pb.cc.o)
      google::protobuf::MapKey::GetStringValue() const in libhw_grpc_proto.a[3](backend.pb.cc.o)
      ...
  absl::lts_20230802::cord_internal::InitializeCordRepExternal(std::__1::basic_string_view<char, std::__1::char_traits<char>>, absl::lts_20230802::cord_internal::CordRepExternal*), referenced from:
      grpc::ProtoBufferReader::ReadCord(absl::lts_20230802::Cord*, int) in libhw_grpc_proto.a[2](backend.grpc.pb.cc.o)
      grpc::ProtoBufferReader::ReadCord(absl::lts_20230802::Cord*, int) in libhw_grpc_proto.a[2](backend.grpc.pb.cc.o)
      grpc::ProtoBufferReader::ReadCord(absl::lts_20230802::Cord*, int) in libhw_grpc_proto.a[2](backend.grpc.pb.cc.o)
      grpc::ProtoBufferReader::ReadCord(absl::lts_20230802::Cord*, int) in libhw_grpc_proto.a[2](backend.grpc.pb.cc.o)
  google::protobuf::internal::ArenaStringPtr::Set(absl::lts_20230802::string_view, google::protobuf::Arena*), referenced from:
      BackendServiceImpl::Health(grpc::ServerContext*, backend::HealthMessage const*, backend::Reply*) in grpc-server.cpp.o
      BackendServiceImpl::LoadModel(grpc::ServerContext*, backend::ModelOptions const*, backend::Result*) in grpc-server.cpp.o
      BackendServiceImpl::LoadModel(grpc::ServerContext*, backend::ModelOptions const*, backend::Result*) in grpc-server.cpp.o
clang: error: linker command failed with exit code 1 (use -v to see invocation)
gmake[4]: *** [examples/grpc-server/CMakeFiles/grpc-server.dir/build.make:197: bin/grpc-server] Error 1
gmake[3]: *** [CMakeFiles/Makefile2:2930: examples/grpc-server/CMakeFiles/grpc-server.dir/all] Error 2
gmake[2]: *** [Makefile:146: all] Error 2
gmake[2]: Leaving directory '/Users/dudu/Repos/LocalAI/backend/cpp/llama/llama.cpp/build'
make[1]: *** [grpc-server] Error 2
make: *** [backend/cpp/llama/grpc-server] Error 2

How can I fix this?

thiner commented 5 months ago

I encountered this error while building LocalAI from source on Ubuntu 22.04. I solved the compilation error by following steps.

  1. Follow the instruction from this thread https://github.com/grpc/grpc/issues/29695#issuecomment-1129244262, try to completely reinstall the grpc on your machine.
  2. If your compilation failed due to fatal error: 'google/protobuf/port_def.inc' file not found error. Follow @mudler 's solution:
    export C_INCLUDE_PATH=/usr/local/include
    export CPLUS_INCLUDE_PATH=/usr/local/include

    but if that's not help, check your real include folders, and correct the commands. In my case, I have to modify the paths to

    export C_INCLUDE_PATH=~/.local/include
    export CPLUS_INCLUDE_PATH=~/.local/include