ci-run.sh
1 #!/bin/bash 2 set -euo pipefail 3 this=$(realpath "$0"); readonly this 4 cd "$(dirname "$this")" 5 shellcheck "$this" 6 7 if (( $# != 1 && $# != 2 )); then 8 cat >&2 <<'EOF' 9 usage: 10 ci-run.sh <tmp_dir> [<cache_dir>] 11 12 This script wraps ci/run.sh: 13 * If <tmp_dir> is a ramdisk, you can reduce writes to your SSD. If <tmp_dir> is not a ramdisk, keep in mind that total writes will increase by the size of <cache_dir>. 14 (openllama_3b_v2: quantized models are about 30GB) 15 * Persistent model and data files are synced to and from <cache_dir>, 16 excluding generated .gguf files. 17 (openllama_3b_v2: persistent files are about 6.6GB) 18 * <cache_dir> defaults to ~/.cache/llama.cpp 19 EOF 20 exit 1 21 fi 22 23 cd .. # => llama.cpp repo root 24 25 tmp="$1" 26 mkdir -p "$tmp" 27 tmp=$(realpath "$tmp") 28 echo >&2 "Using tmp=$tmp" 29 30 cache="${2-$HOME/.cache/llama.cpp}" 31 mkdir -p "$cache" 32 cache=$(realpath "$cache") 33 echo >&2 "Using cache=$cache" 34 35 _sync() { 36 local from="$1"; shift 37 local to="$1"; shift 38 39 echo >&2 "Syncing from $from to $to" 40 mkdir -p "$from" "$to" 41 rsync -a "$from" "$to" --delete-during "$@" 42 } 43 44 _sync "$(realpath .)/" "$tmp/llama.cpp" 45 _sync "$cache/ci-mnt/models/" "$tmp/llama.cpp/ci-mnt/models/" 46 47 cd "$tmp/llama.cpp" 48 bash ci/run.sh ci-out ci-mnt 49 50 _sync 'ci-mnt/models/' "$cache/ci-mnt/models/" --exclude='*.gguf' -P