# Multi-GPU DROID Preprocessing Guide Process the entire DROID dataset in parallel using independent GPU processes (no inter-GPU communication). ## Overview - **Mode**: Independent processing (no DDP, no communication) - **Recommended**: Single machine with 8 GPUs - **Optional**: Two machines with 16 GPUs total - **Dataset**: Full DROID train split (~70k episodes) - **Output**: 1000 tracked points per view with visibility masks - **Preview videos**: 20 total (distributed across GPUs) - **Processing time**: ~10-20 seconds per episode ## Quick Start ### Single Machine (8 GPUs) - Recommended ```bash cd /root/workspace/code/wmrl/Dual-Dynamics-Models/DROID-main bash scripts/run_multigpu_single_machine.sh ``` **How it works:** - 8 independent processes (one per GPU) - No communication between processes - Each GPU processes episodes where `(episode_idx % 8) == gpu_id` - GPU 0: episodes 0, 8, 16, 24, ... - GPU 1: episodes 1, 9, 17, 25, ... - GPU 2: episodes 2, 10, 18, 26, ... - etc. ### Two Machines (16 GPUs) - Optional If you want faster processing with 16 GPUs across 2 machines: #### Machine 1 (GPUs 0-7, Global IDs 0-7) ```bash cd /root/workspace/code/wmrl/Dual-Dynamics-Models/DROID-main bash scripts/run_multigpu_machine1.sh ``` #### Machine 2 (GPUs 0-7, Global IDs 8-15) ```bash cd /root/workspace/code/wmrl/Dual-Dynamics-Models/DROID-main bash scripts/run_multigpu_machine2.sh ``` **Important**: Both machines should use the **same shared output directory** (e.g., `/mnt/kevin/data/droid_processed_1000pts`) accessible via NFS or similar. ## Monitoring Progress ### Check logs: ```bash # Single machine tail -f /mnt/kevin/data/droid_processed_1000pts/log_gpu0.txt # Or for two machines: # Machine 1 tail -f /mnt/kevin/data/droid_processed_1000pts/log_machine0_gpu0.txt # Machine 2 tail -f /mnt/kevin/data/droid_processed_1000pts/log_machine1_gpu0.txt ``` ### Check all running processes: ```bash ps aux | grep preprocess_droid_multigpu ``` ### Check GPU utilization: ```bash nvidia-smi ``` ### Monitor specific GPU: ```bash watch -n 1 nvidia-smi ``` ## How It Works ### Episode Distribution - **Total episodes**: ~70,832 in DROID train split - **Per GPU**: ~4,427 episodes (70,832 / 16) - Each GPU processes: `episodes where (episode_idx % 16) == global_gpu_id` ### Global GPU Mapping | Machine | Local GPU | Global GPU | Episodes Range | |---------|-----------|------------|----------------| | 1 | 0 | 0 | 0, 16, 32, ... | | 1 | 1 | 1 | 1, 17, 33, ... | | ... | ... | ... | ... | | 1 | 7 | 7 | 7, 23, 39, ... | | 2 | 0 | 8 | 8, 24, 40, ... | | 2 | 1 | 9 | 9, 25, 41, ... | | ... | ... | ... | ... | | 2 | 7 | 15 | 15, 31, 47, ...| ### Preview Video Distribution - **Total**: 20 preview videos - **Per GPU**: ~1-2 videos - Distributed evenly across episode range ## Output Structure ``` /mnt/kevin/data/droid_processed_1000pts/ ├── data/ │ ├── episode_000000.npz # Processed by GPU 0 │ ├── episode_000001.npz # Processed by GPU 1 │ ├── episode_000002.npz # Processed by GPU 2 │ └── ... ├── preview_videos/ │ ├── preview_episode_000000.mp4 │ ├── preview_episode_004427.mp4 │ └── ... (20 total) ├── metadata_gpu00.json # GPU 0 stats ├── metadata_gpu01.json # GPU 1 stats ├── ... ├── metadata_gpu15.json # GPU 15 stats ├── log_machine0_gpu0.txt ├── log_machine0_gpu1.txt ├── ... └── log_machine1_gpu7.txt ``` ### NPZ File Contents (per episode) ```python { 'episode_idx': int, # Episode index 'uuid': str, # Calibration UUID 'images_exterior': (T, 180, 320, 3), # Exterior camera frames 'images_wrist': (T, 180, 320, 3), # Wrist camera frames 'actions': (T, 7), # Robot actions (Euler XYZ) 'mesh_vertices_2d_exterior': (T, 7, 2), # Ground truth mesh (7 points) 'mesh_vertices_vis_exterior': (T, 7), # Mesh visibility mask 'tracks_exterior': (T, 1000, 2), # 1000 tracked points 'tracks_vis_exterior': (T, 1000), # Track visibility mask 'tracks_wrist': (T, 1000, 2), # 1000 tracked points 'tracks_vis_wrist': (T, 1000), # Track visibility mask 'mesh_indices': (7,), # [0,1,2,3,4,5,6] } ``` ## After Completion ### Merge Metadata Once all GPUs finish, merge the metadata files: ```bash cd /root/workspace/code/wmrl/Dual-Dynamics-Models/DROID-main python scripts/merge_multigpu_metadata.py \ --output-dir /mnt/kevin/data/droid_processed_1000pts \ --num-gpus 16 ``` This will: - Check all 16 GPU metadata files - Report total processed/skipped episodes - Create `metadata_merged.json` with full statistics - Identify any missing/incomplete GPUs ### Verify Output ```bash # Count processed episodes ls -1 /mnt/kevin/data/droid_processed_1000pts/data/episode_*.npz | wc -l # Count preview videos ls -1 /mnt/kevin/data/droid_processed_1000pts/preview_videos/preview_*.mp4 | wc -l # Check total size du -sh /mnt/kevin/data/droid_processed_1000pts/ ``` ## Episode Filtering Episodes are **skipped** (not processed) if they meet any of these criteria: 1. ❌ **No refined extrinsics** - Missing calibration data 2. ❌ **Too short** - Less than 10 valid frames 3. ❌ **Too long** - More than 400 valid frames (configurable) 4. ❌ **Insufficient mesh visibility** - Less than 2 mesh vertices visible in first frame **Note**: Episodes > 400 frames are **skipped entirely**, not truncated. This ensures all saved trajectories are complete. ## Configuration ### Edit Output Directory Modify in both launcher scripts: ```bash OUTPUT_DIR="/mnt/kevin/data/droid_processed_1000pts" ``` ### Adjust Preview Count Modify in both launcher scripts: ```bash PREVIEW_TOTAL=20 # Change to desired number ``` ### Adjust Max Frames Modify in both launcher scripts: ```bash MAX_FRAMES=400 # Episodes longer than this will be SKIPPED (not truncated) ``` ## Troubleshooting ### GPU Out of Memory - Reduce `MAX_FRAMES` to 200 or 300 - CoTracker uses ~6-8GB VRAM for 400 frames ### Process Killed/Crashed - Check log file: `cat /mnt/kevin/data/droid_processed_1000pts/log_machine*_gpu*.txt` - Resume by re-running the launcher (already-processed episodes will be skipped by file existence check) ### Uneven Load Distribution - Some GPUs may finish faster if they get episodes with fewer frames or more skipped episodes - This is normal and expected ### Network Storage Issues - If using NFS, ensure good network bandwidth - Consider using local storage and merging later if NFS is slow ## Estimated Timing ### Single Machine (8 GPUs) - **Per episode**: 10-20 seconds (avg ~15s with 400 max frames) - **Per GPU**: ~8,854 episodes × 15s = ~36.8 hours - **Total wall time**: ~36-48 hours (all GPUs in parallel) - **Output size**: ~500GB-1TB (depends on episode lengths and compression) ### Two Machines (16 GPUs) - **Per episode**: 10-20 seconds (avg ~15s with 400 max frames) - **Per GPU**: ~4,427 episodes × 15s = ~18.4 hours - **Total wall time**: ~18-24 hours (all GPUs in parallel) - **Output size**: ~500GB-1TB (depends on episode lengths and compression) ## Manual Single-GPU Test Before full run, test on a single GPU: ```bash cd /root/workspace/code/wmrl/Dual-Dynamics-Models/DROID-main CUDA_VISIBLE_DEVICES=0 /mnt/kevin/envs/miniconda3/envs/atm_ati_vdm_droid/bin/python \ scripts/preprocess_droid_multigpu.py \ --gpu-id 0 \ --machine-id 0 \ --num-gpus 1 \ # Test with just 1 GPU --output-dir /tmp/droid_test \ --max-frames 100 \ --preview-total 3 ``` ## Stopping All Processes ```bash # Machine 1 pkill -f preprocess_droid_multigpu # Machine 2 pkill -f preprocess_droid_multigpu ``` ## Point Distribution Details ### Exterior View (1000 points) - **First 7 indices**: Mesh vertices (tracked by CoTracker) - Also saved separately as ground truth in `mesh_vertices_2d_exterior` - **Indices 7-999 (993 points)**: Arm-shaped sampling - Gaussian clouds around visible mesh vertices (σ=15px) - Lines connecting mesh vertices - Uniform random fill ### Wrist View (1000 points) - **First 300 indices**: Sparse uniform across full image - **Indices 300-999 (700 points)**: Dense in bottom 60%-100% of image - Where gripper typically appears in wrist camera ### Visibility Masks - Value range: [0.0, 1.0] - 0.0 = occluded/invisible - 1.0 = fully visible - This&That dataloader uses threshold of 0.7 by default ## Next Steps After preprocessing completes: 1. Run metadata merge script 2. Verify output with sample loading test 3. Update This&That VDM dataloader to use new DROID RLDS dataset 4. Begin ControlNet training with 1000-point tracks