Jeveration-GGUF / setup.sh
Meshwa's picture
Model card, CPU inference code (llama.cpp helper + Python), set-up scripts, examples
6a8ca2a verified
Raw History Blame Contribute Delete
2.77 kB
#!/usr/bin/env bash
# One-time setup, run from the repo root. Idempotent: finished steps are skipped on re-runs.
# 1. llama.cpp at a pinned commit, built as shared libraries (CPU)
# 2. tools/jev-backbone, the helper that runs the GGUF backbone with Jeveration's attention mask
# 3. the Jeveration inference code (image head, decoder, prompts) at a pinned commit
# 4. a Python 3.12 venv with CPU PyTorch
# Then: bash scripts/download.sh (weights around the backbone)
#
# Needs: git, cmake, a C++17 compiler, and uv (https://docs.astral.sh/uv/) or python3.12.
# GPU: pass e.g. LLAMA_CMAKE_ARGS="-DGGML_CUDA=ON" to build llama.cpp with CUDA.
set -euo pipefail
cd "$(dirname "$0")"
LLAMA_COMMIT=918fe468dbaae80bcdaf975c1b368023f2578ead # ggml-org/llama.cpp, 2026-11-28
JEV_COMMIT=cf74be36efe522bdf49adc3326fe233190731812 # Carol-lyh/Jeveration, 2026-11-23
JOBS="${JOBS:-$(nproc)}"
pinned_clone() { # url dir commit
if [ ! -d "$2/.git" ]; then
git init -q "$2" && git -C "$2" remote add origin "$1"
fi
if [ "$(git -C "$2" rev-parse -q --verify HEAD 2>/dev/null)" != "$3" ]; then
git -C "$2" fetch -q --depth 1 origin "$3" && git -C "$2" checkout -q FETCH_HEAD
fi
echo "$2 at $(git -C "$2" rev-parse --short HEAD)"
}
echo "== 1/4 llama.cpp"
pinned_clone https://github.com/ggml-org/llama.cpp llama.cpp $LLAMA_COMMIT
if [ ! -f llama.cpp/build/bin/libllama.so ] || [ ! -x llama.cpp/build/bin/llama-quantize ]; then
# shellcheck disable=SC2086
cmake -S llama.cpp -B llama.cpp/build -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON -DLLAMA_CURL=OFF \
-DLLAMA_BUILD_TESTS=OFF -DLLAMA_BUILD_SERVER=OFF ${LLAMA_CMAKE_ARGS:-} > llama.cpp/build.log
cmake --build llama.cpp/build -j "$JOBS" --target llama llama-quantize >> llama.cpp/build.log
fi
echo "== 2/4 tools/jev-backbone"
if [ ! -x tools/jev-backbone ] || [ tools/jev_backbone.cpp -nt tools/jev-backbone ]; then
g++ -O2 -std=c++17 tools/jev_backbone.cpp -Illama.cpp/include -Illama.cpp/ggml/include \
-Lllama.cpp/build/bin -lllama -lggml -lggml-base -Wl,-rpath,"$PWD/llama.cpp/build/bin" -o tools/jev-backbone
fi
echo "built tools/jev-backbone"
echo "== 3/4 Jeveration code"
pinned_clone https://github.com/Carol-lyh/Jeveration Jeveration $JEV_COMMIT
echo "== 4/4 Python venv"
if [ ! -x .venv/bin/python ]; then
if command -v uv > /dev/null; then uv venv -q --python 3.12 .venv; else python3.12 -m venv .venv; fi
fi
if command -v uv > /dev/null; then PIP=(uv pip install -q --python .venv/bin/python); else PIP=(.venv/bin/python -m pip install -q); fi
"${PIP[@]}" torch==2.15.0 torchvision==0.29.2 --index-url https://download.pytorch.org/whl/cpu # CPU wheels: no CUDA download
"${PIP[@]}" -r requirements.txt
echo "SETUP DONE. Next: bash scripts/download.sh"