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.75k stars 1.66k forks source link

Error on build M1 Metal #626

Closed juanfadev closed 8 months ago

juanfadev commented 1 year ago

LocalAI version: commit 618fd1d41730ab03f7ac40e2457ea29709756b1f

Environment, CPU architecture, OS, and Version: Macbook Pro M1 Pro 16GB, macOS 12.6

Describe the bug Failure on build

To Reproduce make BUILD_TYPE=metal build

Expected behavior build finished OK

Logs

In file included from gobert.cpp:6:
go-bert/bert.cpp/bert.cpp:692:74: warning: format specifies type 'int' but the argument has type 'unsigned long' [-Wformat]
# github.com/go-skynet/go-ggml-transformers.cpp
replit.cpp:65:50: warning: format specifies type 'int' but the argument has type 'std::__vector_base<unsigned long, std::allocator<unsigned long>>::value_type' (aka 'unsigned long') [-Wformat]
# github.com/go-skynet/LocalAI/pkg/model
pkg/model/initializers.go:164:86: undefined: gpt4all.SetLibrarySearchPath
make: *** [build] Error 1

Additional context I have pulled latest changes, it was working previously in a revision from last week.

mudler commented 1 year ago

did you run make clean first?

drpaneas commented 1 year ago

I do not have M1, but I do have a regular x86_64 Macbook Pro from 2020 and I just cloned the project and I did:

make prepare
make build

and it failed:

[....]
  "_whisper_token_translate", referenced from:
      __cgo_6d775385d461_Cfunc_whisper_token_translate in 000035.o
     (maybe you meant: __cgo_6d775385d461_Cfunc_whisper_token_translate)
  "_whisper_tokenize", referenced from:
      __cgo_6d775385d461_Cfunc_whisper_tokenize in 000035.o
     (maybe you meant: __cgo_6d775385d461_Cfunc_whisper_tokenize)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

make: *** [build] Error 1

If this is not relevant to this issue, please ignore it.

Aisuko commented 1 year ago

Make sure you run make clean to remove all the .cpp, and .c files and rebuild them. I assume that maybe some files cannot be recognized in the header file. https://stackoverflow.com/questions/49453582/symbols-not-found-for-architecture-x86-64-mac-os-10-13-3

drpaneas commented 1 year ago

I tried that and didn't fix the issue. Basically you need to devenv for C and C++, and if you don't then you end up with GH issues like that. I guess building inside a container (mounting the local source code, so it can export the binary) would be better approach in terms of compatibility.

Aisuko commented 1 year ago

I tried that and didn't fix the issue. Basically you need to devenv for C and C++, and if you don't then you end up with GH issues like that. I guess building inside a container (mounting the local source code, so it can export the binary) would be better approach in terms of compatibility.

This is a good idea, I have tried it before but the container environment has some weird issues with the arm container environment, here is the issue https://github.com/devcontainers/images/issues/566. And we need to support cross-platform with docker buildx bake. What do you think if we support inside container building? cc @mudler

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

Based on the logs provided, it seems like there is a type mismatch error in the format specifier of the argument passed to the format function in the gobert.cpp file. Additionally, there is an undefined symbol error for gpt4all.SetLibrarySearchPath in the initializers.go file. It's possible that these issues are caused by a compatibility issue between different versions of the dependencies used in the project. To troubleshoot this further, you can try the following steps:

  1. Check the version compatibility of all the dependencies used in the project and ensure they are compatible with each other. You can use tools like go-cmp to compare the dependencies and their versions.
  2. Ensure that the GOGGMLTRANSFORMERS_VERSION, BERT_VERSION, and BLOOMZ_VERSION variables are set correctly in the go.mod file for the project.
  3. Check if there are any other issues with the code or dependencies that may be causing the build to fail. You can try running the build command with the --verbose flag to get more detailed information about the errors encountered during the build process.

Sources:

ChristianWeyer commented 6 months ago

I tried that and didn't fix the issue. Basically you need to devenv for C and C++, and if you don't then you end up with GH issues like that. I guess building inside a container (mounting the local source code, so it can export the binary) would be better approach in terms of compatibility.

Did you ever solve this @drpaneas ?

drpaneas commented 6 months ago

@ChristianWeyer honestly I don't remember. I think I did, but it's been quite awhile and I don't remember what and how :/