1.下载
git clone https://github.com/ggerganov/llama.cpp
cd llama.cpp
2.根据cpu和cuda编译
🖥️ 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
3.量化
1.将 safetensors 格式转成 gguf
cd ~/code/llama.cpp/build_cuda/bin
python convert_hf_to_gguf.py /mnt/workspace/models/Qwen2.5-1.5B-Instruct --outfile /mnt/workspace/Qwen2.5-1.5B-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-