| # Reproducible Phase 0 environment (speculative decoding, RTX 4060 Ti 16 GB) | |
| # Usage: source scripts/spec-env.sh (from the repo root) | |
| # Python (uv) + CUDA toolkit in user-space — no sudo. | |
| set -euo pipefail | |
| REPO="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" | |
| # First time: syncs .venv from pyproject.toml + uv.lock | |
| if [ ! -x "$REPO/.venv/bin/ruff" ]; then | |
| echo "[spec-env] uv sync ..." | |
| (cd "$REPO" && uv sync) || return 1 | |
| fi | |
| # CUDA toolkit: runfile installed in $HOME/cuda (no sudo) — canonical path. | |
| # Fallback: toolkit merged from the venv wheels (scripts/prepare-cuda.sh). | |
| if [ -x "$HOME/cuda/bin/nvcc" ]; then | |
| export CUDA_HOME="$HOME/cuda" | |
| else | |
| if [ ! -x "$REPO/.venv/cuda/bin/nvcc" ]; then | |
| echo "[spec-env] preparing merged CUDA toolkit (fallback) ..." | |
| bash "$REPO/scripts/prepare-cuda.sh" || return 1 | |
| fi | |
| export CUDA_HOME="$REPO/.venv/cuda" | |
| fi | |
| export PATH="$REPO/.venv/bin:$PATH" | |
| # The CUDA runfile installs the real libraries in targets/x86_64-linux/lib | |
| export LD_LIBRARY_PATH="$CUDA_HOME/targets/x86_64-linux/lib:$CUDA_HOME/lib64:$CUDA_HOME/lib:${LD_LIBRARY_PATH:-}" | |
| export LLAMA_CPP_HOME="${LLAMA_CPP_HOME:-$HOME/llama.cpp}" | |
| export LLAMA_CPP_BIN="$LLAMA_CPP_HOME/build/bin" | |
| echo "[spec-env] nvcc: $("$CUDA_HOME/bin/nvcc" --version | tail -2 | head -1)" | |
| echo "[spec-env] llama.cpp bin: $LLAMA_CPP_BIN" | |