Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make build failing on Apple silicon - macbook m2 pro #411

Closed
devilankur18 opened this issue May 29, 2023 · 11 comments · Fixed by #475
Closed

Make build failing on Apple silicon - macbook m2 pro #411

devilankur18 opened this issue May 29, 2023 · 11 comments · Fixed by #475
Assignees
Labels
area/build bug Something isn't working os/macOS

Comments

@devilankur18
Copy link

LocalAI version:

728f297

Environment, CPU architecture, OS, and Version:

arm64(mac m2 pro) Ventura 13.3.1

Describe the bug

make build failing for mac m2 pro,

Error 
LocalAI/go-rwkv/rwkv.cpp/rwkv.cpp:471:19: error: variable has incomplete type 'struct stat64'

To Reproduce

git clone the repo
make build on mac m2 pro

Expected behavior

build should not fail

Logs

make build

go mod edit -replace github.com/go-skynet/go-llama.cpp=/Users/ankur/dev/generative-ai/LocalAI/go-llama
go mod edit -replace github.com/nomic-ai/gpt4all/gpt4all-bindings/golang=/Users/ankur/dev/generative-ai/LocalAI/gpt4all/gpt4all-bindings/golang
go mod edit -replace github.com/go-skynet/go-ggml-transformers.cpp=/Users/ankur/dev/generative-ai/LocalAI/go-ggml-transformers
go mod edit -replace github.com/donomii/go-rwkv.cpp=/Users/ankur/dev/generative-ai/LocalAI/go-rwkv
go mod edit -replace github.com/ggerganov/whisper.cpp=/Users/ankur/dev/generative-ai/LocalAI/whisper.cpp
go mod edit -replace github.com/go-skynet/go-bert.cpp=/Users/ankur/dev/generative-ai/LocalAI/go-bert
go mod edit -replace github.com/go-skynet/bloomz.cpp=/Users/ankur/dev/generative-ai/LocalAI/bloomz
go mod edit -replace github.com/mudler/go-stable-diffusion=/Users/ankur/dev/generative-ai/LocalAI/go-stable-diffusion
go mod download
cd go-rwkv && cd rwkv.cpp &&	cmake . -DRWKV_BUILD_SHARED_LIBRARY=OFF &&	cmake --build . && 	cp librwkv.a .. && cp ggml/src/libggml.a ..
-- Accelerate framework found
-- CMAKE_SYSTEM_PROCESSOR: arm64
-- ARM detected
-- CMAKE_SYSTEM_PROCESSOR: arm64
-- ARM detected
-- Accelerate framework found
-- Configuring done (0.0s)
-- Generating done (0.0s)
-- Build files have been written to: /Users/ankur/dev/generative-ai/LocalAI/go-rwkv/rwkv.cpp
[ 25%] Built target ggml
[ 37%] Building CXX object CMakeFiles/rwkv.dir/rwkv.cpp.o
/Users/ankur/dev/generative-ai/LocalAI/go-rwkv/rwkv.cpp/rwkv.cpp:209:5: warning: 'sprintf' is deprecated: This function is provided for compatibility reasons only.  Due to security concerns inherent in the design of sprintf(3), it is highly recommended that you use snprintf(3) instead. [-Wdeprecated-declarations]
    sprintf(full_key, "blocks.%d.%s", block_index, key.c_str());
    ^
/Library/Developer/CommandLineTools/SDKs/MacOSX13.3.sdk/usr/include/stdio.h:188:1: note: 'sprintf' has been explicitly marked deprecated here
__deprecated_msg("This function is provided for compatibility reasons only.  Due to security concerns inherent in the design of sprintf(3), it is highly recommended that you use snprintf(3) instead.")
^
/Library/Developer/CommandLineTools/SDKs/MacOSX13.3.sdk/usr/include/sys/cdefs.h:215:48: note: expanded from macro '__deprecated_msg'
        #define __deprecated_msg(_msg) __attribute__((__deprecated__(_msg)))
                                                      ^
/Users/ankur/dev/generative-ai/LocalAI/go-rwkv/rwkv.cpp/rwkv.cpp:471:19: error: variable has incomplete type 'struct stat64'
    struct stat64 file_stat;
                  ^
/Users/ankur/dev/generative-ai/LocalAI/go-rwkv/rwkv.cpp/rwkv.cpp:471:12: note: forward declaration of 'stat64'
    struct stat64 file_stat;
           ^
/Users/ankur/dev/generative-ai/LocalAI/go-rwkv/rwkv.cpp/rwkv.cpp:638:30: warning: cast from 'const rwkv_context *' to 'rwkv_context *' drops const qualifier [-Wcast-qual]
    ((struct rwkv_context *) ctx)->last_error = RWKV_ERROR_NONE;
                             ^
/Users/ankur/dev/generative-ai/LocalAI/go-rwkv/rwkv.cpp/rwkv.cpp:640:31: warning: cast from 'const rwkv_context *' to 'rwkv_context *' drops const qualifier [-Wcast-qual]
    RWKV_CTX_ASSERT_FALSE_MSG(ctx, RWKV_ERROR_ARGS, state_out != NULL, "state_out is NULL");
                              ^
/Users/ankur/dev/generative-ai/LocalAI/go-rwkv/rwkv.cpp/rwkv.cpp:641:31: warning: cast from 'const rwkv_context *' to 'rwkv_context *' drops const qualifier [-Wcast-qual]
    RWKV_CTX_ASSERT_FALSE_MSG(ctx, RWKV_ERROR_ARGS, logits_out != NULL, "logits_out is NULL");
                              ^
/Users/ankur/dev/generative-ai/LocalAI/go-rwkv/rwkv.cpp/rwkv.cpp:642:31: warning: cast from 'const rwkv_context *' to 'rwkv_context *' drops const qualifier [-Wcast-qual]
    RWKV_CTX_ASSERT_FALSE_MSG(ctx, RWKV_ERROR_ARGS, token < ctx->model->n_vocab, "Token is out of range 0..%d", ctx->model->n_vocab - 1);
                              ^
5 warnings and 1 error generated.
make[3]: *** [CMakeFiles/rwkv.dir/rwkv.cpp.o] Error 1
make[2]: *** [CMakeFiles/rwkv.dir/all] Error 2
make[1]: *** [all] Error 2
make: *** [go-rwkv/librwkv.a] Error 2

Additional context

@devilankur18 devilankur18 added the bug Something isn't working label May 29, 2023
@Aisuko
Copy link
Collaborator

Aisuko commented May 30, 2023

Hi @devilankur18 , thanks for your feedback. I am not sure if this is bug, I build it in M1 without any issue before. So, please investigate it further. And I saw you pick up a commit with a dependency update. May you try to build the main branch in your local env?

@devilankur18
Copy link
Author

@Aisuko I stared with master branch only, when it failed I tried falling back to older versions.

@Xonar92
Copy link

Xonar92 commented May 30, 2023

I also have this problem on my M1 Pro Macbook

@Aisuko
Copy link
Collaborator

Aisuko commented May 30, 2023

Hi, guys. I hit the issue of the building process in my (arrch64) container environment #282 (comment) but I did not hit the issue on my laptop(M1). May you guys try to use the x86_64 environment? Github Codespace is pretty ok, I use it as the built environment.

@Aisuko
Copy link
Collaborator

Aisuko commented May 30, 2023

Please use make clean to clean all the binding packages and make sure there without any changes to the code.

And resetting every binding packages's changes by using git submodule foreach git reset --hard command.

And you can use make prepare re-download and compile all the files, making sure everything works out. After that, make test check if everything is ok.

@metercai
Copy link

This issue may be caused by the loaded sub-project: https://github.com/donomii/go-rwkv.cpp. When using the project's built-in compilation script: ./build-mac.sh, it fails to compile on my Macbook M1 Pro. Has anyone been able to successfully compile it?

@mudler
Copy link
Owner

mudler commented May 30, 2023

I don't have a macOS, and the CI seems to pass for MacOS reducing my possibilities to test it. Can you see if you can compile https://github.com/saharNooby/rwkv.cpp? The issue seems to come from there. would be great to open an issue to rwkv.cpp too

@devilankur18
Copy link
Author

I have made the changes and it worked

image

@LoganDark
Copy link

this is the fix https://github.com/saharNooby/rwkv.cpp/blob/a8ebb07d2501dcb6fd544177022421660537030f/rwkv.cpp#L20-L36 and should be merged in a day or two

@mudler
Copy link
Owner

mudler commented Jun 1, 2023

Thank you so much @LoganDark !

ping @donomii chance to include RWKV/rwkv.cpp#74 in go-rwkv.cpp anytime soon ?

@donomii
Copy link
Contributor

donomii commented Jun 1, 2023

I'll do it later today

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/build bug Something isn't working os/macOS
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants