evaluation_all / code /run_one_cat.sh
yqi19's picture
Upload folder using huggingface_hub
8aa2acf verified
Raw
History Blame Contribute Delete
2.45 kB
#!/usr/bin/env bash
set -uo pipefail
# Evaluate ONE GR00T checkpoint on its own conflict experiment.
# Starts a dedicated GR00T zmq server on the given GPU, runs the OOD sweep on
# the same GPU (ManiSkill GPU physics+render), then stops the server.
#
# Usage: run_one_cat.sh <category> <gpu> <port> [seed=42] [total_episodes=200]
ROOT=/workspace/groot_eval
HARNESS="${ROOT}/harness"
cat="${1:?category}"
gpu="${2:?gpu}"
port="${3:?port}"
SEED="${4:-42}"
TOTAL="${5:-200}"
OUT_ROOT="${OUT_ROOT:-${ROOT}/results}"
LOG_DIR="${ROOT}/logs/tmux"
mkdir -p "${LOG_DIR}"
slog="${LOG_DIR}/server_${cat}.log"
clog="${LOG_DIR}/client_${cat}.log"
exp_root="${OUT_ROOT}/${cat}/experiments"
results_txt="${OUT_ROOT}/${cat}/${cat}_ood_seed${SEED}.txt"
mkdir -p "${exp_root}" "$(dirname "${results_txt}")"
echo "[$(date +%H:%M:%S)] ${cat}: starting GR00T server gpu=${gpu} port=${port}"
( cd "${ROOT}/gr00t_repo/codebase" && CUDA_VISIBLE_DEVICES="${gpu}" \
HF_HOME="${ROOT}/.hf_cache" HF_TOKEN="$(cat ${ROOT}/.hf_token)" \
NO_ALBUMENTATIONS_UPDATE=1 TOKENIZERS_PARALLELISM=false \
"${ROOT}/.venv_groot/bin/python" -m gr00t.eval.run_gr00t_server \
--model-path "${ROOT}/checkpoints/${cat}" \
--embodiment-tag new_embodiment --device cuda:0 \
--host 127.0.0.1 --port "${port}" ) > "${slog}" 2>&1 &
spid=$!
ok=0
for _ in $(seq 1 300); do
kill -0 "${spid}" 2>/dev/null || { echo "[${cat}] SERVER DIED during load"; break; }
grep -q "Server ready\|Server is ready and listening" "${slog}" 2>/dev/null && { ok=1; break; }
sleep 3
done
if [ "${ok}" != "1" ]; then
echo "[${cat}] server not ready; tail server log:"; tail -n 30 "${slog}"
kill "${spid}" 2>/dev/null; wait "${spid}" 2>/dev/null
exit 1
fi
echo "[$(date +%H:%M:%S)] ${cat}: server ready (pid ${spid}); running OOD sweep (seed=${SEED} total=${TOTAL})"
CUDA_VISIBLE_DEVICES="${gpu}" \
HOST=127.0.0.1 PORT="${port}" SIM_BACKEND=gpu \
EXPERIMENT_ROOT="${exp_root}" GROOT_MAIN="${HARNESS}/groot_main.py" \
MS_PY="${ROOT}/.venv_ms/bin/python" \
MANISKILL_CONFLICT_ROOT="${ROOT}/genie_repo/maniskill_conflict" \
bash "${HARNESS}/run_ood_groot_inference.sh" "${cat}" "${SEED}" "${TOTAL}" "${results_txt}" \
> "${clog}" 2>&1
rc=$?
kill "${spid}" 2>/dev/null; wait "${spid}" 2>/dev/null
echo "[$(date +%H:%M:%S)] ${cat}: DONE rc=${rc} results=${results_txt}"
grep -E "^overall_" "${results_txt}" 2>/dev/null || echo "[${cat}] (no overall_ line — check ${clog})"
exit ${rc}