Geforce 50xx系顯卡最低支持cuda128,llama_cpp_python官方源只有cpu版本,沒有cuda版本,所以自己基于0.3.5版本源碼編譯一個RTX 30xx/40xx/50xx版本。
1. 前置條件
1. 訪問https://developer.download.nvidia.cn/compute/cuda/12.8.0/local_installers/cuda_12.8.0_571.96_windows.exe安裝cuda12.8 toolkit, 安裝完成后在命令行輸入“nvcc -V”確認如下信息:
Cuda compilation tools, release 12.8, V12.8.61
2. 使用visual studio installer 安裝visual studio 2022,工作負荷選擇【使用c++的桌面開發】,安裝完成后將“VC\Tools\MSVC\<版本號>\bin\Hostx64\x64”對1應的路徑加入環境變量;
3. 訪問https://github.com/abetlen/llama-cpp-python/archive/refs/tags/v0.3.5-metal.tar.gz下載源碼(國內鏡像),下載后解壓;?訪問?https://github.com/ggml-org/llama.cpp/archive/refs/tags/b4831.tar.gz下載源碼(國內鏡像),下載后解壓到 “llama_cpp_python\vendor\llama.cpp”;
4. 訪問https://github.com/conda-forge/miniforge/releases/download/24.11.3-0/Miniforge3-Windows-x86_64.exe安裝miniforge;
2. 編譯
conda create llama_build
conda activate llama_build
conda install ccahce
pip install build wheelset CMAKE_ARGS=-DGGML_CUDA=ON -DCMAKE_CUDA_ARCHITECTURES=86;89;120cd C:\llama_cpp_python
python -m build --wheel