Skip to content

CLBast: -DBUILD_SHARED_LIBS=OFF required to build against CLBlast #623

Open
@jonasborn

Description

@jonasborn

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

Using CLBast using the installation instructions from llama.cpp works also with llama-cpp-python

Current Behavior

LD fails to link, probably because of the not build so

Environment and Context

$ clinfo -l

Platform #0: Intel(R) OpenCL Graphics

$ cpuinfo

-- Device #0: Intel(R) Iris(R) Xe Graphics

OpenCL-SDK: ae7fcae82fe0b7bcc272e43fc324181b2d544eea
CLBlast: afb3d8a604f0b2aec50aeb267372767d27389c99


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

`Architecture:            x86_64
 CPU op-mode(s):        32-bit, 64-bit
 Address sizes:         39 bits physical, 48 bits virtual
 Byte Order:            Little Endian
CPU(s):                  8
 On-line CPU(s) list:   0-7
Vendor ID:               GenuineIntel
 Model name:            11th Gen Intel(R) Core(TM) i7-1165G7 @ 2.80GHz
   CPU family:          6
   Model:               140
   Thread(s) per core:  2
   Core(s) per socket:  4
   Socket(s):           1
   Stepping:            1
   CPU max MHz:         4700.0000
   CPU min MHz:         400.0000
   BogoMIPS:            5606.40
   Flags:               fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr
                         sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rep_go
                        od nopl xtopology nonstop_tsc cpuid aperfmperf tsc_known_freq pni pclmulqdq dtes64 monitor ds_cpl
                         vmx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_ti
                        mer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb cat_l2 invpcid_single cdp
                        _l2 ssbd ibrs ibpb stibp ibrs_enhanced tpr_shadow vnmi flexpriority ept vpid ept_ad fsgsbase tsc_
                        adjust bmi1 avx2 smep bmi2 erms invpcid rdt_a avx512f avx512dq rdseed adx smap avx512ifma clflush
                        opt clwb intel_pt avx512cd sha_ni avx512bw avx512vl xsaveopt xsavec xgetbv1 xsaves split_lock_det
                        ect dtherm ida arat pln pts hwp hwp_notify hwp_act_window hwp_epp hwp_pkg_req avx512vbmi umip pku
                         ospke avx512_vbmi2 gfni vaes vpclmulqdq avx512_vnni avx512_bitalg avx512_vpopcntdq rdpid movdiri
                         movdir64b fsrm avx512_vp2intersect md_clear ibt flush_l1d arch_capabilities
Virtualization features: 
 Virtualization:        VT-x
Caches (sum of all):     
 L1d:                   192 KiB (4 instances)
 L1i:                   128 KiB (4 instances)
 L2:                    5 MiB (4 instances)
 L3:                    12 MiB (1 instance)
NUMA:                    
 NUMA node(s):          1
 NUMA node0 CPU(s):     0-7
Vulnerabilities:         
 Itlb multihit:         Not affected
 L1tf:                  Not affected
 Mds:                   Not affected
 Meltdown:              Not affected
 Mmio stale data:       Not affected
 Retbleed:              Not affected
 Spec store bypass:     Mitigation; Speculative Store Bypass disabled via prctl
 Spectre v1:            Mitigation; usercopy/swapgs barriers and __user pointer sanitization
 Spectre v2:            Mitigation; Enhanced IBRS, IBPB conditional, RSB filling, PBRSB-eIBRS SW sequence
 Srbds:                 Not affected
 Tsx async abort:       Not affected`

* Operating System, e.g. for Linux:

ThinkPad-X1-Yoga-Gen-6 5.19.0-45-generic #46~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Wed Jun 7 15:06:04 UTC 20 x86_64 x86_64 x86_64 GNU/Linux

* SDK version, e.g. for Linux:

$ python3 --version

Python 3.10.12

$ make --version

GNU Make 4.3

$ g++ --version

g++ (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0

$ cmake --version

cmake version 3.22.1

Failure Information (for bugs)

      ...
      [7/9] Linking CXX shared library vendor/llama.cpp/libggml_shared.so
      FAILED: vendor/llama.cpp/libggml_shared.so
      : && /usr/bin/c++ -fPIC -O3 -DNDEBUG   -shared -Wl,-soname,libggml_shared.so -o vendor/llama.cpp/libggml_shared.so vendor/llama.cpp/CMakeFiles/ggml.dir/ggml.c.o vendor/llama.cpp/CMakeFiles/ggml.dir/ggml-alloc.c.o vendor/llama.cpp/CMakeFiles/ggml.dir/ggml-opencl.cpp.o vendor/llama.cpp/CMakeFiles/ggml.dir/k_quants.c.o  /usr/local/lib/libclblast.a  /usr/lib/x86_64-linux-gnu/libOpenCL.so && :
      /usr/bin/ld: /usr/local/lib/libclblast.a(xaxpy.cpp.o): warning: relocation against `_ZN7clblast8database11XaxpyDoubleE' in read-only section `.text.startup'
      /usr/bin/ld: /usr/local/lib/libclblast.a(xgemm.cpp.o): relocation R_X86_64_PC32 against symbol `_ZTVSt19_Sp_counted_deleterIPP9_cl_eventZN7clblast5EventC4EvEUlS2_E_SaIvELN9__gnu_cxx12_Lock_policyE2EE' can not be used when making a shared object; recompile with -fPIC
      /usr/bin/ld: final link failed: bad value
      collect2: error: ld returned 1 exit status
      [8/9] Linking CXX shared library vendor/llama.cpp/libllama.so
      FAILED: vendor/llama.cpp/libllama.so
      : && /usr/bin/c++ -fPIC -O3 -DNDEBUG   -shared -Wl,-soname,libllama.so -o vendor/llama.cpp/libllama.so vendor/llama.cpp/CMakeFiles/ggml.dir/ggml.c.o vendor/llama.cpp/CMakeFiles/ggml.dir/ggml-alloc.c.o vendor/llama.cpp/CMakeFiles/ggml.dir/ggml-opencl.cpp.o vendor/llama.cpp/CMakeFiles/ggml.dir/k_quants.c.o vendor/llama.cpp/CMakeFiles/llama.dir/llama.cpp.o  /usr/local/lib/libclblast.a  /usr/lib/x86_64-linux-gnu/libOpenCL.so && :
      /usr/bin/ld: /usr/local/lib/libclblast.a(xaxpy.cpp.o): warning: relocation against `_ZN7clblast8database11XaxpyDoubleE' in read-only section `.text.startup'
      /usr/bin/ld: /usr/local/lib/libclblast.a(xgemm.cpp.o): relocation R_X86_64_PC32 against symbol `_ZTVSt19_Sp_counted_deleterIPP9_cl_eventZN7clblast5EventC4EvEUlS2_E_SaIvELN9__gnu_cxx12_Lock_policyE2EE' can not be used when making a shared object; recompile with -fPIC
      /usr/bin/ld: final link failed: bad value
      collect2: error: ld returned 1 exit status
      ninja: build stopped: subcommand failed.
      Traceback (most recent call last):

When removing -DBUILD_SHARED_LIBS=OFF from the instructions:

...
  Stored in directory: /tmp/pip-ephem-wheel-cache-s3abou5h/wheels/61/f9/20/9ca660a9d3f2a47e44217059409478865948b5c8a1cba70030
Successfully built llama-cpp-python
Installing collected packages: typing-extensions, numpy, diskcache, llama-cpp-python
  Attempting uninstall: typing-extensions
    Found existing installation: typing_extensions 4.7.1
    Uninstalling typing_extensions-4.7.1:
      Successfully uninstalled typing_extensions-4.7.1
  Attempting uninstall: numpy
    Found existing installation: numpy 1.25.2
    Uninstalling numpy-1.25.2:
      Successfully uninstalled numpy-1.25.2
  Attempting uninstall: diskcache
    Found existing installation: diskcache 5.6.1
    Uninstalling diskcache-5.6.1:
      Successfully uninstalled diskcache-5.6.1
  Attempting uninstall: llama-cpp-python
    Found existing installation: llama-cpp-python 0.1.78
    Uninstalling llama-cpp-python-0.1.78:
      Successfully uninstalled llama-cpp-python-0.1.78
Successfully installed diskcache-5.6.1 llama-cpp-python-0.1.78 numpy-1.25.2 typing-extensions-4.7.1

Steps to Reproduce

Use a blank installation and run the installation instructions from llama.cpp for building CLBlast from source

What now?

Just wanted to inform, thought would be worth a notice in the readme if reproducible.

Metadata

Metadata

Assignees

No one assigned

    Labels

    buildllama.cppProblem with llama.cpp shared lib

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions