BitNet icon indicating copy to clipboard operation
BitNet copied to clipboard

direct cpp compilation on aarch64-ostl-linux-gcc failed

Open danilopau opened this issue 1 year ago • 5 comments

tried to compile the routines unsuccefully

would you please hlp ?

(bitnet-cpp) triumph@triumph-HP-Z6-G5-Workstation-Desktop-PC:~/github/BitNet/src$ $CC aarch64-ostl-linux-gcc: fatal error: no input files

bitnet-cpp) triumph@triumph-HP-Z6-G5-Workstation-Desktop-PC:~/github/BitNet/src$ $CC ggml-bitnet-mad.cpp ggml-bitnet-lut.cpp -I ../include -I ../3rdparty/llama.cpp/ggml/include/ -I ../3rdparty/llama.cpp/ggml/src/ -o bitnet /home/triumph/STM32MPU-Ecosystem-v5.1.0/Developer-Package/SDK/sysroots/x86_64-ostl_sdk-linux/usr/libexec/aarch64-ostl-linux/gcc/aarch64-ostl-linux/12.3.0/ld: /home/triumph/STM32MPU-Ecosystem-v5.1.0/Developer-Package/SDK/sysroots/cortexa35-ostl-linux/usr/lib/crt1.o: in function _start': /usr/src/debug/glibc/2.37-r1/csu/../sysdeps/aarch64/start.S:110: undefined reference to main' /home/triumph/STM32MPU-Ecosystem-v5.1.0/Developer-Package/SDK/sysroots/x86_64-ostl_sdk-linux/usr/libexec/aarch64-ostl-linux/gcc/aarch64-ostl-linux/12.3.0/ld: /tmp/ccFRcgOi.o: in function quantize_i2_s': ggml-bitnet-mad.cpp:(.text+0x28): undefined reference to ggml_row_size' /home/triumph/STM32MPU-Ecosystem-v5.1.0/Developer-Package/SDK/sysroots/x86_64-ostl_sdk-linux/usr/libexec/aarch64-ostl-linux/gcc/aarch64-ostl-linux/12.3.0/ld: ggml-bitnet-mad.cpp:(.text+0x74): undefined reference to `fmax' collect2: error: ld returned 1 exit status

danilopau avatar Oct 21 '24 12:10 danilopau

I tried to cross compile your project with aarch64-ostl-linux-gcc and aarch64-ostl-linux-g++ compilers and the does end with errors no matter how I try to compiled the project. While I did it succesfully with llama.cpp.

The point is to allow aarch64-ostl-linux-gcc compilation instead of with clang

danilopau avatar Oct 22 '24 08:10 danilopau

I was installing it on a rpi 5 and got some similar issues:

@danilopau maybe those steps work for you.

My compiling errors include/bitnet-lut-kernels.h:12:5: error: use of undeclared identifier 'posix_memalign' include/bitnet-lut-kernels.h:289:5: error: use of undeclared identifier 'memset'

My fix: edit BitNet/include/bitnet-lut-kernels.h

/* Add includes */
#include <string.h>
#include <malloc.h>
...
#if defined(_WIN32)
    return _aligned_malloc(size, 64);
#else
    void * ptr = nullptr;
    /* Change the following line from posix_memalign to malloc memalign */
    // posix_memalign(&ptr, 64, size);
    ptr = memalign(64, size);
    return ptr;
#endif

Then build: cmake --build build --config Release

I published a blog post with all steps and recorded a video demonstrating it working: https://www.eddieoz.com/building-bitnet-on-raspberry-pi-5-arm64-2/

Check if in your case is enough by adding the #include <string.h>. Although I updated cmake and clang on my rpi5 also.

eddieoz avatar Oct 23 '24 10:10 eddieoz

STM32MP2 is the processor I am using

The error is now

root@stm32mp2:~/extra/BitNet# python3 setup_env.py --hf-repo HF1BitLLM/Llama3-8B-1.58-100B-tokens -q i2_s INFO:root:Compiling the code using CMake. ERROR:root:Error occurred while running command: Command '['cmake', '-B', 'build', '-DBITNET_ARM_TL1=ON', '-DCMAKE_C_COMPILER=clang', '-DCMAKE_CXX_COMPILER=clang++']' returned non-zero exit status 1., check details in logs/generate_build_files.log

root@stm32mp2:~/extra/BitNet# more logs/generate_build_files.log CMake Error: CMake was unable to find a build program corresponding to "Unix Makefiles". CMAKE_MAKE_PROGRAM is not set. You probably need to select a different build tool. -- Configuring incomplete, errors occurred!

danilopau avatar Oct 31 '24 11:10 danilopau

root@stm32mp2:~/extra/BitNet# cmake --build build --config Release no such file or directory CMake Error: Generator: execution of make failed. Make command was: -f Makefile

danilopau avatar Oct 31 '24 11:10 danilopau