使用llama.cpp进行量化和部署

复制代码
git clone https://github.com/ggerganov/llama.cpp
cd llama.cpp

🖥️ CPU 版本

复制代码
cmake -B build_cpu
cmake --build build_cpu --config Release

🖥️ CUDA 版本

复制代码
cmake -B build_cuda -DLLAMA_CUDA=ON
cmake --build build_cuda --config Release -j 12

cmake -B build

cmake --build build --config Release -t llama-server

量化

1.将 safetensors 格式转成 gguf

cd ~/code/llama.cpp/build_cuda/bin

复制代码
python convert-hf-to-gguf.py /mnt/workspace/Qwen2.5-7B-Instruct --outfile /mnt/workspace/Qwen2.5-7B-Instruct-GGUF/Qwen2.5-7B-Instruct-q8_0-v1.gguf --outtype q8_0

2.将 gguf 格式进行(再)量化

cd ~/code/llama.cpp/build_cuda/bin

./quantize --allow-requantize /root/autodl-tmp/models/Llama3-8B-Chinese-Chat-GGUF/Llama3-8B-Chinese-Chat-q8_0-v2_1.gguf /root/autodl-tmp/models/Llama3-8B-Chinese-Chat-GGUF/Llama3-8B-Chinese-Chat-q4_1-v1.gguf Q4_1

部署服务:

cd llama.cpp/build/bin

./llama-server -m /mnt/workspace/Qwen2.5-7B-Instruct-GGUF/Qwen2.5-7B-Instruct-q8_0-v1.gguf/Qwen2.5-7B-Instruct-Q8_0.gguf --port 8080

相关推荐
最贪吃的虎1 小时前
我的第一个 RAG 程序:从 0 到 1,用 PDF 搭一个最小可运行的知识库问答系统
人工智能·python·算法·机器学习·aigc·embedding·llama
码农的神经元18 小时前
从零实现 LLaMA 架构:一步步构建轻量级大语言模型
人工智能·语言模型·llama
chushiyunen20 小时前
llama-index rag框架笔记
chrome·笔记·llama
青梅煮酒与君饮20 小时前
浅谈大模型、Agent、Function Calling、MCP、Skill、Subagent、Langchain、Workflow
人工智能·python·语言模型·langchain·llama
chushiyunen1 天前
llama-index 数据清洗示例、数据清洗等
java·大数据·llama
d1z8881 天前
llama.cpp 性能测试数据汇总 - NVIDIA DGX Spark 对比分析
人工智能·llama·显卡
爱打代码的小林2 天前
LLaMA Factory使用
人工智能·大模型·llama
薛不痒2 天前
Llamafactory的使用(1)
人工智能·python·llama
yumgpkpm2 天前
华为昇腾910B(Ascend 910B)+ LLaMA-Factory 对 Qwen3.5-32B 模型进行 LoRA 微调 的全流程操作指南
开源·prompt·copilot·embedding·llama·gpu算力·gitcode
竹之却4 天前
【OpenClaw】云服务器端 openclaw 集成本地 Windows端 ollama 模型
windows·llama·ollama·openclaw·qwen3.5