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

相关推荐
m0_603888714 天前
LLaMA-Adapter V2 Parameter-Efficient Visual Instruction Model
人工智能·深度学习·ai·llama·论文速览
三千院本院8 天前
LlaMA_Factory实战微调VL大模型
llama
爱分享的飘哥13 天前
第四十六章:AI的“瞬时记忆”与“高效聚焦”:llama.cpp的KV Cache与Attention机制
llama·llama.cpp·kv cache·attention优化·llm cpu推理·量化attention·gguf推理
psyq14 天前
LLaMA Factory 角色扮演模型微调实践记录
人工智能·llama
liliangcsdn22 天前
mac测试ollama llamaindex
数据仓库·人工智能·prompt·llama
茫茫人海一粒沙22 天前
使用 LLaMA 3 8B 微调一个 Reward Model:从入门到实践
llama
liliangcsdn24 天前
mac llama_index agent算术式子计算示例
人工智能·python·macos·llama
许愿与你永世安宁25 天前
RAG(检索增强生成)里的文档管理
数据库·人工智能·gpt·oracle·llama·rag
许愿与你永世安宁1 个月前
基于Llama的RAG 3种模型配置方法
人工智能·python·自然语言处理·json·github·llama·faiss
至善迎风1 个月前
本地部署 Kimi K2 全指南(llama.cpp、vLLM、Docker 三法)
docker·容器·llama·kimi