1
0

ci-run.sh 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #!/bin/bash
  2. set -euo pipefail
  3. this=$(realpath "$0"); readonly this
  4. cd "$(dirname "$this")"
  5. shellcheck "$this"
  6. if (( $# != 1 && $# != 2 )); then
  7. cat >&2 <<'EOF'
  8. usage:
  9. ci-run.sh <tmp_dir> [<cache_dir>]
  10. This script wraps ci/run.sh:
  11. * 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>.
  12. (openllama_3b_v2: quantized models are about 30GB)
  13. * Persistent model and data files are synced to and from <cache_dir>,
  14. excluding generated .gguf files.
  15. (openllama_3b_v2: persistent files are about 6.6GB)
  16. * <cache_dir> defaults to ~/.cache/llama.cpp
  17. EOF
  18. exit 1
  19. fi
  20. cd .. # => llama.cpp repo root
  21. tmp="$1"
  22. mkdir -p "$tmp"
  23. tmp=$(realpath "$tmp")
  24. echo >&2 "Using tmp=$tmp"
  25. cache="${2-$HOME/.cache/llama.cpp}"
  26. mkdir -p "$cache"
  27. cache=$(realpath "$cache")
  28. echo >&2 "Using cache=$cache"
  29. _sync() {
  30. local from="$1"; shift
  31. local to="$1"; shift
  32. echo >&2 "Syncing from $from to $to"
  33. mkdir -p "$from" "$to"
  34. rsync -a "$from" "$to" --delete-during "$@"
  35. }
  36. _sync "$(realpath .)/" "$tmp/llama.cpp"
  37. _sync "$cache/ci-mnt/models/" "$tmp/llama.cpp/ci-mnt/models/"
  38. cd "$tmp/llama.cpp"
  39. bash ci/run.sh ci-out ci-mnt
  40. _sync 'ci-mnt/models/' "$cache/ci-mnt/models/" --exclude='*.gguf' -P