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

sci-misc/llama-cpp build failure when enabling USE flag "blas" for sci-libs/ggml #9

Open
fpemud opened this issue Feb 4, 2025 · 6 comments

Comments

@fpemud
Copy link
Contributor

fpemud commented Feb 4, 2025

emerge command (I've limited the USE flags to the bare minimum. The error still persists when other USE flags are enabled):

USE="blas -cuda -kompute -mkl -opencl -openmp -rocm -sycl -vulkan" emerge -1 ggml llama-cpp whisper-cpp

ggml installs successfully, but error occurs when installing llama-cpp and whisper-cpp. Error:

/usr/lib/gcc/x86_64-pc-linux-gnu/14/../../../../x86_64-pc-linux-gnu/bin/ld: /usr/lib64/libggml-blas.so: undefined reference to `cblas_sgemm'

I think full build log is not needed.
(in fact I have problem uploading it due to my network)

I know that sci-libs/ggml depends on sci-libs/openblas from the ebuild file, USE flags of sci-libs/openblas:

sh-5.2# equery uses openblas
[ Legend : U - final flag setting for installation]
[        : I - package is installed with flag     ]
[ Colors : set, unset                             ]
 * Found these USE flags for sci-libs/openblas-0.3.26-r1:
 U I
 - - dynamic      : Build dynamic architecture detection at run time (for multi targets) 
 + + eselect-ldso : Enable BLAS/LAPACK runtime switching 
 - - index-64bit  : Compile a separate INTERFACE64 OpenBLAS 
 + + openmp       : Build support for the OpenMP (support parallel computing), requires >=sys-devel/gcc-4.2 built with USE="openmp"
 - - pthread      : Build with pthread threading model 
 - - relapack     : Build the ReLAPACK extension to OpenBLAS 
 - - test         : Enable dependencies and/or preparations necessary to run tests (usually controlled by FEATURES=test but can be toggled
                    independently)
@longlene
Copy link
Owner

longlene commented Feb 4, 2025

@fpemud let me take a look, never tried the minimal build before

@longlene
Copy link
Owner

longlene commented Feb 4, 2025

@fpemud It should be good now.

@fpemud
Copy link
Contributor Author

fpemud commented Feb 5, 2025

The following command runs successfully:

USE="blas -cuda -kompute -mkl -opencl -openmp -rocm -sycl -vulkan" emerge -1 ggml llama-cpp whisper-cpp

But this error comes back when "rocm" USE flag is enabled:

-- The HIP compiler identification is Clang 18.1.8
CMake Error at /usr/share/cmake/Modules/CMakeDetermineHIPCompiler.cmake:217 (message):
  The ROCm root directory:

   /usr/local

  does not contain the HIP runtime CMake package, expected at one of:

   /usr/local/lib/cmake/hip-lang/hip-lang-config.cmake
   /usr/local/lib64/cmake/hip-lang/hip-lang-config.cmake

Call Stack (most recent call first):
  src/ggml-hip/CMakeLists.txt:36 (enable_language)

I see you reverted this line in ggml-0_p20250204.ebuild:

-DGGML_HIP=$(usex rocm)

I don't know the detail, but I'm also feeling that GGML_HIP is better than GGML_HIPBLAS.
Can you tell me what do you think about this error?
I'm curious why this error happens. Why does cmake go to /usr/local to find files?

@longlene
Copy link
Owner

longlene commented Feb 5, 2025

@fpemud It may be a mistake, let me check later, I changed it just based on the cmake files.

@longlene
Copy link
Owner

longlene commented Feb 7, 2025

@fpemud I changed it from HIPBLAS TO HIP, because I can't find any HIPBLAS word in cmake, just add it back.

@fpemud
Copy link
Contributor Author

fpemud commented Feb 9, 2025

I managed to build sci-libs/ggml with rocm USE flag after adding "-DCMAKE_HIP_COMPILER_ROCM_ROOT=/usr" in "mycmakeargs".
This time I confirmed that my GPU is actually being used by llama-cpp (but the tps is still very low, I'm still on it).
I don't think this is the final solution.
I guess this is due to /usr/share/cmake/Modules/CMakeDetermineHIPCompiler.cmake from dev-build/cmake.

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

2 participants