dskjal
広告
広告

Windows で llama.cpp のビルド

カテゴリ:deeplearning

Visual Studio のインストール

C++ のビルド環境の構築。

https://visualstudio.microsoft.com/ja/vs/community/

CUDA のインストール

CUDA Toolkit Archive

ソースの取得

git clone https://github.com/ggerganov/llama.cpp.git
cd llama.cpp

CMake のインストール

winget install CMake

powershell 再起動

ビルド

windows はデフォルトで curl が使えないので。curl を off。CUDA を使わず CPU を使う場合は -DGGML_CUDA=ON を削除。

cmake -B build -DLLAMA_CURL=OFF -DGGML_CUDA=ON
cmake --build build --config Release

python ツールのインストール

python -m pip install -r requirements.txt

共有しないなら venv を使う。

python -m venv venv
./venv/Scripts/activate
pip install -r requirements.txt

モデルが fp16/bf16 ではない、もしくは model-00001-of-00002.safetensors のように結合されていない場合、モデルを変換する必要がある。

powershell で以下のようにコマンドを実行する。

HF_MODEL_PATH="/path/to/Llama-3.2-3B-Instruct"
OUTPUT_BF16_GGUF="Llama-3.2-3B-Instruct-BF16.gguf"
python convert-hf-to-gguf.py "$HF_MODEL_PATH" --outtype bf16 --outfile "$OUTPUT_BF16_GGUF"

powershell で以下のコマンドを実行。Q8_0 は Q4_K_M や Q6_K_M などに書き換える。

QUANTIZE_TOOL="./build/bin/Release/llama-quantize.exe"
OUTPUT_BF16_GGUF="Llama-3.2-3B-Instruct-BF16.gguf"
OUTPUT_Q8_0_GGUF="Llama-3.2-3B-Instruct-Q8_0.gguf"
"$QUANTIZE_TOOL" "$OUTPUT_BF16_GGUF" "$OUTPUT_Q8_0_GGUF" Q8_0

広告
広告

カテゴリ