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
23.12k stars 1.75k forks source link

Build on macbook m3 faild : old protoc version #1371

Open kevin-meng opened 9 months ago

kevin-meng commented 9 months ago

LocalAI version:

branch: master. tag:1.40.0

Environment, CPU architecture, OS, and Version:

MacBook Pro M3 96 GB mac0S sonoma 14.1

Describe the bug

Error: error: This file was generated by an older version of protoc Error as blow

/Users/kevin/DeepLearning/gpt/localAI/LocalAI/backend/cpp/llama/llama.cpp/build/examples/grpc-server/backend.pb.h:17:2: error: This file was generated by an older version of protoc which is
#error This file was generated by an older version of protoc which is
 ^
/Users/kevin/DeepLearning/gpt/localAI/LocalAI/backend/cpp/llama/llama.cpp/build/examples/grpc-server/backend.pb.h:18:2: error: incompatible with your Protocol Buffer headers. Please
#error incompatible with your Protocol Buffer headers. Please
 ^
/Users/kevin/DeepLearning/gpt/localAI/LocalAI/backend/cpp/llama/llama.cpp/build/examples/grpc-server/backend.pb.h:19:2: error: regenerate this file with a newer version of protoc.
#error regenerate this file with a newer version of protoc.

Users/kevin/DeepLearning/gpt/localAI/LocalAI/backend/cpp/llama/llama.cpp/build/examples/grpc-server/backend.pb.h:41:1: error: unknown type name 'PROTOBUF_NAMESPACE_OPEN'
PROTOBUF_NAMESPACE_OPEN
^
/Users/kevin/DeepLearning/gpt/localAI/LocalAI/backend/cpp/llama/llama.cpp/build/examples/grpc-server/backend.pb.h:42:1: error: expected unqualified-id
namespace internal {
^
/Users/kevin/DeepLearning/gpt/localAI/LocalAI/backend/cpp/llama/llama.cpp/build/examples/grpc-server/backend.pb.h:45:1: error: unknown type name 'PROTOBUF_NAMESPACE_CLOSE'
PROTOBUF_NAMESPACE_CLOSE
^
/Users/kevin/DeepLearning/gpt/localAI/LocalAI/backend/cpp/llama/llama.cpp/build/examples/grpc-server/backend.pb.h:51:16: error: no member named 'PROTOBUF_NAMESPACE_ID' in the global namespace

To Reproduce

build faild use blow script

   1   │ export C_INCLUDE_PATH=/usr/local/include
   2   │ export CPLUS_INCLUDE_PATH=/usr/local/include
   3   │
   4   │ export BUILD_GRPC_FOR_BACKEND_LLAMA=on
   5   │
   6   │ # install build dependencies
   7   │ # brew install abseil cmake go grpc protobuf wget
   8   │
   9   │ # clone the repo
  10   │ git clone https://github.com/go-skynet/LocalAI.git
  11   │
  12   │ cd LocalAI
  13   │
  14   │
  15   │ # make backend/cpp/llama/grpc-server
  16   │
  17   │ make clean
  18   │ brew link protobuf
  19   |
  20   │ make BUILD_TYPE=metal build

Expected behavior

Logs

full log in the attrachment log.txt

Additional context

sweetcard commented 9 months ago

check your protoc version. I found two versions installed in my m3. The new version should be placed before the old one in PATH. Use the following command to find versions installed. which -a protoc

kevin-meng commented 9 months ago

it turely have two version protoc in my pc

╰─ which -a protoc                                                                                                                                                                                                 ─╯
/Users/kevin/anaconda3/bin/protoc
/opt/homebrew/bin/protoc

and i rename the first version mv /Users/kevin/anaconda3/bin/protoc /Users/kevin/anaconda3/bin/protoc1

but not success

and the errror and log as below /:sad

      google::protobuf::internal::KeyMapBase<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>::FindHelper(std::__1::basic_string_view<char, std::__1::char_traits<char>>, absl::lts_20230802::container_internal::btree_iterator<absl::lts_20230802::container_internal::btree_node<absl::lts_20230802::container_internal::map_params<google::protobuf::internal::VariantKey, google::protobuf::internal::NodeBase*, std::__1::less<google::protobuf::internal::VariantKey>, google::protobuf::internal::MapAllocator<std::__1::pair<google::protobuf::internal::VariantKey const, google::protobuf::internal::NodeBase*>>, 256, false>>, std::__1::pair<google::protobuf::internal::VariantKey const, google::protobuf::internal::NodeBase*>&, std::__1::pair<google::protobuf::internal::VariantKey const, google::protobuf::internal::NodeBase*>*>*) const in libhw_grpc_proto.a[3](backend.pb.cc.o)
  google::protobuf::internal::ZeroFieldsBase::GetClassData() const, referenced from:
      vtable for backend::HealthMessage in libhw_grpc_proto.a[3](backend.pb.cc.o)
  google::protobuf::internal::TaggedStringPtr::ForceCopy(google::protobuf::Arena*) const, referenced from:
      backend::PredictOptions::PredictOptions(google::protobuf::Arena*, backend::PredictOptions const&) in libhw_grpc_proto.a[3](backend.pb.cc.o)
      backend::PredictOptions::PredictOptions(google::protobuf::Arena*, backend::PredictOptions const&) in libhw_grpc_proto.a[3](backend.pb.cc.o)
      backend::PredictOptions::PredictOptions(google::protobuf::Arena*, backend::PredictOptions const&) in libhw_grpc_proto.a[3](backend.pb.cc.o)
      backend::PredictOptions::PredictOptions(google::protobuf::Arena*, backend::PredictOptions const&) in libhw_grpc_proto.a[3](backend.pb.cc.o)
      backend::PredictOptions::PredictOptions(google::protobuf::Arena*, backend::PredictOptions const&) in libhw_grpc_proto.a[3](backend.pb.cc.o)
      backend::PredictOptions::PredictOptions(google::protobuf::Arena*, backend::PredictOptions const&) in libhw_grpc_proto.a[3](backend.pb.cc.o)
      backend::PredictOptions::PredictOptions(google::protobuf::Arena*, backend::PredictOptions const&) in libhw_grpc_proto.a[3](backend.pb.cc.o)
      backend::PredictOptions::PredictOptions(google::protobuf::Arena*, backend::PredictOptions const&) in libhw_grpc_proto.a[3](backend.pb.cc.o)
      ...
clang: error: linker command failed with exit code 1 (use -v to see invocation)

log4.txt

sweetcard commented 9 months ago

it turely have two version protoc in my pc

╰─ which -a protoc                                                                                                                                                                                                 ─╯
/Users/kevin/anaconda3/bin/protoc
/opt/homebrew/bin/protoc

and i rename the first version mv /Users/kevin/anaconda3/bin/protoc /Users/kevin/anaconda3/bin/protoc1

but not success

and the errror and log as below /:sad

      google::protobuf::internal::KeyMapBase<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>::FindHelper(std::__1::basic_string_view<char, std::__1::char_traits<char>>, absl::lts_20230802::container_internal::btree_iterator<absl::lts_20230802::container_internal::btree_node<absl::lts_20230802::container_internal::map_params<google::protobuf::internal::VariantKey, google::protobuf::internal::NodeBase*, std::__1::less<google::protobuf::internal::VariantKey>, google::protobuf::internal::MapAllocator<std::__1::pair<google::protobuf::internal::VariantKey const, google::protobuf::internal::NodeBase*>>, 256, false>>, std::__1::pair<google::protobuf::internal::VariantKey const, google::protobuf::internal::NodeBase*>&, std::__1::pair<google::protobuf::internal::VariantKey const, google::protobuf::internal::NodeBase*>*>*) const in libhw_grpc_proto.a[3](backend.pb.cc.o)
  google::protobuf::internal::ZeroFieldsBase::GetClassData() const, referenced from:
      vtable for backend::HealthMessage in libhw_grpc_proto.a[3](backend.pb.cc.o)
  google::protobuf::internal::TaggedStringPtr::ForceCopy(google::protobuf::Arena*) const, referenced from:
      backend::PredictOptions::PredictOptions(google::protobuf::Arena*, backend::PredictOptions const&) in libhw_grpc_proto.a[3](backend.pb.cc.o)
      backend::PredictOptions::PredictOptions(google::protobuf::Arena*, backend::PredictOptions const&) in libhw_grpc_proto.a[3](backend.pb.cc.o)
      backend::PredictOptions::PredictOptions(google::protobuf::Arena*, backend::PredictOptions const&) in libhw_grpc_proto.a[3](backend.pb.cc.o)
      backend::PredictOptions::PredictOptions(google::protobuf::Arena*, backend::PredictOptions const&) in libhw_grpc_proto.a[3](backend.pb.cc.o)
      backend::PredictOptions::PredictOptions(google::protobuf::Arena*, backend::PredictOptions const&) in libhw_grpc_proto.a[3](backend.pb.cc.o)
      backend::PredictOptions::PredictOptions(google::protobuf::Arena*, backend::PredictOptions const&) in libhw_grpc_proto.a[3](backend.pb.cc.o)
      backend::PredictOptions::PredictOptions(google::protobuf::Arena*, backend::PredictOptions const&) in libhw_grpc_proto.a[3](backend.pb.cc.o)
      backend::PredictOptions::PredictOptions(google::protobuf::Arena*, backend::PredictOptions const&) in libhw_grpc_proto.a[3](backend.pb.cc.o)
      ...
clang: error: linker command failed with exit code 1 (use -v to see invocation)

log4.txt

This is my version. protoc --version libprotoc 25.1

Your version is : protobuf version 24.3.0

could you update your protoc to lastest version and retry ?

kevin-meng commented 9 months ago

my protobuf version already 25.1

i dont know why the build version use 24.3.0....

image
kevin-meng commented 9 months ago

it turely have two version protoc in my pc

╰─ which -a protoc                                                                                                                                                                                                 ─╯
/Users/kevin/anaconda3/bin/protoc
/opt/homebrew/bin/protoc

and i rename the first version mv /Users/kevin/anaconda3/bin/protoc /Users/kevin/anaconda3/bin/protoc1 but not success and the errror and log as below /:sad

      google::protobuf::internal::KeyMapBase<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>::FindHelper(std::__1::basic_string_view<char, std::__1::char_traits<char>>, absl::lts_20230802::container_internal::btree_iterator<absl::lts_20230802::container_internal::btree_node<absl::lts_20230802::container_internal::map_params<google::protobuf::internal::VariantKey, google::protobuf::internal::NodeBase*, std::__1::less<google::protobuf::internal::VariantKey>, google::protobuf::internal::MapAllocator<std::__1::pair<google::protobuf::internal::VariantKey const, google::protobuf::internal::NodeBase*>>, 256, false>>, std::__1::pair<google::protobuf::internal::VariantKey const, google::protobuf::internal::NodeBase*>&, std::__1::pair<google::protobuf::internal::VariantKey const, google::protobuf::internal::NodeBase*>*>*) const in libhw_grpc_proto.a[3](backend.pb.cc.o)
  google::protobuf::internal::ZeroFieldsBase::GetClassData() const, referenced from:
      vtable for backend::HealthMessage in libhw_grpc_proto.a[3](backend.pb.cc.o)
  google::protobuf::internal::TaggedStringPtr::ForceCopy(google::protobuf::Arena*) const, referenced from:
      backend::PredictOptions::PredictOptions(google::protobuf::Arena*, backend::PredictOptions const&) in libhw_grpc_proto.a[3](backend.pb.cc.o)
      backend::PredictOptions::PredictOptions(google::protobuf::Arena*, backend::PredictOptions const&) in libhw_grpc_proto.a[3](backend.pb.cc.o)
      backend::PredictOptions::PredictOptions(google::protobuf::Arena*, backend::PredictOptions const&) in libhw_grpc_proto.a[3](backend.pb.cc.o)
      backend::PredictOptions::PredictOptions(google::protobuf::Arena*, backend::PredictOptions const&) in libhw_grpc_proto.a[3](backend.pb.cc.o)
      backend::PredictOptions::PredictOptions(google::protobuf::Arena*, backend::PredictOptions const&) in libhw_grpc_proto.a[3](backend.pb.cc.o)
      backend::PredictOptions::PredictOptions(google::protobuf::Arena*, backend::PredictOptions const&) in libhw_grpc_proto.a[3](backend.pb.cc.o)
      backend::PredictOptions::PredictOptions(google::protobuf::Arena*, backend::PredictOptions const&) in libhw_grpc_proto.a[3](backend.pb.cc.o)
      backend::PredictOptions::PredictOptions(google::protobuf::Arena*, backend::PredictOptions const&) in libhw_grpc_proto.a[3](backend.pb.cc.o)
      ...
clang: error: linker command failed with exit code 1 (use -v to see invocation)

log4.txt

This is my version. protoc --version libprotoc 25.1

Your version is : protobuf version 24.3.0

could you update your protoc to lastest version and retry ?

hi i have try it again. faild again..... logs as below log5.txt

image
sweetcard commented 9 months ago

it turely have two version protoc in my pc

╰─ which -a protoc                                                                                                                                                                                                 ─╯
/Users/kevin/anaconda3/bin/protoc
/opt/homebrew/bin/protoc

and i rename the first version mv /Users/kevin/anaconda3/bin/protoc /Users/kevin/anaconda3/bin/protoc1 but not success and the errror and log as below /:sad

      google::protobuf::internal::KeyMapBase<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>::FindHelper(std::__1::basic_string_view<char, std::__1::char_traits<char>>, absl::lts_20230802::container_internal::btree_iterator<absl::lts_20230802::container_internal::btree_node<absl::lts_20230802::container_internal::map_params<google::protobuf::internal::VariantKey, google::protobuf::internal::NodeBase*, std::__1::less<google::protobuf::internal::VariantKey>, google::protobuf::internal::MapAllocator<std::__1::pair<google::protobuf::internal::VariantKey const, google::protobuf::internal::NodeBase*>>, 256, false>>, std::__1::pair<google::protobuf::internal::VariantKey const, google::protobuf::internal::NodeBase*>&, std::__1::pair<google::protobuf::internal::VariantKey const, google::protobuf::internal::NodeBase*>*>*) const in libhw_grpc_proto.a[3](backend.pb.cc.o)
  google::protobuf::internal::ZeroFieldsBase::GetClassData() const, referenced from:
      vtable for backend::HealthMessage in libhw_grpc_proto.a[3](backend.pb.cc.o)
  google::protobuf::internal::TaggedStringPtr::ForceCopy(google::protobuf::Arena*) const, referenced from:
      backend::PredictOptions::PredictOptions(google::protobuf::Arena*, backend::PredictOptions const&) in libhw_grpc_proto.a[3](backend.pb.cc.o)
      backend::PredictOptions::PredictOptions(google::protobuf::Arena*, backend::PredictOptions const&) in libhw_grpc_proto.a[3](backend.pb.cc.o)
      backend::PredictOptions::PredictOptions(google::protobuf::Arena*, backend::PredictOptions const&) in libhw_grpc_proto.a[3](backend.pb.cc.o)
      backend::PredictOptions::PredictOptions(google::protobuf::Arena*, backend::PredictOptions const&) in libhw_grpc_proto.a[3](backend.pb.cc.o)
      backend::PredictOptions::PredictOptions(google::protobuf::Arena*, backend::PredictOptions const&) in libhw_grpc_proto.a[3](backend.pb.cc.o)
      backend::PredictOptions::PredictOptions(google::protobuf::Arena*, backend::PredictOptions const&) in libhw_grpc_proto.a[3](backend.pb.cc.o)
      backend::PredictOptions::PredictOptions(google::protobuf::Arena*, backend::PredictOptions const&) in libhw_grpc_proto.a[3](backend.pb.cc.o)
      backend::PredictOptions::PredictOptions(google::protobuf::Arena*, backend::PredictOptions const&) in libhw_grpc_proto.a[3](backend.pb.cc.o)
      ...
clang: error: linker command failed with exit code 1 (use -v to see invocation)

log4.txt

This is my version. protoc --version libprotoc 25.1 Your version is : protobuf version 24.3.0 could you update your protoc to lastest version and retry ?

hi i have try it again. faild again..... logs as below log5.txt

image

Check this link: https://github.com/protocolbuffers/protobuf/issues/11828#issue-1573588295

Maybe another library is not compatible.

I suggest to change your PATH in your ~/.zshrc like this:

export PATH=/opt/homebrew/bin:$PATH

kevin-meng commented 9 months ago

finally , it works ~
thank you so much for your kindly help! @sweetcard

========================= build scripts as blow:

  1. install build dependencies
    
    export C_INCLUDE_PATH=/usr/local/include
    export CPLUS_INCLUDE_PATH=/usr/local/include

install build dependencies

brew install abseil cmake go grpc protobuf wget


2. check protoc path and version
add  `export PATH=/opt/homebrew/bin:$PATH`  to the last line of `~/.zshrc`
`source ~/.zshrc`

check PATH.  should as below 

which -a protoc whereis protoc echo $PATH

>/opt/homebrew/bin:/Users/kevin/.zplug/bin:/Users/kevin/bin:/usr/local/bin:/opt/homebrew/bin:/Users/kevin/anaconda3/bin:/Users/kevin/anaconda3/bin:/Users/kevin/anaconda3/condabin:

Note: anaconda also have protoc in the ~/anaconda3/bin  . this why i faild before.

3. build  LocalAI on mac

clone the repo

git clone https://github.com/go-skynet/LocalAI.git

cd LocalAI

make clean brew link protobuf make BUILD_TYPE=metal build



then you can enjoy this awsome  project
sweetcard commented 9 months ago

finally , it works ~ thank you so much for your kindly help! @sweetcard

========================= build scripts as blow:

  1. install build dependencies
 export C_INCLUDE_PATH=/usr/local/include
export CPLUS_INCLUDE_PATH=/usr/local/include

# install build dependencies
brew install abseil cmake go grpc protobuf wget
  1. check protoc path and version add export PATH=/opt/homebrew/bin:$PATH to the last line of ~/.zshrc source ~/.zshrc

check PATH. should as below

which -a protoc
whereis protoc
echo $PATH                                                                                                                                                                                                     

/opt/homebrew/bin:/Users/kevin/.zplug/bin:/Users/kevin/bin:/usr/local/bin:/opt/homebrew/bin:/Users/kevin/anaconda3/bin:/Users/kevin/anaconda3/bin:/Users/kevin/anaconda3/condabin:

Note: anaconda also have protoc in the ~/anaconda3/bin . this why i faild before.

  1. build LocalAI on mac
# clone the repo
git clone https://github.com/go-skynet/LocalAI.git

cd LocalAI

make clean
brew link protobuf
make BUILD_TYPE=metal build

then you can enjoy this awsome project

Glad to hear that. 😄👍

localai-bot commented 9 months 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:

ERROR: The prompt size exceeds the context window size and cannot be processed.

Sources:

MaxKolbysh commented 9 months ago

During the build I have another issue: In my case protobuf version already 25.1

but then go: too many arguments make: *** [replace] Error 1