Repository navigation
Open
Description
As title, I can not build the project on Raspberry Pi 4 with Raspberry Pi OS (Debian 12 (bookworm)) and gcc 12.
command: python setup_env.py -md models/BitNet-b1.58-2B-4T -q i2_s
[ 1%] Building CXX object 3rdparty/llama.cpp/ggml/src/CMakeFiles/ggml.dir/__/__/__/__/src/ggml-bitnet-mad.cpp.o
In file included from /home/a91249061/BitNet/3rdparty/llama.cpp/ggml/src/./ggml-quants.h:4,
from /home/a91249061/BitNet/src/ggml-bitnet-mad.cpp:5:
/home/a91249061/BitNet/3rdparty/llama.cpp/ggml/src/./ggml-common.h:154:16: warning: ISO C++ prohibits anonymous structs [-Wpedantic]
154 | struct {
| ^
/home/a91249061/BitNet/3rdparty/llama.cpp/ggml/src/./ggml-common.h:175:16: warning: ISO C++ prohibits anonymous structs [-Wpedantic]
175 | struct {
| ^
/home/a91249061/BitNet/3rdparty/llama.cpp/ggml/src/./ggml-common.h:196:16: warning: ISO C++ prohibits anonymous structs [-Wpedantic]
196 | struct {
| ^
/home/a91249061/BitNet/3rdparty/llama.cpp/ggml/src/./ggml-common.h:261:16: warning: ISO C++ prohibits anonymous structs [-Wpedantic]
261 | struct {
| ^
/home/a91249061/BitNet/3rdparty/llama.cpp/ggml/src/./ggml-common.h:294:16: warning: ISO C++ prohibits anonymous structs [-Wpedantic]
294 | struct {
| ^
/home/a91249061/BitNet/3rdparty/llama.cpp/ggml/src/./ggml-common.h:311:16: warning: ISO C++ prohibits anonymous structs [-Wpedantic]
311 | struct {
| ^
/home/a91249061/BitNet/src/ggml-bitnet-mad.cpp: In function ‘size_t quantize_i2_s(const float*, void*, int64_t, int64_t, const float*)’:
/home/a91249061/BitNet/src/ggml-bitnet-mad.cpp:46:100: warning: unused parameter ‘quant_weights’ [-Wunused-parameter]
46 | size_t quantize_i2_s(const float * src, void * dst, int64_t nrow, int64_t n_per_row, const float * quant_weights) {
| ~~~~~~~~~~~~~~^~~~~~~~~~~~~
/home/a91249061/BitNet/src/ggml-bitnet-mad.cpp: In function ‘void ggml_vec_dot_i2_i8_s(int, float*, size_t, const void*, size_t, const void*, size_t, int)’:
/home/a91249061/BitNet/src/ggml-bitnet-mad.cpp:95:28: warning: cast from type ‘const void*’ to type ‘uint8_t*’ {aka ‘unsigned char*’} casts away qualifiers [-Wcast-qual]
95 | const uint8_t * x = (uint8_t *)vx;
| ^~~~~~~~~~~~~
/home/a91249061/BitNet/src/ggml-bitnet-mad.cpp:96:28: warning: cast from type ‘const void*’ to type ‘int8_t*’ {aka ‘signed char*’} casts away qualifiers [-Wcast-qual]
96 | const int8_t * y = (int8_t *)vy;
| ^~~~~~~~~~~~
/home/a91249061/BitNet/src/ggml-bitnet-mad.cpp:94:52: warning: unused parameter ‘bs’ [-Wunused-parameter]
94 | void ggml_vec_dot_i2_i8_s(int n, float * s, size_t bs, const void * vx, size_t bx, const void * vy, size_t by, int nrc) {
| ~~~~~~~^~
/home/a91249061/BitNet/src/ggml-bitnet-mad.cpp:94:80: warning: unused parameter ‘bx’ [-Wunused-parameter]
94 | void ggml_vec_dot_i2_i8_s(int n, float * s, size_t bs, const void * vx, size_t bx, const void * vy, size_t by, int nrc) {
| ~~~~~~~^~
/home/a91249061/BitNet/src/ggml-bitnet-mad.cpp:94:108: warning: unused parameter ‘by’ [-Wunused-parameter]
94 | void ggml_vec_dot_i2_i8_s(int n, float * s, size_t bs, const void * vx, size_t bx, const void * vy, size_t by, int nrc) {
| ~~~~~~~^~
/home/a91249061/BitNet/src/ggml-bitnet-mad.cpp:94:116: warning: unused parameter ‘nrc’ [-Wunused-parameter]
94 | void ggml_vec_dot_i2_i8_s(int n, float * s, size_t bs, const void * vx, size_t bx, const void * vy, size_t by, int nrc) {
| ~~~~^~~
during GIMPLE pass: vect
/home/a91249061/BitNet/src/ggml-bitnet-mad.cpp: In function ‘size_t quantize_i2_s(const float*, void*, int64_t, int64_t, const float*)’:
/home/a91249061/BitNet/src/ggml-bitnet-mad.cpp:46:8: internal compiler error: in vect_transform_reduction, at tree-vect-loop.cc:7457
46 | size_t quantize_i2_s(const float * src, void * dst, int64_t nrow, int64_t n_per_row, const float * quant_weights) {
| ^~~~~~~~~~~~~
0x7f90e8773f __libc_start_call_main
../sysdeps/nptl/libc_start_call_main.h:58
0x7f90e87817 __libc_start_main_impl
../csu/libc-start.c:360
Please submit a full bug report, with preprocessed source (by using -freport-bug).
Please include the complete backtrace with any bug report.
See <file:///usr/share/doc/gcc-12/README.Bugs> for instructions.
gmake[2]: *** [3rdparty/llama.cpp/ggml/src/CMakeFiles/ggml.dir/build.make:132: 3rdparty/llama.cpp/ggml/src/CMakeFiles/ggml.dir/__/__/__/__/src/ggml-bitnet-mad.cpp.o] Error 1
gmake[1]: *** [CMakeFiles/Makefile2:759: 3rdparty/llama.cpp/ggml/src/CMakeFiles/ggml.dir/all] Error 2
gmake: *** [Makefile:136: all] Error 2
Metadata
Metadata
Assignees
Labels
No labels
Activity
Benjamin-Wegener commentedon Apr 28, 2025
try
cmake .. -DCMAKE_CXX_FLAGS="-O2"This avoids the crash by reducing optimization level and skipping problematic vectorization.
ping-ee commentedon Apr 29, 2025
Neither the compile flag
-DCMAKE_CXX_FLAGS=-O2nor-DCMAKE_CXX_FLAGS_RELEASE="-O2 -DNDEBUG"works for me.ping-ee commentedon Apr 29, 2025
I followed steps 5 and 6 mentioned on this page instead of running
setup_env.py, and it works.worldbiomusic commentedon May 1, 2025
It works. Thank you💖💖
Zodijackyl98 commentedon Feb 8, 2026
I followed everything I found on the internet and tried to solve the issue with the help of multiple AI agents but still I end up getting the same error. I don't think there is a hardware wall that I can't overcome since there are people ran BitNet on Pi 4
like the one I have. So far I've tried these;
~/BitNet/3rdparty/llama.cpp/ggml/src/ggml-quants.cHere is the error;
-- Performing Test COMPILER_SUPPORTS_ARMV82_DOTPROD - Successsince the CPU does not support dotprod and i8mm it behaves as if it supports.Here is the ouput after compiling;
lepus2589 commentedon Feb 22, 2026
I encountered the
SIGILLsignal (illegal instruction), too. I tried to build the latestmain(8fd3412) on the latest Raspberry Pi OS from December 2025 based on Debian 13 (Trixie).This gives you Clang/LLVM v19 and Python v3.13. Which unfortunately meant, that I had to build Python v3.12 from source, as the PyTorch version required by the BitNet project only works for Python<=3.12.
But after I solved that problem, I followed the steps from Bijan Bowen's (Bijan Bowen (@OminousIndustries)) BitNet b1.58 on Raspberry Pi 4B blog post. After setting up the Python virtual environment, I did:
Generating the header and config files with the command from setup_env.py#L180:
Building with CMake:
Running
python run_inference.py ...caused theSIGILLerror.Because some SO answers pointed to a problem with the
armv8-a+lseextension being assumed but unavailable on the Pi 4B, I even configured the complete arch and cpu info in CMake like this:But that didn't help.
Next, I tried to checkout a revision from the approximate time of Bijan Bowen's blog post. I decided for c17d1c5, as it already had the inference server and the model architecture name fix in it. I deleted the
./builddirectory, regenerated the header files and rebuilt with CMake and, voilà, it worked!I decided to do a
git bisectand it turns out, that the commit introducing this regression is c17d1c5. The last commit working on the RPi 4B is 404980e.So, for anyone trying this in 2026, do this after cloning the repository:
Mert Yasin Şafak (@Zodijackyl98) Your AIs might be onto something there. The
GGML_COMPILER_SUPPORT_DOTPRODtry_compile()done by the3rdparty/llama.cpp/ggml/src/CMakeLists.txtfirst tests, if thedotprodextension is supported by the target system. If you are on a system with anarmv8.2-a+dotprodarch, this should succeed and simply add the respective pre-processor define. If it fails (as it does on RPi 4B), we follow up with theCOMPILER_SUPPORTS_ARMV82_DOTPRODtest to see, if the compiler supports the-march=armv8.2-a+dotprodflag (so basically, if you could cross-compile for such a system). If that succeeds, we explicitly set the-march=armv8.2-a+dotprodflag (and thus are now basically cross-compiling for such a CPU). If you are on aarmv8-a(like the RPi 4B) and your compiler supports cross-compiling forarmv8.2-a+dotprod(whichclang-19apparently does), you are now cross-compiling for such a system instead of compiling for your host system. Coincidentally, thistry_compile()block was introduced in the "bad" commit.Now, that I was explicitly looking for it, I actually saw the
-march=armv8.2-a+dotprodgiven to the compiler. No wonder, it produces invalid instructions.I think, the complete
COMPILER_SUPPORTS_ARMV82_DOTPRODtest needs to go. It only tests the cross-compile capability of the compiler, which doesn't help at all determining the capabilities of the target system:I tried this on
mainand it compiles and runs, but now it produces gibberish when running inference. This looks like what is described in #411.Until these bugs are fixed, the "good" commit above is the only thing that works.