idacy's picture
TRACE artifact: framework, corpus, instrumented case, provider case, evaluators, figures
2955ecc verified
Raw
History Blame Contribute Delete
1.3 kB
#!/usr/bin/env bash
# TRACE study setup: create a local venv and install PyTorch into it.
# Run once per node. Needs either outbound access to pypi.org, or a
# wheels/ directory shipped inside this bundle (then no network is used).
set -euo pipefail
HERE="$(cd "$(dirname "$0")" && pwd)"
PY="${PYTHON:-python3}"
echo "== python: $($PY --version 2>&1)"
if [[ ! -d "$HERE/venv" ]]; then
"$PY" -m venv "$HERE/venv"
fi
# shellcheck disable=SC1091
source "$HERE/venv/bin/activate"
if [[ -d "$HERE/wheels" ]]; then
echo "== installing torch from bundled wheels (no network)"
if [[ -f "$HERE/WHEELS-SHA256SUMS" ]]; then
(
cd "$HERE"
sha256sum -c WHEELS-SHA256SUMS >/dev/null
) || { echo "bundled wheel integrity check failed"; exit 2; }
echo "== bundled wheel integrity check passed"
fi
pip install --quiet --no-index --find-links "$HERE/wheels" torch
else
echo "== installing torch from PyPI (needs outbound network this once)"
pip install --quiet --upgrade pip
pip install torch
fi
python - <<'EOF'
import torch
print(f"== torch {torch.__version__}; cuda available: {torch.cuda.is_available()}")
if torch.cuda.is_available():
for i in range(torch.cuda.device_count()):
print(f"== gpu {i}: {torch.cuda.get_device_name(i)}")
EOF
echo "== setup done"