llama.cpp本地化部署
llama.cpp是一个开源的大模型部署工具,该工具使用C/C++语言编写,实现了Meta的LLaMa架构。本教程介绍如何在本地从源码编译部署llama.cpp。
准备
在进行本地化部署之前,系统上需要先安装好如下的工具:
- Git
- Make
- CMake
- CUDA Tool Kit (可选,如需要编译GPU版本,请先安装)
Git 与 CMake 在 SonmiHPC 集群平台上可以通过 DNF 进行安装:
shell
dnf install -y git make cmake
dnf install -y git make cmake
克隆源码到本地
执行如下的命令,使用 git 将 llama.cpp 的仓库克隆到本地中:
shell
git clone https://github.com/ggerganov/llama.cpp
cd llama.cpp
git clone https://github.com/ggerganov/llama.cpp
cd llama.cpp
CPU版本编译
CPU版本执行如下的命令进行多线程加速编译过程:
shell
cmake -B build
cmake --build build --config Release -j $(nproc)
cmake -B build
cmake --build build --config Release -j $(nproc)
GPU版本编译
GPU版本执行如下的命令进行多线程加速编译过程:
shell
cmake -B build -DGGML_CUDA=ON
cmake --build build --config Release -j $(nproc)
cmake -B build -DGGML_CUDA=ON
cmake --build build --config Release -j $(nproc)
安装
编译好之后进入源码目录的build目录下,执行下面的命令安装到本地 /usr/local/bin 中:
shell
make install
make install