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

相关推荐
还卿一钵无情泪17 小时前
PEFT-Transformers、Unsloth、LLaMA-Factory 微调框架 横向对比
深度学习·大模型·llama·ollama
程序猿编码2 天前
不依赖 vLLM/llama.cpp:一套面向学习的 DeepSeek-R1 CUDA 推理实现
c++·学习·语言模型·llama·vllm·大模型推理
天燹2 天前
本地部署大模型ollama
人工智能·llama
骑着蜗牛撵大象3273 天前
N1 小盒子撑起 AI 接口中转层:New-API 接管本地 Ollama,用 Token 分发模型能力
docker·llama·1024程序员节·api网关·飞牛nas·new-api
言简行敏,心静致远。4 天前
llama-bench使用说明及其应用
llama
AI_Gump4 天前
模型篇|llama.cpp 推理引擎深度解读:从一人练手到 LLM 端侧的事实标准
llama·llama.cpp
星野云联AIoT技术洞察7 天前
设备手册离线 RAG:先管住版本、权限和引文,再谈本地大模型
llama·rag·设备告警·rag知识库·设备运维·设备离线·设备手册
晚风吹北巷9 天前
基于LLama-Factory 进行Lora微调
llama
你都会上树?9 天前
本地部署模型 llama + opencode + Qwen3.8-32b
llama
夜瞬10 天前
从零微调 Qwen3-8B:基于 LoRA 与 LLaMA-Factory 打造专属 AI 编程助教
人工智能·python·llama