openpi / droid /scripts /run_scan_machine2.sh
zhicao's picture
Upload folder using huggingface_hub
b584148 verified
Raw
History Blame Contribute Delete
2.7 kB
#!/bin/bash
# Run parallel scanning on Machine 2 in chunks (episodes 46117-92232)
# Processes in 3000-episode chunks to avoid OOM
set -e
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$SCRIPT_DIR"
# Configuration for Machine 2
TOTAL_START=46117
TOTAL_END=92233 # Exclusive, so this does 46117-92232
CHUNK_SIZE=3000
NUM_WORKERS=32 # Adjust based on available CPUs
FINAL_OUTPUT="valid_episodes_machine2.json"
echo "=========================================="
echo "DROID Scanner - Machine 2 (Chunked)"
echo "=========================================="
echo "Total range: $TOTAL_START to $((TOTAL_END-1))"
echo "Chunk size: $CHUNK_SIZE episodes"
echo "Workers per chunk: $NUM_WORKERS"
echo "Final output: $FINAL_OUTPUT"
echo "=========================================="
echo ""
# Array to store chunk output files
CHUNK_FILES=()
# Process in chunks
for ((start=$TOTAL_START; start<$TOTAL_END; start+=CHUNK_SIZE)); do
end=$((start + CHUNK_SIZE))
if [ $end -gt $TOTAL_END ]; then
end=$TOTAL_END
fi
chunk_output="valid_episodes_machine2_chunk_${start}_${end}.json"
CHUNK_FILES+=("$chunk_output")
echo ""
echo "=========================================="
echo "Processing chunk: $start to $((end-1))"
echo "=========================================="
python3 scan_valid_episodes_parallel.py \
--start $start \
--end $end \
--num-workers $NUM_WORKERS \
--output "$chunk_output" \
--batch-size 500 \
--max-frames 400 \
--checkpoint-interval 1000
if [ $? -ne 0 ]; then
echo "ERROR: Chunk $start-$((end-1)) failed"
exit 1
fi
echo "✓ Chunk complete: $chunk_output"
done
echo ""
echo "=========================================="
echo "All chunks complete! Merging results..."
echo "=========================================="
# Merge all chunk results
python3 merge_scan_results.py \
"${CHUNK_FILES[@]}" \
--output "$FINAL_OUTPUT"
if [ $? -eq 0 ]; then
echo ""
echo "=========================================="
echo "✓ Machine 2 scanning complete!"
echo "=========================================="
echo "Final results saved to: $FINAL_OUTPUT"
echo ""
echo "Chunk files created (can be deleted):"
for chunk in "${CHUNK_FILES[@]}"; do
echo " - $chunk"
done
echo ""
echo "Next step: Merge with Machine 1 results:"
echo " python merge_scan_results.py \\"
echo " valid_episodes_machine1.json \\"
echo " valid_episodes_machine2.json \\"
echo " --output valid_episodes_combined.json"
echo ""
else
echo "ERROR: Merging failed on Machine 2"
exit 1
fi