使用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

相关推荐
qyyyyy5709 小时前
PDF 转 JSON 怎么做?从表格和元数据提取到 LLM 结构化处理
数据库·pdf·json·erlang·llama
薛定e的猫咪12 小时前
【大模型量化】使用 llama.cpp 完成量化、本地推理与服务化部署
人工智能·深度学习·算法·llama
CODER030412 小时前
win11系统编译安装cuda版llama-cpp-python(踩完所有的坑)
开发语言·python·llama
今天吃饺子1 天前
超高创新模型!TF-SAX-Llama 轴承故障诊断
大语言模型·llama·故障诊断
明月千里赴迢遥2 天前
Node搭建代理清洗API请求
llama
Rei22483 天前
使用llama.cpp的Qwen3.6-27B-Q8本地部署详解【Linux GPU】
linux·运维·llama
蛋先生DX3 天前
大模型本地部署神器的瘦身进阶原理,就这两招?
llm·llama·ollama
爱学习的小白柏4 天前
【AI问数技术】多Agent协同架构:查询规划/SQL生成/洞察分析/报告生成
java·网络·人工智能·windows·sql·架构·llama
qy2016skq4 天前
OpenClaw 源码解读——入门与破局9 双插件协同:Quota Guard 负责“停“,Model Router 负责“绕“
langchain·prompt·aigc·embedding·ai编程·llama·agi
CHPCWWHSU4 天前
llama.cpp + DeepSeek-Harness 构建本地大模型推理与Agent智能体系统
llama