1、环境要求llama-cpp-python
https://pypi.org/project/llama-cpp-python/
Requirements:
Python 3.8+
C compiler
Linux: gcc or clang
Windows: Visual Studio or MinGW
MacOS: Xcode
2、安装命令
直接pip install llama-cpp-python
会报wheel错误。
Pre-built Wheel (New)
It is also possible to install a pre-built wheel with basic CPU support.
pip install llama-cpp-python \
--extra-index-url https://abetlen.github.io/llama-cpp-python/whl/cpu
3、gcc安装
https://github.com/oobabooga/text-generation-webui/issues/1534
sudo apt update
sudo apt install gcc-11 g++-11
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-11 60 --slave /usr/bin/g++ g++ /usr/bin/g++-11
pip install --upgrade pip
pip install --upgrade setuptools wheel
sudo apt-get install build-essential
4、libc.musl-x86_64.so.1错误
RuntimeError: Failed to load shared library ‘/nfs2/zhaochuan.cai/miniconda3/envs/reranker/lib/python3.12/site-packages/llama_cpp/lib/libllama.so’: libc.musl-x86_64.so.1: cannot open shared object file: No such file or directory
官方git:https://github.com/abetlen/llama-cpp-python/issues/1628
运行下面两行代码
apt install musl-dev
ln -s /usr/lib/x86_64-linux-musl/libc.so /lib/libc.musl-x86_64.so.1