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

相关推荐
小镇cxy8 小时前
小模型微调过程记录
ai·llama
CV-杨帆14 小时前
复现 LLama Guard Llama-Prompt-Guard-2-86M / Llama-Prompt-Guard-2-22M
llama
学习是生活的调味剂14 小时前
LLaMA大模型家族发展介绍
人工智能·llama
love530love14 小时前
【笔记】解决 Stable Diffusion WebUI 启动 “找不到llama_cpp模块”
运维·windows·笔记·python·stable diffusion·github·llama
同学小张3 天前
【端侧AI 与 C++】1. llama.cpp源码编译与本地运行
开发语言·c++·aigc·llama·agi·ai-native
程序员与背包客_CoderZ7 天前
C/C++版LLM推理框架Llama.cpp——入门与编码实战
c语言·开发语言·网络·c++·人工智能·语言模型·llama
java_logo9 天前
LOBE-CHAT Docker 容器化部署指南
运维·docker·语言模型·容器·llama
AI大模型9 天前
手把手教你用LlamaIndex搭建RAG系统,让LLM告别“幻觉”,提升回答质量!
llm·agent·llama
开发者导航18 天前
【开发者导航】轻量可微调且开源的大语言模型家族:LLaMA
语言模型·开源·llama
缘友一世18 天前
借助LLama_Factory工具对大模型进行lora微调
llama