cd /workspace/musubi-tuner || echo "Failed to open directory" LATENT_BATCH_SIZE=12 LATENT_NUM_WORKERS=6 TEXT_BATCH_SIZE=1 TEXT_NUM_WORKERS=1 mkdir -p logs latent_pids=() for i in 0 1 2 3 4 5 6 7; do CUDA_VISIBLE_DEVICES=$i python -m musubi_tuner.ltx2_cache_latents \ --dataset_config "train/ltxxx_gpu${i}.toml" \ --ltx2_checkpoint "$LTX2_CKPT" \ --device cuda \ --vae_dtype bf16 \ --ltx2_mode av \ --ltx2_audio_source video \ --batch_size "$LATENT_BATCH_SIZE" \ --num_workers "$LATENT_NUM_WORKERS" \ --skip_existing \ > "logs/ltx2_cache_latents_gpu${i}.log" 2>&1 & latent_pids+=($!) done latent_failed=0 for pid in "${latent_pids[@]}"; do if ! wait "$pid"; then latent_failed=1 fi done if[ "$latent_failed" -ne 0 ]; then echo "Latent caching failed on at least one GPU. Check logs/ltx2_cache_latents_gpu*.log" else echo "Latent caching finished successfully on all 8 GPUs. Starting text cache..." text_pids=() for i in 0 1 2 3 4 5 6 7; do CUDA_VISIBLE_DEVICES=$i python -m musubi_tuner.ltx2_cache_text_encoder_outputs \ --dataset_config "train/ltxxx_gpu${i}.toml" \ --ltx2_checkpoint "$LTX2_CKPT" \ --gemma_root "$GEMMA_ROOT" \ --gemma_load_in_8bit \ --device cuda \ --mixed_precision bf16 \ --ltx2_mode av \ --batch_size "$TEXT_BATCH_SIZE" \ --num_workers "$TEXT_NUM_WORKERS" \ --skip_existing \ > "logs/ltx2_cache_text_gpu${i}.log" 2>&1 & text_pids+=($!) done text_failed=0 for pid in "${text_pids[@]}"; do if ! wait "$pid"; then text_failed=1 fi done if[ "$text_failed" -ne 0 ]; then echo "Text caching failed on at least one GPU. Check logs/ltx2_cache_text_gpu*.log" else echo "Latent cache and text cache both completed successfully." fi fi