跳到主要内容
极客日志极客日志面向AI+效率的开发者社区
首页博客我的书AI学习GitHub 精选镜像AI工具UI配色美学关于
搜索内容 / 工具 / 仓库 / 镜像...⌘K搜索
注册
博客列表
C++AI算法

新版 llama.cpp 使用指南及 Llama 模型本地部署

如何使用 llama.cpp 在本地部署 Llama 大模型。内容包括环境搭建(编译 CUDA 支持)、模型格式转换(pth/hf 转 gguf)、量化处理、命令行交互及 API 服务启动,最后通过 Open WebUI 实现类 ChatGPT 的聊天界面。适合希望离线运行大模型的开发者参考。

菩提发布于 2026/4/6更新于 2026/10/24129 浏览
新版 llama.cpp 使用指南及 Llama 模型本地部署

简介

最近大模型的发展日新月异。这一次我们来看一下使用 llama.cpp 这个项目,其主要解决的是推理过程中的性能问题。主要有两点优化:

  • llama.cpp 使用的是 C 语言写的机器学习张量库 ggml
  • llama.cpp 提供了模型量化的工具

此项目的优势在于没有 GPU 也能跑 LLaMA 模型。llama.cpp 是一个不同的生态系统,具有不同的设计理念,旨在实现轻量级、最小外部依赖、多平台以及广泛灵活的硬件支持:

  • 纯粹的 C/C++ 实现,没有外部依赖
  • 支持广泛的硬件:
    • x86_64 CPU 的 AVX、AVX2 和 AVX512 支持
    • 通过 Metal 和 Accelerate 支持 Apple Silicon(CPU 和 GPU)
    • NVIDIA GPU(通过 CUDA)、AMD GPU(通过 hipBLAS)、Intel GPU(通过 SYCL)、昇腾 NPU(通过 CANN)和摩尔线程 GPU(通过 MUSA)
    • GPU 的 Vulkan 后端
  • 多种量化方案以加快推理速度并减少内存占用
  • CPU+GPU 混合推理,以加速超过总 VRAM 容量的模型

llama.cpp 提供了大模型量化的工具,可以将模型参数从 32 位浮点数转换为 16 位浮点数,甚至是 8、4 位整数。除此之外,llama.cpp 还提供了服务化组件,可以直接对外提供模型的 API。

1. llama.cpp 环境安装

克隆仓库并进入该目录:

git clone https://github.com/ggerganov/llama.cpp
cd llama.cpp

构建 GPU 执行环境,确保安装 CUDA 工具包,适用于有 GPU 的操作系统。

如果 CUDA 设置正确,那么执行 nvidia-smi、nvcc --version 没有错误提示,则表示一切设置正确。

mkdir build
sudo apt-get install make cmake gcc g++ locate cmake -B build -DGGML_CUDA=ON
cmake --build build --config Release -j4
cd build
make install

在当前版本(截至 2024 年 11 月 10 日)这些指令分别被重命名为 llama-quantize、llama-cli、llama-server。

ln -s your/path/to/llama.cpp/build/bin/llama-quantize llama-quantize
ln -s your/path/to/llama.cpp/build/bin/llama-server llama-server
ln -s your/path/to/llama.cpp/build/bin/llama-cli llama-cli

2. LLAMA 模型转换

这里我们会从 pth 开始,一步步给出我们怎么将模型应用到 llama.cpp 中的。

2.1 pth 原始模型处理

首先安装高版本 python 3.10。

pip install protobuf==3.20.0
pip install transformers #最新版
pip install sentencepiece #(0.1.97 测试通过)
pip install peft #(0.2.0 测试通过)
pip install git+https://github.com/huggingface/transformers
pip install sentencepiece
pip install peft
2.1.1 磁链下载

然后下载原版 LLaMA 模型的权重和 tokenizer.model 文件。如果嫌从官方下载太麻烦,网上也有一些泄露的模型版本可以直接下载。

这里 应该是最早泄漏的版本,可以使用 IPFS 客户端 进行下载。

社区里也有人制作了种子,可以使用 BitTorrent 下载,磁链地址为 magnet:?xt=urn:btih:ZXXDAUWYLRUXXBHUYEMS6Q5CE5WA3LVA&dn=LLaMA

sudo apt update
sudo apt install transmission-cli "magnet:?xt=urn:btih:ZXXDAUWYLRUXXBHUYEMS6Q5CE5WA3LVA&dn=LLaMA"

压缩包内文件目录如下(LLaMA-7B 为例)

├── llama-7b
│   ├── consolidated.00.pth
│   ├── params.json
│   └── checklist.chk
└── tokenizer.model
2.1.2 使用 pyllama 下载

另一种下载 Llama 模型的方法是使用 pyllama 库。首先,通过 pip 安装它(非 M2 芯片):

pip3 install transformers pyllama -U

然后通过下面的命令下载 Llama 7B 模型(根据需要你也可以下载 13B、30B 和 65B,如果不指定 --model_size 则下载所有):

python3 -m llama.download --model_size 7B

在 Mac M2 下可能会遇到下面这样的报错:

ImportError: dlopen(/Library/Python/3.9/site-packages/_itree.cpython-39-darwin.so, 0x0002): tried: '/Library/Python/3.9/site-packages/_itree.cpython-39-darwin.so'(mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64')), '/System/Volumes/Preboot/Cryptexes/OS/Library/Python/3.9/site-packages/_itree.cpython-39-darwin.so'(no such file), '/Library/Python/3.9/site-packages/_itree.cpython-39-darwin.so'(mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64'))

根据 itree 的官方文档,这个库我们需要自己手动构建:

brew install cmake
pip3 install https://github.com/juncongmoo/itree/archive/refs/tags/v0.0.18.tar.gz

安装完成后,再次下载,这次虽然没有报错,但是模型的下载目录 pyllama_data 却是空的,根据 这里 的解决方案,我们使用源码重新安装 pyllama:

pip3 uninstall pyllama
git clone https://github.com/juncongmoo/pyllama
pip3 install -e pyllama

然后再次下载即可,7B 模型文件大约 13G,下载速度取决于你的网速,成功后输出如下:

python3 -m llama.download --model_size 7B
❤️ Resume download is supported. You can ctrl-c and rerun the program to resume the downloading
Downloading tokenizer...
✅ pyllama_data/tokenizer.model
✅ pyllama_data/tokenizer_checklist.chk
tokenizer.model: OK
Downloading 7B
downloading file to pyllama_data/7B/consolidated.00.pth ...please wait for a few minutes ...
✅ pyllama_data/7B/consolidated.00.pth
✅ pyllama_data/7B/params.json
✅ pyllama_data/7B/checklist.chk
Checking checksums for the 7B model
consolidated.00.pth: OK
params.json: OK
2.1.3 脚本下载
#!/bin/bash
# Function to handle stopping the script
function stop_script(){
    echo "Stopping the script."
    exit 0
}
# Register the signal handler
trap stop_script SIGINT
while true; do
    # Run the command with a timeout of 200 second
    timeout 2000 python -m llama.download --model_size $1 --folder model
    echo "restart download"
    sleep 1
    # Wait for 1 second before starting the next iteration
    # Wait for any key to be pressed within a 1-second timeout
    read -t 1 -n 1 -s key
    if [[ $key ]]; then
        stop_script
    fi
done

之后运行该文件即可自动执行(漫长等待ing)

bash llama_download.sh 7B

下载后一共有 5 个文件:

pyllama_data
|-- 7B
|   |-- checklist.chk
|   |-- consolidated.00.pth
|   `-- params.json
|-- tokenizer.model
`-- tokenizer_checklist.chk

2.2 原版转为 hf 格式文件

2.2.1 hf 格式转换

这里使用 transformers 提供的脚本 convert_llama_weights_to_hf.py 将原版 LLaMA 模型转换为 HuggingFace 格式。或者直接在抱抱脸上下载。

git clone https://huggingface.co/luodian/llama-7b-hf ./models/Llama-7b-chat-hf

将原版 LLaMA 的 tokenizer.model 放在 --input_dir 指定的目录,其余文件放在 ${input_dir}/${model_size} 下。执行以下命令后,--output_dir 中将存放转换好的 HF 版权重。

git clone https://github.com/huggingface/transformers.git
cd transformers
python src/transformers/models/llama/convert_llama_weights_to_hf.py \
--input_dir /workspace/pth_model/7B \
--model_size 7B \
--output_dir /workspace/hf_data

--output_dir 目录下会生成 HF 格式的模型文件,诸如:

config.json
generation_config.json
pytorch_model-00001-of-00002.bin
pytorch_model-00002-of-00002.bin
pytorch_model.bin.index.json
special_tokens_map.json
tokenizer_config.json
tokenizer.json
tokenizer.model
2.2.2 合并 lora

这里我们选择了 Chinese-LLaMA-Alpaca 作为 lora 合并的操作。然后我们需要合并 LoRA 权重,生成全量模型权重。这里我们使用 ymcui/Chinese-LLaMA-Alpaca at v2.0 (github.com) 里面的 scripts/merge_llama_with_chinese_lora.py 脚本。

git clone https://github.com/ymcui/Chinese-LLaMA-Alpaca.git

对原版 LLaMA 模型(HF 格式)扩充中文词表,并与 LoRA 权重进行合并,生成全量模型权重 consolidated.*.pth(建议检查生成模型的 SHA256 值)和配置文件 params.json。请执行以下命令:

python scripts/merge_llama_with_chinese_lora.py \
--base_model /workspace/hf_data \
--lora_model /workspace/chinese_llama_lora_7b \
--output_dir /workspace/lora_pth_data

--base_model:存放 HF 格式的 LLaMA 模型权重和配置文件的目录(Step 1 生成)

--lora_model:中文 LLaMA/Alpaca LoRA 解压后文件所在目录,也可使用 Model Hub 模型调用名称:ziqingyang/chinese-alpaca-lora-7b 或 ziqingyang/chinese-llama-lora-7b

--output_type: 指定输出格式,可为 pth 或 huggingface。若不指定,默认为 pth

--output_dir:指定保存全量模型权重的目录,默认为./(可选)

--offload_dir(仅对旧脚本 scripts/merge_llama_with_chinese_lora.py 有效):对于低内存用户需要指定一个 offload 缓存路径(可选)

如果出现下面的错误,则将 /workspace/chinese_llama_lora_7b 下的 adapter_config.json 删除 lora 内容。

转换结果:

在转换完毕后,如有需要,可自行按照 2.2.1 节中的脚本将本步骤生成的 .pth 文件转换为 HuggingFace 格式。

2.3 hf 转 gguf 模型

之前的 convert.py 已被移至 examples/convert_legacy_llama.py,并且不应用于 Llama/Llama2/Mistral 模型及其衍生品以外的任何用途。它不支持 LLaMA 3,您可以使用 convert_hf_to_gguf.py 来处理从 Hugging Face 下载的 LLaMA 3。这里我们对模型进行转化,将其转化为 gguf 格式并进行量化,在 llama.cpp 路径下:

# 请参考并替换为自己的对应路径,记得创建/workspace/chinese_gguf/llama-7b.gguf 这个文件。其中 outtype 是指下面的量化精度,其实不需要转,可以使用下面的指令转
python convert_hf_to_gguf.py ../hf_data --outfile /workspace/chinese_gguf/llama-7b.gguf --outtype q8_0
#如果是 pth 则是
python3 examples/convert_legacy_llama.py /workspace/lora_pth_data/ --outfile /workspace/chinese_gguf/chinese.gguf

pth 版本 hf 版本

# llama-quantize 提供各种精度的量化
#./llama-quantize
#usage: ./quantize [--help] [--allow-requantize] [--leave-output-tensor] model-f32.gguf [model-quant.gguf] type [nthreads]
# --allow-requantize: Allows requantizing tensors that have already been quantized. Warning: This can severely reduce quality compared to quantizing from 16bit or 32bit
# --leave-output-tensor: Will leave output.weight un(re)quantized. Increases model size but may also increase quality, especially when requantizing
# Allowed quantization types:
# 2 or Q4_0 : 3.56G, +0.2166 ppl @ LLaMA-v1-7B
# 3 or Q4_1 : 3.90G, +0.1585 ppl @ LLaMA-v1-7B
# 8 or Q5_0 : 4.33G, +0.0683 ppl @ LLaMA-v1-7B
# 9 or Q5_1 : 4.70G, +0.0349 ppl @ LLaMA-v1-7B
# 10 or Q2_K : 2.63G, +0.6717 ppl @ LLaMA-v1-7B
# 12 or Q3_K : alias for Q3_K_M
# 11 or Q3_K_S : 2.75G, +0.5551 ppl @ LLaMA-v1-7B
# 12 or Q3_K_M : 3.07G, +0.2496 ppl @ LLaMA-v1-7B
# 13 or Q3_K_L : 3.35G, +0.1764 ppl @ LLaMA-v1-7B
# 15 or Q4_K : alias for Q4_K_M
# 14 or Q4_K_S : 3.59G, +0.0992 ppl @ LLaMA-v1-7B
# 15 or Q4_K_M : 3.80G, +0.0532 ppl @ LLaMA-v1-7B
# 17 or Q5_K : alias for Q5_K_M
# 16 or Q5_K_S : 4.33G, +0.0400 ppl @ LLaMA-v1-7B
# 17 or Q5_K_M : 4.45G, +0.0122 ppl @ LLaMA-v1-7B
# 18 or Q6_K : 5.15G, -0.0008 ppl @ LLaMA-v1-7B
# 7 or Q8_0 : 6.70G, +0.0004 ppl @ LLaMA-v1-7B
# 1 or F16 : 13.00G @ 7B
# 0 or F32 : 26.00G @ 7B
# 2. 使用 llama-quantize 转换精度
# llama-quantize 支持的精度以及更多的使用方法可通过 llama-quantize --help 查看
llama-quantize /workspace/chinese_gguf/chinese.gguf /workspace/chinese_gguf/chinese_q4_0.gguf Q4_0

转换完成后,模型目录下会多一个 chinese_q4_0.gguf 文件:

ls -lh /workspace/chinese_gguf

3. 使用 llama.cpp 运行 GGUF 模型

这里我们可以通过上面的操作,或者去 https://huggingface.co/models 找 GGUF 格式的大模型版本,下载模型文件放在 llama.cpp 项目 models 目录下。

git clone https://huggingface.co/rozek/LLaMA-2-7B-32K-Instruct_GGUF ./models/LLaMA-2-7B-32K-Instruct_GGUF

仓库中包含各种量化位数的模型,Q2、Q3、Q4、Q5、Q6、Q8、F16。量化模型的命名方法遵循:"Q" + 量化比特位 + 变种。量化位数越少,对硬件资源的要求越低,但是模型的精度也越低。

3.1 交互模式

可通过 llama-cli 或 llama-server 运行模型。

llama-cli -m chinese_q4_0.gguf -p "you are a helpful assistant" -cnv -ngl 24

其中:

  • -m 参数后跟要运行的模型
  • -cnv 表示以对话模式运行模型
  • -ngl:当编译支持 GPU 时,该选项允许将某些层卸载到 GPU 上进行计算。一般情况下,性能会有所提高。

其他参数详见官方文档 llama.cpp/examples/main/README.md at master · ggerganov/llama.cpp (github.com)

3.2 模型 API 服务

llama.cpp 提供了完全与 OpenAI API 兼容的 API 接口,使用经过编译生成的 llama-server 可执行文件启动 API 服务。如果编译构建了 GPU 执行环境,可以使用 -ngl N 或 --n-gpu-layers N 参数,指定 offload 层数,让模型在 GPU 上运行推理。未使用 -ngl N 或 --n-gpu-layers N 参数,程序默认在 CPU 上运行。

./llama-server -m /mnt/workspace/my-llama-13b-q4_0.gguf -ngl 28

可从以下关键启动日志看出,模型在 GPU 上执行。

ggml_cuda_init: GGML_CUDA_FORCE_MMQ: no
ggml_cuda_init: CUDA_USE_TENSOR_CORES: yes
ggml_cuda_init: found 1 CUDA devices: Device 0: Tesla V100S-PCIE-32GB, compute capability 7.0, VMM: yes
llm_load_tensors: ggml ctx size =0.30 MiB
llm_load_tensors: offloading 32 repeating layers to GPU
llm_load_tensors: offloading non-repeating layers to GPU
llm_load_tensors: offloaded 33/33 layers to GPU
llm_load_tensors: CPU buffer size =1002.00 MiB
llm_load_tensors: CUDA0 buffer size =14315.02 MiB
.........................................................................................
llama_new_context_with_model: n_ctx =512
llama_new_context_with_model: n_batch =512
llama_new_context_with_model: n_ubatch =512
llama_new_context_with_model: flash_attn =0

会启动一个类似 web 服务器的进程,默认端口号为 8080,这样就启动了一个 API 服务,可以使用 curl 命令进行测试。

curl --request POST \
--url http://localhost:8080/completion \
--header "Content-Type: application/json" \
--data '{"prompt": "What color is the sun?","n_predict": 512}'
{"content":".....","generation_settings":{"frequency_penalty":0.0,"grammar":"","ignore_eos":false,"logit_bias":[],"mirostat":0,"mirostat_eta":0.10000000149011612,"mirostat_tau":5.0,......}}

此外可通过 web 页面或者 OpenAI api 等进行访问。安装 openai 依赖。

pip install openai

使用 OpenAI api 访问:

import openai
client = openai.OpenAI(
    base_url="http://127.0.0.1:8080/v1",
    api_key="sk-no-key-required")
completion = client.chat.completions.create(
    model="qwen",# model name can be chosen arbitrarily
    messages=[{"role":"system","content":"You are a helpful assistant."},{"role":"user","content":"tell me something about michael jordan"}])
print(completion.choices[0].message.content)

3.3 模型 API 服务 (第三方,自己安装不需要)

在 llamm.cpp 项目中有提到各种语言编写的第三方工具包,可以使用这些工具包提供 API 服务,这里以 Python 为例,使用 llama-cpp-python 提供 API 服务。

安装依赖。

pip install llama-cpp-python
pip install llama-cpp-python -i https://mirrors.aliyun.com/pypi/simple/

注意:可能还需要安装以下缺失依赖,可根据启动时的异常提示分别安装。

pip install sse_starlette starlette_context pydantic_settings

启动 API 服务,默认运行在 http://localhost:8000

python -m llama_cpp.server --model models/Llama3-q8.gguf

然后操作和上面一致,运行 openai 的脚本。

4. 实现类似 ChatGPT 的聊天应用

至此,我们已经可以熟练地在本地部署和运行 Llama 模型了,为了让我们和语言模型之间的交互更加友好,我们还可以借助一些开源项目打造一款类似 ChatGPT 的聊天应用。无论是 llama.cpp 还是 Ollama,周边生态都非常丰富,社区开源了大量的网页、桌面、终端等交互界面以及诸多的插件和拓展,参考 Ollama 的 Community Integrations。

下面列举一些比较有名的 Web UI:

  • Open WebUI
  • Text generation web UI
  • Jan
  • GPT4All
  • LibreChat

接下来我们就基于 Open WebUI 来实现一个本地聊天应用。Open WebUI 是一个可扩展、功能丰富且用户友好的自托管 WebUI,旨在完全离线运行。它的原名叫 Ollama WebUI,原本只是对 Ollama 的,后来在社区的推动下,发展成了一款通用的聊天应用 WebUI,支持各种 LLM 运行器,包括 Ollama 以及与 OpenAI 兼容的接口。

Open WebUI 具备大量的功能特性,包括:

  • 直观的界面:接近 ChatGPT 的界面,提供用户友好的体验;
  • 响应式的设计:同时兼容桌面和移动端设备;
  • 快速的响应:让用户享受快速且响应迅速的性能;
  • 轻松的安装:支持使用 Docker 或 Kubernetes 进行安装;
  • 代码语法高亮:增强代码的可读性;
  • 全面支持 Markdown 和 LaTeX:实现更丰富的交互,提升用户的体验;
  • 本地 RAG 集成:支持在聊天中对文档进行问答;
  • 网页浏览功能:支持在聊天中对网页进行问答;
  • 预设的提示词:聊天时输入 / 命令即可立即访问预设的提示词;
  • RLHF 注释:通过给消息点赞或点踩,为 RLHF 创建数据集,便于使用您的消息来训练或微调模型;
  • 对话标记:轻松分类和定位特定的聊天,以便快速参考和高效数据收集;
  • 模型管理:支持在页面上下载或删除模型;支持导入 GGUF 文件,轻松创建 Ollama 模型或 Modelfile 文件;
  • 多模型切换:支持多个模型之间的切换;
  • 多模型对话:同时与多个模型进行交流,通过比较获得最佳回应;
  • 多模态:支持多模态大模型,可以在聊天中使用图片;
  • 聊天记录:轻松访问和管理对话历史,支持导入和导出聊天数据;
  • 语音输入支持:通过语音互动与模型进行交流,享受直接与模型对话的便利;
  • 图像生成集成:无缝地使用 AUTOMATIC1111 API 和 DALL-E 集成图像生成功能,为聊天体验增添动态视觉内容;
  • OpenAI API 集成:轻松地将与 Ollama 模型兼容的 OpenAI API 集成到对话中;
  • 国际化(i18n):支持多种不同的语言;

运行如下的 Docker 命令即可安装 Open WebUI:

$ docker run -d -p 3000:8080 \
  --add-host=host.docker.internal:host-gateway \
  -v open-webui:/app/backend/data \
  --name open-webui \
  --restart always \
  ghcr.io/open-webui/open-webui:main

安装成功后,浏览器访问 http://localhost:3000/ 即可,首次访问需要注册一个账号。

注册账号并登录后,就可以看到我们熟悉的聊天界面了。

5. 参考链接

https://github.com/ymcui/Chinese-LLaMA-Alpaca/wiki/llama.cpp 量化部署

https://www.chenshaowen.com/blog/llama-cpp-that-is-a-llm-deployment-tool.html

https://www.bilibili.com/read/cv34175051/

https://qwen.readthedocs.io/zh-cn/latest/run_locally/llama.cpp.html

https://www.aneasystone.com/archives/2024/04/llama-in-action.html

目录

  1. 简介
  2. 1. llama.cpp 环境安装
  3. 2. LLAMA 模型转换
  4. 2.1 pth 原始模型处理
  5. 2.1.1 磁链下载
  6. 2.1.2 使用 pyllama 下载
  7. 2.1.3 脚本下载
  8. Function to handle stopping the script
  9. Register the signal handler
  10. 2.2 原版转为 hf 格式文件
  11. 2.2.1 hf 格式转换
  12. 2.2.2 合并 lora
  13. 2.3 hf 转 gguf 模型
  14. 请参考并替换为自己的对应路径,记得创建/workspace/chinese_gguf/llama-7b.gguf 这个文件。其中 outtype 是指下面的量化精度,其实不需要转,可以使用下面的指令转
  15. llama-quantize 提供各种精度的量化
  16. --allow-requantize: Allows requantizing tensors that have already been quantized. Warning: This can severely reduce quality compared to quantizing from 16bit or 32bit
  17. --leave-output-tensor: Will leave output.weight un(re)quantized. Increases model size but may also increase quality, especially when requantizing
  18. Allowed quantization types:
  19. 2 or Q4_0 : 3.56G, +0.2166 ppl @ LLaMA-v1-7B
  20. 3 or Q4_1 : 3.90G, +0.1585 ppl @ LLaMA-v1-7B
  21. 8 or Q5_0 : 4.33G, +0.0683 ppl @ LLaMA-v1-7B
  22. 9 or Q5_1 : 4.70G, +0.0349 ppl @ LLaMA-v1-7B
  23. 10 or Q2_K : 2.63G, +0.6717 ppl @ LLaMA-v1-7B
  24. 12 or Q3K : alias for Q3K_M
  25. 11 or Q3KS : 2.75G, +0.5551 ppl @ LLaMA-v1-7B
  26. 12 or Q3KM : 3.07G, +0.2496 ppl @ LLaMA-v1-7B
  27. 13 or Q3KL : 3.35G, +0.1764 ppl @ LLaMA-v1-7B
  28. 15 or Q4K : alias for Q4K_M
  29. 14 or Q4KS : 3.59G, +0.0992 ppl @ LLaMA-v1-7B
  30. 15 or Q4KM : 3.80G, +0.0532 ppl @ LLaMA-v1-7B
  31. 17 or Q5K : alias for Q5K_M
  32. 16 or Q5KS : 4.33G, +0.0400 ppl @ LLaMA-v1-7B
  33. 17 or Q5KM : 4.45G, +0.0122 ppl @ LLaMA-v1-7B
  34. 18 or Q6_K : 5.15G, -0.0008 ppl @ LLaMA-v1-7B
  35. 7 or Q8_0 : 6.70G, +0.0004 ppl @ LLaMA-v1-7B
  36. 1 or F16 : 13.00G @ 7B
  37. 0 or F32 : 26.00G @ 7B
  38. 2. 使用 llama-quantize 转换精度
  39. llama-quantize 支持的精度以及更多的使用方法可通过 llama-quantize --help 查看
  40. 3. 使用 llama.cpp 运行 GGUF 模型
  41. 3.1 交互模式
  42. 3.2 模型 API 服务
  43. 3.3 模型 API 服务 (第三方,自己安装不需要)
  44. 4. 实现类似 ChatGPT 的聊天应用
  45. 5. 参考链接

更多推荐文章

查看全部
  • VSCode Copilot 登录失败原因排查与修复指南
  • OpenCode 命令行 AI 编程代理使用指南
  • GLM-4v-9b 实战指南:基于 llama.cpp GGUF 在消费级 GPU 部署多模态模型
  • 吴恩达机器学习:逻辑回归算法详解
  • AI 模型组合技术指南
  • Stable Diffusion 文生图保姆级入门指南
  • 无人机视觉任务常用数据集汇总:检测与分割资源整理
  • Dify 工作流实战:快速搭建专业 Web 登录界面
  • TDuck 开源表单系统私有化部署与数据收集实践
  • OpenClaw 跨平台 AI 助手使用指南:安装配置与核心功能详解
  • 小鹏 VLA 2.0 技术解析:自动驾驶与人形机器人的端到端演进
  • 双指针统计有效三角形个数
  • VS Code 配置 C/C++ 开发环境指南(支持万能头文件)
  • Stable Diffusion 画质增强:Consistency Decoder 使用教程
  • C++ Qt 网络编程:QUdpSocket、QTcpSocket 与 Http 实战
  • 基于 UniApp 与 Vue 的纯前端奶茶点餐系统架构解析
  • Jetson Orin NX 部署 Ollama 与 Llama 3.2 实战指南
  • MySQL 数据类型核心指南:选型、实战与避坑
  • PostgreSQL INSERT INTO 语句详解与实战技巧
  • Qwen-Image-2512 免费本地部署实战:ComfyUI 全流程指南

相关免费在线工具

  • 加密/解密文本

    使用加密算法(如AES、TripleDES、Rabbit或RC4)加密和解密文本明文。 在线工具,加密/解密文本在线工具,online

  • RSA密钥对生成器

    生成新的随机RSA私钥和公钥pem证书。 在线工具,RSA密钥对生成器在线工具,online

  • Mermaid 预览与可视化编辑

    基于 Mermaid.js 实时预览流程图、时序图等图表,支持源码编辑与即时渲染。 在线工具,Mermaid 预览与可视化编辑在线工具,online

  • 随机西班牙地址生成器

    随机生成西班牙地址(支持马德里、加泰罗尼亚、安达卢西亚、瓦伦西亚筛选),支持数量快捷选择、显示全部与下载。 在线工具,随机西班牙地址生成器在线工具,online

  • Gemini 图片去水印

    基于开源反向 Alpha 混合算法去除 Gemini/Nano Banana 图片水印,支持批量处理与下载。 在线工具,Gemini 图片去水印在线工具,online

  • Base64 字符串编码/解码

    将字符串编码和解码为其 Base64 格式表示形式即可。 在线工具,Base64 字符串编码/解码在线工具,online