prismvla-procthor-engine / generate_parallel.sh
whab13's picture
initial: procthor engine + parallel launcher + setup + README
bb54e71 verified
Raw
History Blame Contribute Delete
1.96 kB
#!/bin/bash
# Parallel data generation.
#
# AI2-THOR launches one CloudRendering process per shard; each shard pins to one GPU
# (the engine doesn't share a GPU well — Unity context). For a typical rented box:
# 1x GPU -> 1 shard
# 4x GPU -> 4 shards (recommended)
# 8x GPU -> 8 shards
#
# Each shard writes its own parquet to <OUT_DIR>/aligned_routes_procthor_shard<NNN>.parquet
# and its own frames to <OUT_DIR>/frames/procthor_<idx>/
#
# Tunables:
N_EPISODES_PER_SHARD=500 # 500 x 4 shards = 2000 eps (~5 GB on disk)
N_SHARDS=4 # = # GPUs on the box (use `nvidia-smi -L | wc -l`)
OUT_DIR="${OUT_DIR:-./procthor_data}"
mkdir -p "$OUT_DIR"
source .venv/bin/activate
# Detect available GPUs
N_GPUS=$(nvidia-smi -L | wc -l)
if [ "$N_GPUS" -lt "$N_SHARDS" ]; then
echo "WARNING: only $N_GPUS GPUs visible but $N_SHARDS shards requested. Capping."
N_SHARDS=$N_GPUS
fi
echo "Launching $N_SHARDS shards x $N_EPISODES_PER_SHARD episodes each on $N_GPUS GPUs"
echo "Output dir: $OUT_DIR"
PIDS=()
for SHARD in $(seq 0 $((N_SHARDS-1))); do
GPU=$SHARD
START_IDX=$((SHARD * N_EPISODES_PER_SHARD))
LOG="$OUT_DIR/shard${SHARD}.log"
echo " shard $SHARD: GPU $GPU, episodes [$START_IDX, $((START_IDX+N_EPISODES_PER_SHARD))) -> $LOG"
CUDA_VISIBLE_DEVICES=$GPU python -m procthor_engine.generate \
--out-dir "$OUT_DIR" \
--n-episodes "$N_EPISODES_PER_SHARD" \
--start-idx "$START_IDX" \
--shard-idx "$SHARD" \
--device 0 \
> "$LOG" 2>&1 &
PIDS+=($!)
sleep 5 # stagger to avoid CloudRendering port collisions
done
echo
echo "Shards launched. PIDs: ${PIDS[*]}"
echo "Watch progress:"
echo " tail -F $OUT_DIR/shard*.log"
echo
echo "When all shards finish, upload the data with: bash upload_to_hf.sh"
wait "${PIDS[@]}"
echo
echo "=== ALL SHARDS DONE ==="
ls -la "$OUT_DIR"/aligned_routes_procthor_shard*.parquet 2>/dev/null
echo "Total disk used:"
du -sh "$OUT_DIR"