#!/bin/bash # Parallel reprocessing script for updating existing DROID .npz files # Distributes files across 5 machines, each with 8 GPUs (40 GPUs total) # # Usage: # bash run_reprocessing_8gpu.sh [--dry-run] # # MACHINE_ID: 0, 1, 2, 3, or 4 # Parse arguments if [ $# -eq 0 ]; then echo "Error: Missing machine ID argument" echo "Usage: bash run_reprocessing_8gpu.sh [--dry-run]" echo " MACHINE_ID: 0, 1, 2, 3, or 4" echo "" echo "Distribution (4,976 total files, ~995 per machine):" echo " Machine 0: files 0 to 995" echo " Machine 1: files 995 to 1990" echo " Machine 2: files 1990 to 2985" echo " Machine 3: files 2985 to 3980" echo " Machine 4: files 3980 to 4976" exit 1 fi MACHINE_ID=$1 shift # Validate machine ID if [ $MACHINE_ID -lt 0 ] || [ $MACHINE_ID -gt 4 ]; then echo "Error: MACHINE_ID must be 0, 1, 2, 3, or 4" exit 1 fi # Parse dry-run flag DRY_RUN_FLAG="" if [ "$1" == "--dry-run" ]; then DRY_RUN_FLAG="--dry-run" echo "DRY RUN MODE - Will check what needs reprocessing without saving" fi # Configuration DATA_DIR="/mnt/kevin/data/droid_processed_1000pts" TOTAL_FILES=4976 TOTAL_MACHINES=5 NUM_GPUS=8 FILES_PER_MACHINE=$(( TOTAL_FILES / TOTAL_MACHINES )) # Calculate file range for this machine MACHINE_START=$(( MACHINE_ID * FILES_PER_MACHINE )) # Last machine gets remaining files if [ $MACHINE_ID -eq 4 ]; then MACHINE_END=$TOTAL_FILES else MACHINE_END=$(( (MACHINE_ID + 1) * FILES_PER_MACHINE )) fi FILES_PER_GPU=$(( (MACHINE_END - MACHINE_START) / NUM_GPUS )) echo "========================================" echo "DROID Reprocessing - Machine $MACHINE_ID" echo "========================================" echo " Total files: $TOTAL_FILES" echo " Total machines: $TOTAL_MACHINES" echo " File range: $MACHINE_START to $MACHINE_END" echo " GPUs: $NUM_GPUS" echo " Files per GPU: ~$FILES_PER_GPU" echo " Data directory: $DATA_DIR" if [ -n "$DRY_RUN_FLAG" ]; then echo " Mode: DRY RUN" else echo " Mode: REPROCESS" fi echo "========================================" # Create log directory mkdir -p $DATA_DIR/reprocessing_logs # Launch 8 parallel processes for GPU_ID in {0..7}; do START_IDX=$(( MACHINE_START + GPU_ID * FILES_PER_GPU )) END_IDX=$(( MACHINE_START + (GPU_ID + 1) * FILES_PER_GPU )) # Last GPU gets remaining files if [ $GPU_ID -eq 7 ]; then END_IDX=$MACHINE_END fi echo "Launching GPU $GPU_ID: files $START_IDX to $END_IDX" CUDA_VISIBLE_DEVICES=$GPU_ID \ /mnt/kevin/envs/miniconda3/envs/atm_ati_vdm_droid/bin/python \ scripts/reprocess_existing_npz.py \ --data-dir $DATA_DIR \ --start-idx $START_IDX \ --end-idx $END_IDX \ --gpu-id $GPU_ID \ $DRY_RUN_FLAG \ > $DATA_DIR/reprocessing_logs/m${MACHINE_ID}_gpu${GPU_ID}.log 2>&1 & done echo "" echo "All 8 GPU processes launched on Machine $MACHINE_ID!" echo "" echo "Monitor progress:" echo " tail -f $DATA_DIR/reprocessing_logs/m${MACHINE_ID}_gpu0.log" echo "" echo "Check completion:" echo " grep 'Reprocessing Complete' $DATA_DIR/reprocessing_logs/m${MACHINE_ID}_*.log | wc -l" echo "" echo "Stop all:" echo " pkill -f reprocess_existing_npz" echo "" echo "Machine breakdown:" echo " Machine 0: files 0 → 995 (995 files)" echo " Machine 1: files 995 → 1990 (995 files)" echo " Machine 2: files 1990 → 2985 (995 files)" echo " Machine 3: files 2985 → 3980 (995 files)" echo " Machine 4: files 3980 → 4976 (996 files)" echo ""