PABannier / bark.cpp

Suno AI's Bark model in C/C++ for fast text-to-speech
MIT License
630 stars 48 forks source link

Mac M1: zsh: illegal hardware instruction ./build/examples/main/main -m ./models/bark-small/ggml_weights.bin -p -t 4 #175

Closed loginid20 closed 1 month ago

loginid20 commented 1 month ago

Apologies for the noob question, but I get the following error when trying to follow the usage instructions in the README.md on my MacBook Pro M1:

zsh: illegal hardware instruction ./build/examples/main/main -m ./models/bark-small/ggml_weights.bin -p -t 4

Can someone point me in a possible direction to rectify?

Thanks

PABannier commented 1 month ago

Hello @loginid20 !

Not a noob question at all! I'm also using an M1 Pro. The Illegal hardware instruction makes me think that you probably built the main executable for the wrong platform (e.g., for an x86 architecture instead of ARM for your MacBook).

This is surprising, you should not have to explicitly specify the platform you are building on.

Could you clean your build folder with rm -rf build, and share with me the output of the command cmake ..?

loginid20 commented 1 month ago

Thank you PABannier,

I followed your instructions and got the following output:

cmake .. cmake --build . --config Release -- The C compiler identification is AppleClang 15.0.0.15000309 -- The CXX compiler identification is AppleClang 15.0.0.15000309 -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Check for working C compiler: /Library/Developer/CommandLineTools/usr/bin/cc - skipped -- Detecting C compile features -- Detecting C compile features - done -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Check for working CXX compiler: /Library/Developer/CommandLineTools/usr/bin/c++ - skipped -- Detecting CXX compile features -- Detecting CXX compile features - done -- Performing Test CMAKE_HAVE_LIBC_PTHREAD -- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success -- Found Threads: TRUE -- CMAKE_SYSTEM_PROCESSOR: x86_64 CMake Warning at encodec.cpp/ggml/src/CMakeLists.txt:37 (message): Your arch is announced as x86_64, but it seems to actually be ARM64. Not fixing that can lead to bad performance. For more info see: https://github.com/ggerganov/whisper.cpp/issues/66#issuecomment-#1282546789

-- x86 detected sysctl: unknown oid 'machdep.cpu.leaf7_features' -- Accelerate framework found -- Configuring done (1.9s) -- Generating done (0.0s) -- Build files have been written to: /Users/XXXX/Documents/Bark/bark.cpp/build [ 6%] Building C object encodec.cpp/ggml/src/CMakeFiles/ggml.dir/ggml.c.o /Users/XXXX/Documents/Bark/bark.cpp/encodec.cpp/ggml/src/ggml.c:2431:5: warning: implicit conversion increases floating-point precision: 'float' to 'ggml_float' (aka 'double') [-Wdouble-promotion] GGML_F16_VEC_REDUCE(sumf, sum); ^~~~~~~~~~ /Users/XXXX/Documents/Bark/bark.cpp/encodec.cpp/ggml/src/ggml.c:2062:37: note: expanded from macro 'GGML_F16_VEC_REDUCE'

define GGML_F16_VEC_REDUCE GGML_F32Cx8_REDUCE

                                ^

/Users/XXXX/Documents/Bark/bark.cpp/encodec.cpp/ggml/src/ggml.c:2052:33: note: expanded from macro 'GGML_F32Cx8_REDUCE'

define GGML_F32Cx8_REDUCE GGML_F32x8_REDUCE

                            ^

/Users/XXXX/Documents/Bark/bark.cpp/encodec.cpp/ggml/src/ggml.c:1998:11: note: expanded from macro 'GGML_F32x8_REDUCE' res = _mm_cvtss_f32(_mm_hadd_ps(t1, t1)); \ ~ ^~~~~~~~~~ /Users/XXXX/Documents/Bark/bark.cpp/encodec.cpp/ggml/src/ggml.c:3691:9: warning: implicit conversion increases floating-point precision: 'float' to 'ggml_float' (aka 'double') [-Wdouble-promotion] GGML_F16_VEC_REDUCE(sumf[k], sum[k]); ^~~~~~~~ /Users/XXXX/Documents/Bark/bark.cpp/encodec.cpp/ggml/src/ggml.c:2062:37: note: expanded from macro 'GGML_F16_VEC_REDUCE'

define GGML_F16_VEC_REDUCE GGML_F32Cx8_REDUCE

                                ^

/Users/XXXX/Documents/Bark/bark.cpp/encodec.cpp/ggml/src/ggml.c:2052:33: note: expanded from macro 'GGML_F32Cx8_REDUCE'

define GGML_F32Cx8_REDUCE GGML_F32x8_REDUCE

                            ^

/Users/XXXX/Documents/Bark/bark.cpp/encodec.cpp/ggml/src/ggml.c:1998:11: note: expanded from macro 'GGML_F32x8_REDUCE' res = _mm_cvtss_f32(_mm_hadd_ps(t1, t1)); \ ~ ^~~~~~~~~~ /Users/XXXX/Documents/Bark/bark.cpp/encodec.cpp/ggml/src/ggml.c:11934:17: warning: 'cblas_sgemm' is deprecated: first deprecated in macOS 13.3 - An updated CBLAS interface supporting ILP64 is available. Please compile with -DACCELERATE_NEW_LAPACK to access the new headers and -DACCELERATE_LAPACK_ILP64 for ILP64 support. [-Wdeprecated-declarations] cblas_sgemm(CblasRowMajor, CblasNoTrans, CblasTrans, ^ /Library/Developer/CommandLineTools/SDKs/MacOSX14.4.sdk/System/Library/Frameworks/vecLib.framework/Headers/cblas.h:610:6: note: 'cblas_sgemm' has been explicitly marked deprecated here void cblas_sgemm(const enum CBLAS_ORDER __Order, ^ 3 warnings generated. [ 12%] Building C object encodec.cpp/ggml/src/CMakeFiles/ggml.dir/ggml-alloc.c.o [ 18%] Building C object encodec.cpp/ggml/src/CMakeFiles/ggml.dir/ggml-backend.c.o [ 25%] Linking C shared library libggml.dylib [ 25%] Built target ggml [ 31%] Building CXX object encodec.cpp/CMakeFiles/encodec.dir/encodec.cpp.o [ 37%] Linking CXX static library libencodec.a [ 37%] Built target encodec [ 43%] Building CXX object CMakeFiles/bark.dir/bark.cpp.o [ 50%] Linking CXX static library libbark.a [ 50%] Built target bark [ 56%] Building CXX object examples/CMakeFiles/common.dir/common.cpp.o [ 62%] Linking CXX static library libcommon.a [ 62%] Built target common [ 68%] Building CXX object examples/main/CMakeFiles/main.dir/main.cpp.o [ 75%] Linking CXX executable main [ 75%] Built target main [ 81%] Building CXX object examples/server/CMakeFiles/server.dir/server.cpp.o [ 87%] Linking CXX executable server [ 87%] Built target server [ 93%] Building CXX object examples/quantize/CMakeFiles/quantize.dir/main.cpp.o [100%] Linking CXX executable quantize [100%] Built target quantize

--

There seems to be discussion about old homebrew installations here, which may be the culprit for me: https://github.com/ggerganov/whisper.cpp/issues/66#issuecomment-#1282546789

I will reinstall homebrew and will report back if that solves the issue for me.

Thanks

loginid20 commented 1 month ago

ok - I got it working.

If it helps someone else: I had previously installed an older version of Homebrew when this machine was new, which at that time required using Rosetta 2.

I uninstalled Homebrew from /usr/local and installed it in /opt/homebrew, and made sure to uncheck 'Open using Rosetta' under the Get Info panel for my terminal.app.

Running 'uname - m' in the terminal now reports 'arm64' (it reported 'x86' before I made these changes) and installing bark.cpp as described in the README.md works without error

PABannier commented 1 month ago

Brilliant @loginid20 ! Thanks for letting us know. Closing this issue as this is solved.