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

相关推荐
心疼你的一切14 小时前
Llama.Cpp 本地大模型极速部署与调用指南
人工智能·ai·aigc·llama
hyunbar19 小时前
llama_index.vector_stores 模块没有怎么办?
python·llama
Felven2 天前
llama.cpp 模型使用指南-本地大语言模型部署实践与长上下文内存估算参考手册
ai·语言模型·llama
skywalk81632 天前
使用llama.cpp运行模型unsloth/Qwen3.6-35B-A3B-UD-Q4_K_M.gguf 速度大约5.5 token/s
人工智能·llama
小小测试开发4 天前
本地运行 AI 完全指南:从 Ollama 到 llama.cpp,2026 年不再需要云端 API
人工智能·llama
不懒不懒5 天前
【基于讯飞语音识别 + DeepSeek 大模型的课堂视频智能转写与分析系统】
大模型·llm·llama·moviepy·智慧课堂·deepseek3
松☆6 天前
torchtitan-npu:在Ascend 910上从头预训练Llama-3的完整实录
llama
嗝o゚6 天前
昇腾CANN cann-recipes-infer 仓:LLaMA 推理最佳实践,从模型到服务
人工智能·llama·cann
子榆.6 天前
CANN TensorFlow适配器:当tf.matmul跑在昇腾NPU上时在底层发生了什么
人工智能·neo4j·llama