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

[User] Android build fails with "ld.lld: error: undefined symbol: clGetPlatformIDs" #3525

Closed
4 tasks done
Mabbs opened this issue Oct 7, 2023 · 17 comments
Closed
4 tasks done
Labels
android Issues specific to Android build Compilation issues

Comments

@Mabbs
Copy link

Mabbs commented Oct 7, 2023

Prerequisites

Please answer the following questions for yourself before submitting an issue.

  • I am running the latest code. Development is very rapid so there are no tagged versions as of now.
  • I carefully followed the README.md.
  • I searched using keywords relevant to my issue to make sure that I am creating a new issue that is not already open (or closed).
  • I reviewed the Discussions, and have a new bug or useful enhancement to share.

Expected Behavior

I am trying to use this tutorial to compile llama.cpp.

Current Behavior

Compilation failed.

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: Kryo-V2
Model: 4
Thread(s) per core: 1
Core(s) per socket: 4
Socket(s): 1
Stepping: 0xa
CPU(s) scaling MHz: 100%
CPU max MHz: 1900.8000
CPU min MHz: 300.0000
BogoMIPS: 38.00
Flags: fp asimd evtstrm aes pmull sha1 sha2 crc32
Model name: Falkor-V1/Kryo
Model: 1
Thread(s) per core: 1
Core(s) per socket: 4
Socket(s): 1
Stepping: 0xa
CPU(s) scaling MHz: 96%
CPU max MHz: 2457.6001
CPU min MHz: 300.0000
BogoMIPS: 38.00
Flags: fp asimd evtstrm aes pmull sha1 sha2 crc32
Caches (sum of all):
L1d: 384 KiB (8 instances)
L1i: 384 KiB (8 instances)
L2: 3 MiB (2 instances)

  • Operating System, e.g. for Linux:

Linux localhost 4.4.207-perf-g4f4b497d7bf8 #1 SMP PREEMPT Wed Dec 25 02:26:18 CST 2019 aarch64 Android

  • SDK version, e.g. for Linux:

GNU Make 4.4.1
Built for aarch64-unknown-linux-android
Copyright (C) 1988-2023 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later https://gnu.org/licenses/gpl.html
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
clang version 17.0.2
Target: aarch64-unknown-linux-android24
Thread model: posix
InstalledDir: /data/data/com.termux/files/usr/bin

Steps to Reproduce

Follow the tutorial step by step.

Failure Logs

~/llama.cpp $ make LLAMA_CLBLAST=1
Package clblast was not found in the pkg-config search path.
Perhaps you should add the directory containing `clblast.pc'
to the PKG_CONFIG_PATH environment variable
No package 'clblast' found
Package clblast was not found in the pkg-config search path.
Perhaps you should add the directory containing `clblast.pc'
to the PKG_CONFIG_PATH environment variable
No package 'clblast' found
Package clblast was not found in the pkg-config search path.
Perhaps you should add the directory containing `clblast.pc'
to the PKG_CONFIG_PATH environment variable
No package 'clblast' found
Package clblast was not found in the pkg-config search path.
Perhaps you should add the directory containing `clblast.pc'
to the PKG_CONFIG_PATH environment variable
No package 'clblast' found
Package clblast was not found in the pkg-config search path.
Perhaps you should add the directory containing `clblast.pc'
to the PKG_CONFIG_PATH environment variable
No package 'clblast' found
I llama.cpp build info: 
I UNAME_S:   Linux
I UNAME_P:   unknown
I UNAME_M:   aarch64
I CFLAGS:    -I. -Icommon -D_XOPEN_SOURCE=600 -D_GNU_SOURCE -DNDEBUG -DGGML_USE_K_QUANTS -DGGML_USE_CLBLAST   -std=c11   -fPIC -O3 -Wall -Wextra -Wpedantic -Wcast-qual -Wno-unused-function -Wshadow -Wstrict-prototypes -Wpointer-arith -Wmissing-prototypes -Werror=implicit-int -Werror=implicit-function-declaration -Wunreachable-code-break -Wunreachable-code-return -Wdouble-promotion -pthread -mcpu=native  
I CXXFLAGS:  -I. -Icommon -D_XOPEN_SOURCE=600 -D_GNU_SOURCE -DNDEBUG -DGGML_USE_K_QUANTS -DGGML_USE_CLBLAST   -std=c++11 -fPIC -O3 -Wall -Wextra -Wpedantic -Wcast-qual -Wno-unused-function -Wmissing-declarations -Wmissing-noreturn -pthread -mcpu=native   -Wunreachable-code-break -Wunreachable-code-return -Wmissing-prototypes -Wextra-semi 
I NVCCFLAGS:  -I. -Icommon -D_XOPEN_SOURCE=600 -D_GNU_SOURCE -DNDEBUG -DGGML_USE_K_QUANTS -DGGML_USE_CLBLAST   -std=c++11 -fPIC -O3 -Wall -Wextra -Wpedantic -Wcast-qual -Wno-unused-function -Wmissing-declarations -Wmissing-noreturn -pthread -mcpu=native     -Wno-pedantic -Xcompiler "-Wunreachable-code-break -Wunreachable-code-return -Wmissing-prototypes -Wextra-semi "
I LDFLAGS:    
I CC:        clang version 17.0.2
I CXX:       clang version 17.0.2

cc  -I. -Icommon -D_XOPEN_SOURCE=600 -D_GNU_SOURCE -DNDEBUG -DGGML_USE_K_QUANTS -DGGML_USE_CLBLAST   -std=c11   -fPIC -O3 -Wall -Wextra -Wpedantic -Wcast-qual -Wno-unused-function -Wshadow -Wstrict-prototypes -Wpointer-arith -Wmissing-prototypes -Werror=implicit-int -Werror=implicit-function-declaration -Wunreachable-code-break -Wunreachable-code-return -Wdouble-promotion -pthread -mcpu=native     -c ggml.c -o ggml.o
ggml.c:2456:5: warning: implicit conversion increases floating-point precision: 'float32_t' (aka 'float') to 'ggml_float' (aka 'double') [-Wdouble-promotion]
 2456 |     GGML_F16_VEC_REDUCE(sumf, sum);
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ggml.c:1983:41: note: expanded from macro 'GGML_F16_VEC_REDUCE'
 1983 |     #define GGML_F16_VEC_REDUCE         GGML_F32Cx4_REDUCE
      |                                         ^
ggml.c:1973:38: note: expanded from macro 'GGML_F32Cx4_REDUCE'
 1973 |     #define GGML_F32Cx4_REDUCE       GGML_F32x4_REDUCE
      |                                      ^
ggml.c:1903:11: note: expanded from macro 'GGML_F32x4_REDUCE'
 1903 |     res = GGML_F32x4_REDUCE_ONE(x[0]);         \
      |         ~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~
ggml.c:1888:34: note: expanded from macro 'GGML_F32x4_REDUCE_ONE'
 1888 | #define GGML_F32x4_REDUCE_ONE(x) vaddvq_f32(x)
      |                                  ^~~~~~~~~~~~~
ggml.c:3716:9: warning: implicit conversion increases floating-point precision: 'float32_t' (aka 'float') to 'ggml_float' (aka 'double') [-Wdouble-promotion]
 3716 |         GGML_F16_VEC_REDUCE(sumf[k], sum[k]);
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ggml.c:1983:41: note: expanded from macro 'GGML_F16_VEC_REDUCE'
 1983 |     #define GGML_F16_VEC_REDUCE         GGML_F32Cx4_REDUCE
      |                                         ^
ggml.c:1973:38: note: expanded from macro 'GGML_F32Cx4_REDUCE'
 1973 |     #define GGML_F32Cx4_REDUCE       GGML_F32x4_REDUCE
      |                                      ^
ggml.c:1903:11: note: expanded from macro 'GGML_F32x4_REDUCE'
 1903 |     res = GGML_F32x4_REDUCE_ONE(x[0]);         \
      |         ~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~
ggml.c:1888:34: note: expanded from macro 'GGML_F32x4_REDUCE_ONE'
 1888 | #define GGML_F32x4_REDUCE_ONE(x) vaddvq_f32(x)
      |                                  ^~~~~~~~~~~~~
2 warnings generated.
aarch64-linux-android-clang++ -I. -Icommon -D_XOPEN_SOURCE=600 -D_GNU_SOURCE -DNDEBUG -DGGML_USE_K_QUANTS -DGGML_USE_CLBLAST   -std=c++11 -fPIC -O3 -Wall -Wextra -Wpedantic -Wcast-qual -Wno-unused-function -Wmissing-declarations -Wmissing-noreturn -pthread -mcpu=native   -Wunreachable-code-break -Wunreachable-code-return -Wmissing-prototypes -Wextra-semi  -c llama.cpp -o llama.o
aarch64-linux-android-clang++ -I. -Icommon -D_XOPEN_SOURCE=600 -D_GNU_SOURCE -DNDEBUG -DGGML_USE_K_QUANTS -DGGML_USE_CLBLAST   -std=c++11 -fPIC -O3 -Wall -Wextra -Wpedantic -Wcast-qual -Wno-unused-function -Wmissing-declarations -Wmissing-noreturn -pthread -mcpu=native   -Wunreachable-code-break -Wunreachable-code-return -Wmissing-prototypes -Wextra-semi  -c common/common.cpp -o common.o
aarch64-linux-android-clang++ -I. -Icommon -D_XOPEN_SOURCE=600 -D_GNU_SOURCE -DNDEBUG -DGGML_USE_K_QUANTS -DGGML_USE_CLBLAST   -std=c++11 -fPIC -O3 -Wall -Wextra -Wpedantic -Wcast-qual -Wno-unused-function -Wmissing-declarations -Wmissing-noreturn -pthread -mcpu=native   -Wunreachable-code-break -Wunreachable-code-return -Wmissing-prototypes -Wextra-semi  -c common/console.cpp -o console.o
aarch64-linux-android-clang++ -I. -Icommon -D_XOPEN_SOURCE=600 -D_GNU_SOURCE -DNDEBUG -DGGML_USE_K_QUANTS -DGGML_USE_CLBLAST   -std=c++11 -fPIC -O3 -Wall -Wextra -Wpedantic -Wcast-qual -Wno-unused-function -Wmissing-declarations -Wmissing-noreturn -pthread -mcpu=native   -Wunreachable-code-break -Wunreachable-code-return -Wmissing-prototypes -Wextra-semi  -c common/grammar-parser.cpp -o grammar-parser.o
cc -I. -Icommon -D_XOPEN_SOURCE=600 -D_GNU_SOURCE -DNDEBUG -DGGML_USE_K_QUANTS -DGGML_USE_CLBLAST   -std=c11   -fPIC -O3 -Wall -Wextra -Wpedantic -Wcast-qual -Wno-unused-function -Wshadow -Wstrict-prototypes -Wpointer-arith -Wmissing-prototypes -Werror=implicit-int -Werror=implicit-function-declaration -Wunreachable-code-break -Wunreachable-code-return -Wdouble-promotion -pthread -mcpu=native   -c k_quants.c -o k_quants.o
aarch64-linux-android-clang++ -I. -Icommon -D_XOPEN_SOURCE=600 -D_GNU_SOURCE -DNDEBUG -DGGML_USE_K_QUANTS -DGGML_USE_CLBLAST   -std=c++11 -fPIC -O3 -Wall -Wextra -Wpedantic -Wcast-qual -Wno-unused-function -Wmissing-declarations -Wmissing-noreturn -pthread -mcpu=native   -Wunreachable-code-break -Wunreachable-code-return -Wmissing-prototypes -Wextra-semi  -c ggml-opencl.cpp -o ggml-opencl.o
cc  -I. -Icommon -D_XOPEN_SOURCE=600 -D_GNU_SOURCE -DNDEBUG -DGGML_USE_K_QUANTS -DGGML_USE_CLBLAST   -std=c11   -fPIC -O3 -Wall -Wextra -Wpedantic -Wcast-qual -Wno-unused-function -Wshadow -Wstrict-prototypes -Wpointer-arith -Wmissing-prototypes -Werror=implicit-int -Werror=implicit-function-declaration -Wunreachable-code-break -Wunreachable-code-return -Wdouble-promotion -pthread -mcpu=native     -c ggml-alloc.c -o ggml-alloc.o
aarch64-linux-android-clang++ -I. -Icommon -D_XOPEN_SOURCE=600 -D_GNU_SOURCE -DNDEBUG -DGGML_USE_K_QUANTS -DGGML_USE_CLBLAST   -std=c++11 -fPIC -O3 -Wall -Wextra -Wpedantic -Wcast-qual -Wno-unused-function -Wmissing-declarations -Wmissing-noreturn -pthread -mcpu=native   -Wunreachable-code-break -Wunreachable-code-return -Wmissing-prototypes -Wextra-semi  examples/main/main.cpp ggml.o llama.o common.o console.o grammar-parser.o k_quants.o ggml-opencl.o ggml-alloc.o -o main  
ld.lld: error: undefined symbol: clGetPlatformIDs
>>> referenced by ggml-opencl.cpp
>>>               ggml-opencl.o:(ggml_cl_init)

ld.lld: error: undefined symbol: clGetPlatformInfo
>>> referenced by ggml-opencl.cpp
>>>               ggml-opencl.o:(ggml_cl_init)
>>> referenced by ggml-opencl.cpp
>>>               ggml-opencl.o:(ggml_cl_init)

ld.lld: error: undefined symbol: clGetDeviceIDs
>>> referenced by ggml-opencl.cpp
>>>               ggml-opencl.o:(ggml_cl_init)

ld.lld: error: undefined symbol: clGetDeviceInfo
>>> referenced by ggml-opencl.cpp
>>>               ggml-opencl.o:(ggml_cl_init)
>>> referenced by ggml-opencl.cpp
>>>               ggml-opencl.o:(ggml_cl_init)
>>> referenced by ggml-opencl.cpp
>>>               ggml-opencl.o:(ggml_cl_init)
>>> referenced 1 more times

ld.lld: error: undefined symbol: clCreateContext
>>> referenced by ggml-opencl.cpp
>>>               ggml-opencl.o:(ggml_cl_init)

ld.lld: error: undefined symbol: clCreateCommandQueue
>>> referenced by ggml-opencl.cpp
>>>               ggml-opencl.o:(ggml_cl_init)
>>> referenced by ggml-opencl.cpp
>>>               ggml-opencl.o:(ggml_cl_init)

ld.lld: error: undefined symbol: clCreateProgramWithSource
>>> referenced by ggml-opencl.cpp
>>>               ggml-opencl.o:(ggml_cl_init)

ld.lld: error: undefined symbol: clBuildProgram
>>> referenced by ggml-opencl.cpp
>>>               ggml-opencl.o:(ggml_cl_init)

ld.lld: error: undefined symbol: clCreateKernel
>>> referenced by ggml-opencl.cpp
>>>               ggml-opencl.o:(ggml_cl_init)
>>> referenced by ggml-opencl.cpp
>>>               ggml-opencl.o:(ggml_cl_init)
>>> referenced by ggml-opencl.cpp
>>>               ggml-opencl.o:(ggml_cl_init)
>>> referenced 21 more times

ld.lld: error: undefined symbol: clGetProgramBuildInfo
>>> referenced by ggml-opencl.cpp
>>>               ggml-opencl.o:(ggml_cl_init)
>>> referenced by ggml-opencl.cpp
>>>               ggml-opencl.o:(ggml_cl_init)

ld.lld: error: undefined symbol: clReleaseMemObject
>>> referenced by ggml-opencl.cpp
>>>               ggml-opencl.o:(ggml_cl_free_data)
>>> referenced by ggml-opencl.cpp
>>>               ggml-opencl.o:(ggml_cl_mul)
>>> referenced by ggml-opencl.cpp
>>>               ggml-opencl.o:(ggml_cl_mul)
>>> referenced 11 more times

ld.lld: error: undefined symbol: clSetKernelArg
>>> referenced by ggml-opencl.cpp
>>>               ggml-opencl.o:(ggml_cl_mul)
>>> referenced by ggml-opencl.cpp
>>>               ggml-opencl.o:(ggml_cl_mul)
>>> referenced by ggml-opencl.cpp
>>>               ggml-opencl.o:(ggml_cl_mul)
>>> referenced 18 more times

ld.lld: error: undefined symbol: clEnqueueNDRangeKernel
>>> referenced by ggml-opencl.cpp
>>>               ggml-opencl.o:(ggml_cl_mul)
>>> referenced by ggml-opencl.cpp
>>>               ggml-opencl.o:(ggml_cl_mul)
>>> referenced by ggml-opencl.cpp
>>>               ggml-opencl.o:(ggml_cl_mul_mat_q_f32(ggml_tensor const*, ggml_tensor const*, ggml_tensor*))
>>> referenced 1 more times

ld.lld: error: undefined symbol: clReleaseEvent
>>> referenced by ggml-opencl.cpp
>>>               ggml-opencl.o:(ggml_cl_mul)
>>> referenced by ggml-opencl.cpp
>>>               ggml-opencl.o:(ggml_cl_mul)
>>> referenced by ggml-opencl.cpp
>>>               ggml-opencl.o:(ggml_cl_mul)
>>> referenced 3 more times

ld.lld: error: undefined symbol: clFinish
>>> referenced by ggml-opencl.cpp
>>>               ggml-opencl.o:(ggml_cl_mul)
>>> referenced by ggml-opencl.cpp
>>>               ggml-opencl.o:(ggml_cl_mul)
>>> referenced by ggml-opencl.cpp
>>>               ggml-opencl.o:(ggml_cl_mul)
>>> referenced 4 more times

ld.lld: error: undefined symbol: clEnqueueReadBuffer
>>> referenced by ggml-opencl.cpp
>>>               ggml-opencl.o:(ggml_cl_mul)
>>> referenced by ggml-opencl.cpp
>>>               ggml-opencl.o:(ggml_cl_mul)
>>> referenced by ggml-opencl.cpp
>>>               ggml-opencl.o:(ggml_cl_mul)
>>> referenced 3 more times

ld.lld: error: undefined symbol: clblast::StatusCode clblast::Gemm<float>(clblast::Layout, clblast::Transpose, clblast::Transpose, unsigned long, unsigned long, unsigned long, float, _cl_mem*, unsigned long, unsigned long, _cl_mem*, unsigned long, unsigned long, float, _cl_mem*, unsigned long, unsigned long, _cl_command_queue**, _cl_event**, _cl_mem*)
>>> referenced by ggml-opencl.cpp
>>>               ggml-opencl.o:(ggml_cl_mul_mat)
>>> referenced by ggml-opencl.cpp
>>>               ggml-opencl.o:(ggml_cl_mul_mat_q_f32(ggml_tensor const*, ggml_tensor const*, ggml_tensor*))

ld.lld: error: undefined symbol: clEnqueueWriteBuffer
>>> referenced by ggml-opencl.cpp
>>>               ggml-opencl.o:(ggml_cl_mul_mat)
>>> referenced by ggml-opencl.cpp
>>>               ggml-opencl.o:(ggml_cl_h2d_tensor_2d(_cl_command_queue*, _cl_mem*, unsigned long, ggml_tensor const*, unsigned long, unsigned long, _cl_event**))

ld.lld: error: undefined symbol: clblast::StatusCode clblast::Gemm<unsigned short>(clblast::Layout, clblast::Transpose, clblast::Transpose, unsigned long, unsigned long, unsigned long, unsigned short, _cl_mem*, unsigned long, unsigned long, _cl_mem*, unsigned long, unsigned long, unsigned short, _cl_mem*, unsigned long, unsigned long, _cl_command_queue**, _cl_event**, _cl_mem*)
>>> referenced by ggml-opencl.cpp
>>>               ggml-opencl.o:(ggml_cl_mul_mat)

ld.lld: error: undefined symbol: clCreateBuffer
>>> referenced by ggml-opencl.cpp
>>>               ggml-opencl.o:(ggml_cl_pool_malloc(unsigned long, unsigned long*))

ld.lld: error: too many errors emitted, stopping now (use --error-limit=0 to see all errors)
aarch64-linux-android-clang++: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [Makefile:543: main] Error 1
@staviq staviq added build Compilation issues android Issues specific to Android labels Oct 7, 2023
@staviq
Copy link
Contributor

staviq commented Oct 7, 2023

What's the output from apt install libopenblas ?

Edit: I think I reproduced your problem.

Try this:

pkg install libopenblas
pkg install clblast

And run make again.

@Mabbs
Copy link
Author

Mabbs commented Oct 7, 2023

What's the output from apt install libopenblas ?

Edit: I think I reproduced your problem.

Try this:

pkg install libopenblas
pkg install clblast

And run make again.

It works! Thank you.

@Mabbs Mabbs closed this as completed Oct 7, 2023
@miketdn
Copy link

miketdn commented Dec 5, 2023

What's the output from apt install libopenblas ?

Edit: I think I reproduced your problem.

Try this:

pkg install libopenblas
pkg install clblast

And run make again.

I get the same error but even after running these commands, it still persists.

@staviq any ideas on what else could be the issue? Everything else from the original bug report is the same. Just trying to go through the tutorial and getting this error on the make LLAMA_CLBLAST=1 command.

~/llama.cpp $ pkg install libopenblas
No mirror or mirror group selected. You might want to select one by running 'termux-change-repo'
Checking availability of current mirror:
[*] https://packages-cf.termux.dev/apt/termux-main/: ok
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
libopenblas is already the newest version (0.3.25).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

~/llama.cpp $ pkg install clblast
No mirror or mirror group selected. You might want to select one by running 'termux-change-repo'
Checking availability of current mirror:
[*] https://packages-cf.termux.dev/apt/termux-main/: ok
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
clblast is already the newest version (1.6.1).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

@nmeln
Copy link

nmeln commented Dec 8, 2023

@miketdn Try running this as well: pkg install package-config.
make was complaining about package-config not found, and it's easy to miss that error. After I installed it, the compilation was completed without errors.

@miketdn
Copy link

miketdn commented Dec 9, 2023

@nmeln Thanks for the suggestion but I get Unable to locate package package-config. I tried a couple of different repos, but no luck. Is there a repo I should use in particular?

@romanovj
Copy link

romanovj commented Dec 9, 2023

pkg i pkg-config

@nmeln
Copy link

nmeln commented Dec 9, 2023

@miketdn Yes, I used an incorrect name, look at @romanovj reply for a correct command.

Another thing is at least on my device (Qualcomm SM8150 Snapdragon 855+) I'm getting gibberish and very slow output when compiling with clblast support.

If you find that to be the case as well, I would recommend just cloning the llama.cpp repo and running make and ignoring other instructions from the readme.

Here are my settings for example (I set gpu offload to zero):

./main -m ./models/3B/stablelm-zephyr-3b.Q6_K.gguf -t 4 -ngl 0 -n -1 -c 1024 --repeat-penalty 1.0 --top-k 0 --top-p 1.0 --min-p 0.05 --temp 1.6 --rope-freq-base 0 --rope-freq-scale 0 --color -i --interactive-first --in-prefix "<|user|>\n" --in-suffix "<|endoftext|>\n<|assistant|>" -r "<|user|>" --keep -1 --prompt "This is an infinite conversation between a helpful assistant (you) and the user (me). You provide consistent and short replies. When faced with a specific problem, you will first identify and write out the constraints specified by user, then reason step by step to solve the problem."

@juanjgit
Copy link

What's the output from apt install libopenblas ?
Edit: I think I reproduced your problem.
Try this:

pkg install libopenblas
pkg install clblast

And run make again.

It works! Thank you.

@ggerganov Could these commands be added to the README ?

@miketdn
Copy link

miketdn commented Dec 11, 2023

Still doesn't work after running pkg i pkg-config successfully. Still the same error message as the original report:
ld.lld: error: undefined symbol: clGetPlatformInfo

@romanovj
Copy link

romanovj commented Dec 11, 2023

Still doesn't work after running pkg i pkg-config successfully. Still the same error message as the original report: ld.lld: error: undefined symbol: clGetPlatformInfo

do you have ocl-icd?

pkg i oci-icd

maybe you need to add to LDFLAGS
-L/system/vendor/lib64 -lOpenCL

@miketdn
Copy link

miketdn commented Dec 11, 2023

@romanovj Yes, I'm following this section of the README (https://github.com/ggerganov/llama.cpp#building-the-project-using-termux-f-droid).

I ran these two initially:
apt install libopenblas
apt install ocl-icd opencl-headers opencl-clhpp clinfo

They were all installed successfully. I think there must be something wrong with my phone/OS or with the instructions because I re-tried on a new phone, new installation and still get the exact same errors. I've also tried all the suggestions noted here, no luck unfortunately.

I originally tried on a Pixel 6 running GrapheneOS. Now tried on a brand new Pixel 8 running GrapheneOS.

@nmeln
Copy link

nmeln commented Dec 11, 2023

Try running pkg upgrade and apt update && apt upgrade in the new phone's Termux

I run the apt commands you mentioned, but also:

pkg install clang wget git cmake
pkg install libopenblas
pkg install clblast
pkg install pkg-config

And have compiled clblast and copied the required header file and so file as specified in the readme.

Then exited and restarted Termux.

Additionally I copied openblas headers to llama.cpp folder (make sure you are in the right dir)

@romanovj
Copy link

romanovj commented Dec 11, 2023

Try running pkg upgrade and apt update && apt upgrade in the new phone's Termux

I run the apt commands you mentioned, but also:

pkg install clang wget git cmake
pkg install libopenblas
pkg install clblast
pkg install pkg-config

And have compiled clblast and copied the required header file and so file as specified in the readme.

Then exited and restarted Termux.

Additionally I copied openblas headers to llama.cpp folder (make sure you are in the right dir)

I have build with these commands on fresh termux

yes | pkg upg
pkg install clang wget git cmake libopenblas clblast pkg-config opencl-headers -y
git clone --depth 1 https://github.com/ggerganov/llama.cpp
cd llama.cpp
make LLAMA_CLBLAST=1

@miketdn
Copy link

miketdn commented Dec 12, 2023

Try running pkg upgrade and apt update && apt upgrade in the new phone's Termux
I run the apt commands you mentioned, but also:

pkg install clang wget git cmake
pkg install libopenblas
pkg install clblast
pkg install pkg-config

And have compiled clblast and copied the required header file and so file as specified in the readme.
Then exited and restarted Termux.
Additionally I copied openblas headers to llama.cpp folder (make sure you are in the right dir)

I have build with these commands on fresh termux

yes | pkg upg
pkg install clang wget git cmake libopenblas clblast pkg-config opencl-headers -y
git clone --depth 1 https://github.com/ggerganov/llama.cpp
cd llama.cpp
make LLAMA_CLBLAST=1

Thank you @romanovj !

I ran this line: pkg install clang wget git cmake libopenblas clblast pkg-config opencl-headers -y

And tried it again (make LLAMA_CLBLAST=1), and it worked! Not sure why that worked since all of those packages were already installed, but it cleared the error.

@miketdn
Copy link

miketdn commented Dec 12, 2023

Now after following the rest of the steps and trying to run a ./main script, I get the following error:

CANNOT LINK EXECUTABLE "./main": library "libGLES_mali.so" not found: needed by /vendor/lib64/libOpenCL.so in namespace (default)

Wasn't able to find any other bug reports on this. Might create a new Issue ticket

@lainedfles
Copy link

@miketdn I've encountered the same problem which seems to be a result of Android filesystem permissions. Non-rooted Termux cannot read most of the files under /vendor/lib64 on my Pixel 7 Pro running GrapheneOS (Android 14) and libGLES_mali.so resides within /vendor/lib64/egl. Appending this path allowed me to load tinyllama:

export LD_LIBRARY_PATH=/vendor/lib64:/vendor/lib64/egl:$LD_LIBRARY_PATH

@miketdn
Copy link

miketdn commented Jan 5, 2024

@lainedfles That fixed it for me! Thank you for sharing! I had put off trying to get it to work, I couldn't figure it out

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
android Issues specific to Android build Compilation issues
Projects
None yet
Development

No branches or pull requests

7 participants