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

libopenblas, OpenBlas, cblas.h unavailable to link during make #1174

Closed
ghost opened this issue Apr 25, 2023 · 3 comments
Closed

libopenblas, OpenBlas, cblas.h unavailable to link during make #1174

ghost opened this issue Apr 25, 2023 · 3 comments

Comments

@ghost
Copy link

ghost commented Apr 25, 2023

Hi, I want to compile llama.cpp with blas in termux.

Expected Behavior

Currently, I use make LLAMA_OPENBLAS=1, and it fails to make. I expect it to locate one of the libraries for blas:

libopenblas/stable,now 0.3.23 aarch64 [installed],

or

openblas-static/termux,now 0.3.7 aarch64 [installed].

Alternatively, I also have:
$HOME/OpenBLAS-0.3.23

Current Behavior

'make LLAMA_OPENBLAS=1
I llama.cpp build info:
I UNAME_S: Linux
I UNAME_P: unknown
I UNAME_M: aarch64
I CFLAGS: -I. -O3 -DNDEBUG -std=c11 -fPIC -Wall -Wextra -Wpedantic -Wcast-qual -Wdouble-promotion -Wshadow -Wstrict-prototypes -Wpointer-arith -pthread -DGGML_USE_OPENBLAS -I/usr/local/include/openblas -mcpu=native
I CXXFLAGS: -I. -I./examples -O3 -DNDEBUG -std=c++11 -fPIC -Wall -Wextra -Wpedantic -Wcast-qual -Wno-unused-function -Wno-multichar -pthread -mcpu=native
I LDFLAGS: -lopenblas
I CC: clang version 16.0.2
I CXX: clang version 16.0.2

cc -I. -O3 -DNDEBUG -std=c11 -fPIC -Wall -Wextra -Wpedantic -Wcast-qual -Wdouble-promotion -Wshadow -Wstrict-prototypes -Wpointer-arith -pthread -DGGML_USE_OPENBLAS -I/usr/local/include/openblas -mcpu=native -c ggml.c -o ggml.o
ggml.c:149:10: fatal error: 'cblas.h' file not found
#include <cblas.h>
^~~~~~~~~
1 error generated.
make: *** [Makefile:161: ggml.o] Error 1'

Environment and Context

Please provide detailed information about your computer setup. This is important in case the issue is not reproducible except for under certain specific conditions.

  • Physical (or virtual) hardware you are using, e.g. for Linux:

Architecture: aarch64
CPU op-mode(s): 32-bit, 64-bit
Byte Order: Little Endian
CPU(s): 8
On-line CPU(s) list: 0-7
Vendor ID: Qualcomm
Model name: -
Model: 14
Thread(s) per core: 1
Core(s) per socket: 4
Socket(s): 1
Stepping: 0xd
CPU(s) scaling MHz: 100%
CPU max MHz: 1785.6000
CPU min MHz: 300.0000
BogoMIPS: 38.40
Flags: fp asimd evtstrm aes pm
ull sha1 sha2 crc32 ato
mics fphp asimdhp cpuid
asimdrdm lrcpc dcpop a
simddp
Model name: -
Model: 14
Thread(s) per core: 1
Core(s) per socket: 2
Socket(s): 2
Stepping: 0xd
CPU(s) scaling MHz: 100%
CPU max MHz: 2841.6001
CPU min MHz: 710.4000
BogoMIPS: 38.40
Flags: fp asimd evtstrm aes pm
ull sha1 sha2 crc32 ato
mics fphp asimdhp cpuid
asimdrdm lrcpc dcpop a
simddp

  • Operating System, e.g. for Linux:

Linux localhost 4.14.190-23725627-abG975WVLS8IWA1 #2 SMP PREEMPT Mon Jan 16 15:43:02 KST 2023 aarch64 Android

Steps to Reproduce

  1. Use termux to move llama.cpp to $HOME
  2. Cd then cd llama.cpp
  3. make LLAMA_OPENBLAS =1
@slaren
Copy link
Collaborator

slaren commented Apr 25, 2023

You can use cmake for better detection of the OpenBLAS location. If you insist on using make, just modify the Makefile to point it to the right location.

@ghost
Copy link
Author

ghost commented Apr 25, 2023

You can use cmake for better detection of the OpenBLAS location. If you insist on using make, just modify the Makefile to point it to the right location.

Thanks for your response. My apologies, I accidentally closed the issue while figuring out how to use github ui.

I compiled with cmake LLAMA_OPENBLAS=1 llama.cpp. It appeared to work, but it doesn't create a main file, so I dunno how to run it to test if blas is working. Please excuse my ignorance!

I edit the MAKEFILE line 104 to 'CFLAGS += -DGGML_USE_OPENBLAS /data/data/com.termux/files/usr/lib/'

Also tried 'CFLAGS += -DGGML_USE_OPENBLAS /data/data/com.termux/files/usr/lib/libopenblas_armv8p-r0.3.7.a'

And 'CFLAGS += -DGGML_USE_OPENBLAS /data/data/com.termux/files/home/OpenBLAS-0.3.23'

But I'm still receiving the same error message during make.

'clang-16: warning: /data/data/com.termux/files/home/OpenBLAS-0.3.23: 'linker' input unused [-Wunused-command-line-argument]
ggml.c:149:10: fatal error: 'cblas.h' file not found'

Thanks for any direction.

@ghost ghost closed this as completed Apr 25, 2023
@ghost ghost reopened this Apr 25, 2023
@ghost
Copy link
Author

ghost commented Apr 25, 2023

Hi,

editing the MAKEFILE line 104 to CFLAGS += -DGGML_USE_OPENBLAS -I/data/data/com.termux/files/usr/include/openblas

Allowed me to compile and now BLAS is working as expected. Thanks!

@ghost ghost closed this as completed Apr 25, 2023
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant