You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Use llama-cpp-python with an already built version of llama.cpp #1070
Describe the solution you'd like
I would like to be able to install llama-cpp-python without building llama.cpp and simply set a variable to the folder of an already build llama.cpp build.
Describe alternatives you've considered
I tried building llama.cpp the way I want (on Windows and with cuBLAS) but it fails when being doing though llama-cpp-python, although it works fine when building llama.cpp as a standalone.
Additional context
Even installing a llama-cpp-python in the basic CPU only way would be OK if it would be easy to swap the llama.cpp build afterwards.
Reacted by Lalith Kumar V, SergProduction and prodigy
Yes, same problem on ubunbtu, building with GPU enabled core dumps when inference starts. Doesn't seem very stable. unfortunately localai is even worse, doesn't compile properly. These tools are probably just too new.
This gives you the most control over the build process however note that the llama.cpp API version must match the version for the version of llama-cpp-python that you're installing.
Reacted by anil, Linda Chiu, Jorge Diogo, Varun Rao, Michael Hsu, xqgtiti, Anudeep Tubati, thebiss, navratil-matej, Ayman and 8 more
I run into libggml.so: undefined symbol: llama_max_devices. I've built llama.cpp with CUDA and built the shared libs. Importing in Python causes that error.
I am getting src/libllama.so: undefined symbol: llama_get_model_tensor when building latest of llama-cpp and on latest llama-cpp-python when importing llama_cpp. Anyone have idea on how to solve?
For me I had to export LLAMA_CPP_LIB_PATH=/path/to/shared/lib/directory
The libllama.so file is located at llama.cpp/build/bin/libllama.so. I set the LLAMA_CPP_LIB_PATH environment variable to /home/.../llama.cpp/build/bin/libllama.so, but I encountered the following error:
> Segmentation fault
Python code:
fromllama_cppimportLlamallm=Llama(model_path="resources/qwen2.5-0.5b-instruct-q8_0.gguf")
output=llm(
"Q: Dime el nombre de los planetas en el sistema solar A: ",
max_tokens=32,
stop=["Q:", "\n"],
echo=True
)
print(output)
I’m trying to run the llama-cpp-python bindings on a Raspberry Pi 3B+. The llama.cpp installation works fine, but when using llama-cpp-python, the RAM gets maxed out and the process fails.
Activity
Speedway1 commentedon Jan 7, 2024
Yes, same problem on ubunbtu, building with GPU enabled core dumps when inference starts. Doesn't seem very stable. unfortunately localai is even worse, doesn't compile properly. These tools are probably just too new.
abetlen commentedon Jan 8, 2024
Yup this is possible!
This gives you the most control over the build process however note that the llama.cpp API version must match the version for the version of llama-cpp-python that you're installing.
aniljava commentedon Jan 8, 2024
Having
pip install llama-cpp-python[minimal]would be nice to allow use of existing llama.cpp's libllama.so.@Speedway1 , can you try running with
LLAMA_CPP_LIBpointing to the llama.cpp dir and also invoking following in llama.cpp base folder.TamirHCL commentedon Jan 8, 2024
Amazing - thanks for the answer/clarification!
thangld201 commentedon Jan 16, 2024
Hi @abetlen @aniljava @TamirHCL, when installing with
cmake .. -DBUILD_SHARED_LIBS=ON && cmake --build . --config ReleaseI got the error
Does anyone have a solution ?
sigjhl commentedon Jul 5, 2024
In case someone doesn't know what the shared library file is (=me), it's the libllama.so file.
LLAMA_CPP_LIB=.../libllama.so
hericks commentedon Jul 8, 2024
@abetlen
Where can we find the llama.cpp API version that a specific version of llama-cpp-python expects?
Edit. No need to answer. I've figured it out. Its the commit hash mentioned in
llama-cpp-python/vendor/.NeuralFlux commentedon Jul 29, 2024
I run into
libggml.so: undefined symbol: llama_max_devices. I've built llama.cpp with CUDA and built the shared libs. Importing in Python causes that error.MarioIshac commentedon Dec 23, 2024
I am getting
src/libllama.so: undefined symbol: llama_get_model_tensorwhen building latest ofllama-cppand on latestllama-cpp-pythonwhen importingllama_cpp. Anyone have idea on how to solve?LixiangHan commentedon Apr 3, 2025
In my case, the above solutions do not work for me. I installed llama-cpp-python with the already-built llama.cpp by
tommydvt commentedon Apr 17, 2025
For me I had to export LLAMA_CPP_LIB_PATH=/path/to/shared/lib/directory
Mauriciocr207 commentedon Apr 23, 2025
The libllama.so file is located at llama.cpp/build/bin/libllama.so. I set the LLAMA_CPP_LIB_PATH environment variable to /home/.../llama.cpp/build/bin/libllama.so, but I encountered the following error:
> Segmentation faultPython code:
I’m trying to run the llama-cpp-python bindings on a Raspberry Pi 3B+. The llama.cpp installation works fine, but when using llama-cpp-python, the RAM gets maxed out and the process fails.
JackZeng0208 commentedon Apr 27, 2025
@Mauriciocr207 The segmentation fault is caused by llama.cpp (ggml-org/llama.cpp#9289 (comment)), you should build llama.cpp based on code before version b5028