llama-cpp-python本地部署并使用gpu版本
使用带编译的命令安装llama库
# 首选 GGML_CUDA 后续LLAMA_CUBLAS将删除
CMAKE_ARGS="-DGGML_CUDA=on" FORCE_CMAKE=1 pip install llama-cpp-python --no-cache-dir
CMAKE_ARGS="-DLLAMA_CUBLAS=on" FORCE_CMAKE=1 pip install llama-cpp-python --no-cache-dir
如果仅使用pip install llama-cpp-python会仅使用cpu运行。
并且使用LLAMA_CUBLAS 可能会出现以下错误
_*** CMake configuration failed
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for llama-cpp-python
Failed to build llama-cpp-python
ERROR: Could not build wheels for llama-cpp-python, which is required to install pyproject.toml-based projects_
下载torch本地很慢,加速技巧(linux):
apt install aria2
-x 16
表示使用 16 个连接进行下载。-s 16
表示将文件分为 16 个部分来同时下载。aria2c -x 16 -s 16 https://download.pytorch.org/whl/cu121/torch-2.5.0%2Bcu121-cp312-cp312-linux_x86_64.whl
实时查看nvidia显卡占用信息 :
-n SECONDS
:指定刷新间隔(默认是 2 秒)。-d
:高亮显示输出中变化的部分。-t
:不显示顶部的标题信息。watch -n 0.5 nvidia-smi
作者:i__chen