train.sh 945 B

123456789101112131415161718192021222324252627282930313233
  1. # Args setting
  2. MODEL=$1
  3. DATASET=$2
  4. DATA_ROOT=$3
  5. BATCH_SIZE=$4
  6. WORLD_SIZE=$5
  7. MASTER_PORT=$6
  8. RESUME=$7
  9. # -------------------------- Train Pipeline --------------------------
  10. if [ $WORLD_SIZE == 1 ]; then
  11. python train.py \
  12. --cuda \
  13. --dataset ${DATASET} \
  14. --root ${DATA_ROOT} \
  15. --model ${MODEL} \
  16. --batch_size ${BATCH_SIZE} \
  17. --resume ${RESUME}
  18. elif [[ $WORLD_SIZE -gt 1 && $WORLD_SIZE -le 8 ]]; then
  19. python -m torch.distributed.run --nproc_per_node=$WORLD_SIZE --master_port ${MASTER_PORT} \
  20. train.py \
  21. --cuda \
  22. --distributed \
  23. --dataset ${DATASET} \
  24. --root ${DATA_ROOT} \
  25. --model ${MODEL} \
  26. --batch_size ${BATCH_SIZE} \
  27. --resume ${RESUME}
  28. else
  29. echo "The WORLD_SIZE is set to a value greater than 8, indicating the use of multi-machine \
  30. multi-card training mode, which is currently unsupported."
  31. exit 1
  32. fi