69 lines
4.8 KiB
Bash
Executable file
69 lines
4.8 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
# Igneum proving v0: Ubuntu 24.04 side (inside WSL2). Run by SETUP-PROVER.bat; can be re-run, every step is idempotent.
|
|
# Installs: build tools, the NVIDIA CUDA toolkit for WSL-Ubuntu (the WSL-specific repository; the driver comes from
|
|
# Windows and must NOT be installed here), rustup + stable Rust, sp1up + the SP1 toolchain (succinct rustc, cargo-prove).
|
|
# SP1's GPU prover (v6.x): no Docker and no NVIDIA Container Toolkit any more; the SDK downloads a native
|
|
# `sp1-gpu-server` binary (about 134 MB, release asset sp1_gpu_server_v6.8.1_x86_64.tar.gz) into ~/.sp1/bin on
|
|
# the first SP1_PROVER=cuda run. Source: https://docs.succinct.xyz/docs/sp1/generating-proofs/hardware-acceleration
|
|
# ("Docker and the NVIDIA Container Toolkit are no longer required", "CUDA 12 runtime and a compatible NVIDIA driver",
|
|
# "24GB or more VRAM", Linux x86_64). Version-specific lines below are approximate and dated 3 October 2026.
|
|
set -euo pipefail
|
|
HERE="$(cd "$(dirname "$0")" && pwd)"
|
|
log() { echo "[setup-wsl $(date +%H:%M:%S)] $*"; }
|
|
|
|
if ! grep -qi microsoft /proc/version; then log "this does not look like WSL; continuing anyway"; fi
|
|
if [ ! -e /usr/lib/wsl/lib/libcuda.so.1 ]; then
|
|
log "WARNING: /usr/lib/wsl/lib/libcuda.so.1 is missing: the Windows NVIDIA driver is not exposing the GPU to WSL. Update the Windows driver and run 'wsl --update' in PowerShell."
|
|
fi
|
|
|
|
log "1/5 apt packages (build-essential, clang, pkg-config, libssl-dev, git, curl, python3, protobuf-compiler, about 300 MB approximate)"
|
|
sudo apt-get update -qq
|
|
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y -qq build-essential clang pkg-config libssl-dev git curl ca-certificates python3 wget gnupg2 protobuf-compiler >/dev/null
|
|
|
|
log "2/5 NVIDIA CUDA toolkit for WSL-Ubuntu (repository wsl-ubuntu, cuda-toolkit-12-8, about 3 GB approximate; the driver is NOT installed here)"
|
|
# Source: https://docs.nvidia.com/cuda/wsl-user-guide/index.html (CUDA on WSL User Guide, "Option 1: Using the WSL-Ubuntu Package").
|
|
if ! dpkg -s cuda-keyring >/dev/null 2>&1; then
|
|
wget -q https://developer.download.nvidia.com/compute/cuda/repos/wsl-ubuntu/x86_64/cuda-keyring_1.1-1_all.deb -O /tmp/cuda-keyring.deb
|
|
sudo dpkg -i /tmp/cuda-keyring.deb >/dev/null
|
|
sudo apt-get update -qq
|
|
fi
|
|
if ! dpkg -s cuda-toolkit-12-8 >/dev/null 2>&1; then
|
|
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y -qq cuda-toolkit-12-8 >/dev/null || sudo DEBIAN_FRONTEND=noninteractive apt-get install -y -qq cuda-toolkit-12-9 >/dev/null
|
|
fi
|
|
CUDA_DIR="$(ls -d /usr/local/cuda-12.* 2>/dev/null | sort -V | tail -1 || true)"
|
|
if [ -n "$CUDA_DIR" ]; then
|
|
grep -q 'usr/local/cuda' ~/.bashrc || printf '\nexport PATH="%s/bin:$PATH"\nexport LD_LIBRARY_PATH="%s/lib64:/usr/lib/wsl/lib:${LD_LIBRARY_PATH:-}"\n' "$CUDA_DIR" "$CUDA_DIR" >> ~/.bashrc
|
|
export PATH="$CUDA_DIR/bin:$PATH"; export LD_LIBRARY_PATH="$CUDA_DIR/lib64:/usr/lib/wsl/lib:${LD_LIBRARY_PATH:-}"
|
|
log "CUDA: $("$CUDA_DIR/bin/nvcc" --version | tail -1)"
|
|
else
|
|
log "WARNING: no /usr/local/cuda-12.* after the install; SP1_PROVER=cuda will fail until the toolkit is present"
|
|
fi
|
|
nvidia-smi --query-gpu=name,memory.total,driver_version --format=csv,noheader 2>/dev/null | sed 's/^/GPU inside WSL: /' || log "nvidia-smi not available inside WSL (the GPU may still work; the Windows driver decides)"
|
|
|
|
log "3/5 Rust (rustup, stable; about 500 MB approximate)"
|
|
if [ ! -x "$HOME/.cargo/bin/cargo" ]; then
|
|
curl -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal >/dev/null
|
|
fi
|
|
export PATH="$HOME/.cargo/bin:$HOME/.sp1/bin:$PATH"
|
|
rustup show active-toolchain || true
|
|
|
|
log "4/5 sp1up and the SP1 toolchain (cargo-prove 21 MB + succinct rust toolchain about 300 MB download, 1 GB on disk, approximate)"
|
|
# Source: https://docs.succinct.xyz/docs/sp1/getting-started/install
|
|
if [ ! -x "$HOME/.sp1/bin/sp1up" ]; then
|
|
curl -L https://sp1up.succinct.xyz | bash >/dev/null
|
|
fi
|
|
"$HOME/.sp1/bin/sp1up" --version v6.8.1 2>&1 | tail -3 || "$HOME/.sp1/bin/sp1up" 2>&1 | tail -3
|
|
cargo prove --version
|
|
cargo +succinct --version
|
|
|
|
log "5/5 copying the proving sources into the Linux file system (cargo on /mnt/c is slow) and pre-building the host with the cuda feature"
|
|
DEST="$HOME/igneum-prove"
|
|
mkdir -p "$DEST"
|
|
rsync -a --delete --exclude target "$HERE/package/" "$DEST/" 2>/dev/null || cp -r "$HERE/package/." "$DEST/"
|
|
# Re-stamp every copied source: rsync keeps the Mac's dates and cargo rebuilds by mtime, so a file older than the last build
|
|
# here would be taken as unchanged (the stale-build class, 4 and 5 October 2026).
|
|
find "$DEST" -name target -prune -o -type f -exec touch {} + 2>/dev/null || true
|
|
cd "$DEST/proving/igneum-prove"
|
|
# The guest is built by host/build.rs through cargo-prove; the host links sp1-sdk with the cuda feature.
|
|
cargo build --release -p igneum-prove-export -p igneum-prove-host --features igneum-prove-host/cuda 2>&1 | tail -5
|
|
log "done. Double-click PROVE-BLOCK.bat on Windows to prove the fixture block on the GPU and on the CPU."
|