使用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 小时前
ComfyUI - ELLA:解锁ComfyUI图像生成新境界的神奇插件
人工智能·gpt·stable diffusion·aigc·音视频·midjourney·llama
Coder个人博客2 天前
Llama.cpp GGML 模块深度分析
人工智能·自动驾驶·llama
牛奶咖啡.8542 天前
基于Llama-Factory/Qwen2.5-1.5b自定义数据集LoRA微调实战【PPO/RLHF/训练/评估】
语言模型·llm·llama·rl·ppo
白云千载尽3 天前
LLaMA-Factory 入门(二): 深入技术解析
人工智能·llama
Coder个人博客3 天前
Llama.cpp 整体架构分析
人工智能·自动驾驶·llama
Coder个人博客4 天前
Llama.cpp Tools 实用工具深度分析
人工智能·自动驾驶·llama
Coder个人博客4 天前
Llama.cpp Examples 示例程序深度分析
人工智能·自动驾驶·llama
白云千载尽4 天前
LLaMA-Factory 入门(一):Ubuntu20 下大模型微调与部署
人工智能·算法·大模型·微调·llama
Elaine3364 天前
基于 Qwen2.5 与 LLaMA-Factory 的 LoRA 微调实战
人工智能·lora·微调·llama·llama-factory
小杨互联网5 天前
PyTorch分布式训练实战:从零构建Llama模型多GPU训练系统
人工智能·pytorch·llama