Set up and compile custom llama.cpp for quantization
mainTo support image models, you must use a patched version of llama.cpp. Follow these steps to prepare and compile the llama-quantize binary.
- Fix line endings: Run
python fix_lines_ending.pyto ensure the patch file is valid (converts CRLF to LF). - Clone llama.cpp:
git clone https://github.com/ggerganov/llama.cpp - Apply Patch:
cd llama.cpp git checkout tags/b3962 git apply ..\lcpp.patch - Compile:
For Visual Studio 2019, Linux, etc.:
mkdir build
cmake -B build
cmake --build build --config Debug -j10 --target llama-quantize
cd ..For Visual Studio 2022:
First, configure with C++17 support:
mkdir build
cmake -B build -DCMAKE_CXX_STANDARD=17 -DCMAKE_CXX_STANDARD_REQUIRED=ON -DCMAKE_CXX_FLAGS="-std=c++17"Then, edit llama.cpp\common\log.cpp to insert these lines after the first line:
#include "log.h"
#define _SILENCE_CXX23_CHRONO_DEPRECATION_WARNING
#include <chrono>Finally, build:
cmake --build build --config Debug -j10 --target llama-quantize
cd ..git clone https://github.com/ggerganov/llama.cpp
cd llama.cpp
git checkout tags/b3962
git apply ..\lcpp.patch