test-batch.sh 1.4 KB

1234567891011121314151617181920212223242526272829303132333435
  1. #!/bin/bash
  2. #SBATCH --job-name=test_mpi # Nom du job
  3. #SBATCH --partition=docker # Nom de la partition (défini dans votre slurm.conf)
  4. #SBATCH --nodes=2 # Demande 2 noeuds (c1 et c2)
  5. #SBATCH --ntasks=2 # Demande 2 tâches au total
  6. #SBATCH --ntasks-per-node=1 # 1 tâche par noeud (pour forcer la répartition)
  7. #SBATCH --output=res_%j.out # Fichier de sortie standard (%j = ID du job)
  8. #SBATCH --error=res_%j.err # Fichier d'erreur
  9. echo "=========================================="
  10. echo "Job SLURM ID : $SLURM_JOB_ID"
  11. echo "Date de début : $(date)"
  12. echo "Exécuté sur le noeud maître : $(hostname)"
  13. echo "Liste des noeuds alloués : $SLURM_JOB_NODELIST"
  14. echo "=========================================="
  15. echo ""
  16. echo ">>> TEST 1 : Vérification simple des noeuds (srun hostname)"
  17. # Doit retourner c1 et c2
  18. srun hostname
  19. echo ""
  20. echo ">>> TEST 2 : Test MPI via Python (mpi4py)"
  21. # Ce script Python va afficher le rang MPI et le nom de l'hôte
  22. # Votre slurm.conf utilise MpiDefault=pmi2, donc srun devrait gérer la communication
  23. srun python3 -c "from mpi4py import MPI; \
  24. comm = MPI.COMM_WORLD; \
  25. rank = comm.Get_rank(); \
  26. size = comm.Get_size(); \
  27. host = MPI.Get_processor_name(); \
  28. print(f'MPI SUCCESS: Je suis le rang {rank} sur {size}, tournant sur le conteneur {host}')"
  29. echo ""
  30. echo "=========================================="
  31. echo "Fin du job : $(date)"