train.sh 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  1. # Args parameters
  2. MODEL=$1
  3. DATASET=$2
  4. DATASET_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 -m torch.distributed.run --nproc_per_node=${WORLD_SIZE} --master_port ${MASTER_PORT} train.py \
  12. --cuda \
  13. --dataset ${DATASET} \
  14. --root ${DATASET_ROOT} \
  15. --model ${MODEL} \
  16. --batch_size ${BATCH_SIZE} \
  17. --resume ${RESUME} \
  18. --fp16
  19. elif [[ $WORLD_SIZE -gt 1 && $WORLD_SIZE -le 8 ]]; then
  20. python -m torch.distributed.run --nproc_per_node=${WORLD_SIZE} --master_port ${MASTER_PORT} train.py \
  21. --cuda \
  22. --distributed \
  23. --dataset ${DATASET} \
  24. --root ${DATASET_ROOT} \
  25. --model ${MODEL} \
  26. --batch_size ${BATCH_SIZE} \
  27. --resume ${RESUME} \
  28. --fp16 \
  29. --sybn
  30. else
  31. echo "The WORLD_SIZE is set to a value greater than 8, indicating the use of multi-machine \
  32. multi-card training mode, which is currently unsupported."
  33. exit 1
  34. fi