This page was translated by an AI (LLM) with a cursory human check and is awaiting full review.
Running a parallel code in batch
Jobs are managed across all nodes by the Slurm software.
If your code requires the MPI CUDA-aware functionality, you should refer to the pageRunning a batch MPI CUDA-aware and GPUDirect multi-GPU job.
To submit a parallel job in batch on Jean Zay, you need to:
- Create a submission script:
- CPU example
- Quad-GPU V100 example
- Octo-GPU V100 example
- Octo-GPU A100 example
- Quad-GPU H100 example
#!/bin/bash
#SBATCH --job-name=TravailMPI # nom du job
#SBATCH --nodes=2 # Nombre total de noeuds
#SBATCH --ntasks-per-node=40 # Nombre de processus MPI par noeud
# /!\ Attention, la ligne suivante est trompeuse mais dans le vocabulaire
# de Slurm "multithread" fait bien référence à l'hyperthreading.
#SBATCH --hint=nomultithread # 1 processus MPI par coeur physique (pas d'hyperthreading)
#SBATCH --time=00:10:00 # Temps d’exécution maximum demande (HH:MM:SS)
#SBATCH --output=TravailMPI%j.out # Nom du fichier de sortie (%j est remplacé par le numéro du travail)
#SBATCH --error=TravailMPI%j.out # Nom du fichier d'erreur (ici commun avec la sortie)
# on se place dans le répertoire de soumission
cd ${SLURM_SUBMIT_DIR}
# nettoyage des modules charges en interactif et herites par defaut
module purge
# chargement des modules
module load ... # par exemple intel-all/19.0.4
# echo des commandes lancées
set -x
# exécution du code
srun ./exec_mpi
The current configuration of the machine does not allow using hyperthreading (execution of 80 MPI processes on the 40 cores of a compute node) with a purely MPI code.
#!/bin/bash
#SBATCH --job-name=multi_gpu # nom du job
# Il est possible d'utiliser uniquement des GPU V100 16 Go ou 32 Go
##SBATCH -C v100-16g # decommenter pour reserver uniquement des GPU V100 16 Go
##SBATCH -C v100-32g # decommenter pour reserver uniquement des GPU V100 32 Go
# Ici, reservation de 2 noeuds avec 4 GPU par noeud et 10 CPU par tache :
#SBATCH --nodes=2 # nombre de noeuds
#SBATCH --ntasks-per-node=4 # nombre de taches par noeud (= nombre de GPU par noeud ici)
#SBATCH --gres=gpu:4 # nombre de GPU par noeud (max 4)
# Le nombre de CPU par tache doit etre adapte en fonction de la partition utilisee. Sachant
# qu'ici on reserve un GPU par tache (soit 1/4 des GPU du noeud), l'ideal est de reserver 1/4
# des CPU du noeud par tache :
#SBATCH --cpus-per-task=10 # nombre de CPU par tache (1/4 des CPU du noeud 4-GPU V100)
# /!\ Attention, "multithread" fait reference à l'hyperthreading dans la terminologie Slurm
#SBATCH --hint=nomultithread # hyperthreading desactive
#SBATCH --time=00:10:00 # temps maximum d'execution demande (HH:MM:SS)
#SBATCH --output=multi_gpu%j.out # nom du fichier de sortie (%j est remplacé par le numéro du travail)
#SBATCH --error=multi_gpu%j.out # nom du fichier d'erreur (ici commun avec la sortie)
# Nettoyage des modules charges en interactif et herites par defaut
module purge
# Chargement des modules
module load ...
# Echo des commandes lancees
set -x
# Le code doit etre compile avec les modules compatibles avec la partition choisie
# Execution du code
srun ./executable_multi_gpu
# Execution du code via bind_gpu.sh si necessite d'un binding externe
# avec un GPU par tache, voir les remarques
# srun /lustre/fshomisc/sup/pub/idrtools/bind_gpu.sh ./executable_multi_gpu
# Pour lancer un script Python, il faut remplacer la dernière ligne par
# srun python -u script_multi_gpu.py
# L'option -u (pour unbuffered) de Python permet de désactiver la bufférisation des sorties standards
#!/bin/bash
#SBATCH --job-name=multi_gpu # nom du job
#SBATCH --partition=gpu_p2 # partition gpu_p2 : noeud octo-GPU V100 32 Go
# Ici, reservation de 2 noeuds avec 8 GPU par noeud et 3 CPU par tache :
#SBATCH --nodes=2 # nombre de noeuds
#SBATCH --ntasks-per-node=8 # nombre de taches par noeud (= nombre de GPU par noeud ici)
#SBATCH --gres=gpu:8 # nombre de GPU par noeud (max 8)
# Le nombre de CPU par tache doit etre adapte en fonction de la partition utilisee. Sachant
# qu'ici on reserve un GPU par tache (soit 1/8 des GPU du noeud), l'ideal est de reserver 1/8
# des CPU du noeud par tache :
#SBATCH --cpus-per-task=3 # nombre de CPU par tache (1/8 des CPU du noeud 8-GPU V100)
# /!\ Attention, "multithread" fait reference à l'hyperthreading dans la terminologie Slurm
#SBATCH --hint=nomultithread # hyperthreading desactive
#SBATCH --time=00:10:00 # temps maximum d'execution demande (HH:MM:SS)
#SBATCH --output=multi_gpu%j.out # nom du fichier de sortie (%j est remplacé par le numéro du travail)
#SBATCH --error=multi_gpu%j.out # nom du fichier d'erreur (ici commun avec la sortie)
# Nettoyage des modules charges en interactif et herites par defaut
module purge
# Chargement des modules
module load ...
# Echo des commandes lancees
set -x
# Le code doit etre compile avec les modules compatibles avec la partition choisie
# Execution du code
srun ./executable_multi_gpu
# Execution du code via bind_gpu.sh si necessite d'un binding externe
# avec un GPU par tache, voir les remarques
# srun /lustre/fshomisc/sup/pub/idrtools/bind_gpu.sh ./executable_multi_gpu
# Pour lancer un script Python, il faut remplacer la dernière ligne par
# srun python -u script_multi_gpu.py
# L'option -u (pour unbuffered) de Python permet de désactiver la bufférisation des sorties standards
#!/bin/bash
#SBATCH --job-name=multi_gpu # nom du job
#SBATCH -C a100 # partition gpu_p5 : noeud octo-GPU A100 80 Go
# Ici, reservation de 2 noeuds avec 8 GPU par noeud et 8 CPU par tache :
#SBATCH --nodes=2 # nombre de noeuds
#SBATCH --ntasks-per-node=8 # nombre de taches par noeud (= nombre de GPU par noeud ici)
#SBATCH --gres=gpu:8 # nombre de GPU par noeud (max 8)
# Le nombre de CPU par tache doit etre adapte en fonction de la partition utilisee. Sachant
# qu'ici on reserve un GPU par tache (soit 1/8 des GPU du noeud), l'ideal est de reserver 1/8
# des CPU du noeud par tache :
#SBATCH --cpus-per-task=8 # nombre de CPU par tache pour gpu_p5 (1/8 des CPU du noeud 8-GPU A100)
# /!\ Attention, "multithread" fait reference à l'hyperthreading dans la terminologie Slurm
#SBATCH --hint=nomultithread # hyperthreading desactive
#SBATCH --time=00:10:00 # temps maximum d'execution demande (HH:MM:SS)
#SBATCH --output=multi_gpu%j.out # nom du fichier de sortie (%j est remplacé par le numéro du travail)
#SBATCH --error=multi_gpu%j.out # nom du fichier d'erreur (ici commun avec la sortie)
# Nettoyage des modules charges en interactif et herites par defaut
module purge
# Activation du module permet l'accès aux modules compatibles avec la partition A100
module load arch/a100
# Chargement des modules
module load ...
# Echo des commandes lancees
set -x
# Le code doit etre compile avec les modules compatibles avec la partition choisie
# Execution du code
srun ./executable_multi_gpu
# Execution du code via bind_gpu.sh si necessite d'un binding externe
# avec un GPU par tache, voir les remarques
# srun /lustre/fshomisc/sup/pub/idrtools/bind_gpu.sh ./executable_multi_gpu
# Pour lancer un script Python, il faut remplacer la dernière ligne par
# srun python -u script_multi_gpu.py
# L'option -u (pour unbuffered) de Python permet de désactiver la bufférisation des sorties standards
The modules accessible by default are not compatible with this partition,
you must first load the arch/a100 module to be able to list
and load compatible modules. To find out more, consult the sectionModules compatible with the A100 and H100 partitions.
#!/bin/bash
#SBATCH --job-name=multi_gpu # nom du job
#SBATCH -C h100 # partition gpu_p6 : noeud quadri-GPU H100 80 Go
# Ici, reservation de 2 noeuds avec 4 GPU par noeud et 24 CPU par tache :
#SBATCH --nodes=2 # nombre de noeuds
#SBATCH --ntasks-per-node=4 # nombre de taches par noeud (= nombre de GPU par noeud ici)
#SBATCH --gres=gpu:4 # nombre de GPU par noeud (max 4)
# Le nombre de CPU par tache doit etre adapte en fonction de la partition utilisee. Sachant
# qu'ici on reserve un GPU par tache (soit 1/4 des GPU du noeud), l'ideal est de reserver 1/4
# des CPU du noeud par tache :
#SBATCH --cpus-per-task=24 # nombre de CPU par tache pour gpu_p6 (1/4 des CPU du noeud 4-GPU H100)
# /!\ Attention, "multithread" fait reference à l'hyperthreading dans la terminologie Slurm
#SBATCH --hint=nomultithread # hyperthreading desactive
#SBATCH --time=00:10:00 # temps maximum d'execution demande (HH:MM:SS)
#SBATCH --output=multi_gpu%j.out # nom du fichier de sortie (%j est remplacé par le numéro du travail)
#SBATCH --error=multi_gpu%j.out # nom du fichier d'erreur (ici commun avec la sortie)
# Nettoyage des modules charges en interactif et herites par defaut
module purge
# Activation du module permet l'accès aux modules compatibles avec la partition H100
module load arch/h100
# Chargement des modules
module load ...
# Echo des commandes lancees
set -x
# Le code doit etre compile avec les modules compatibles avec la partition choisie
# Execution du code
srun ./executable_multi_gpu
# Execution du code via bind_gpu.sh si necessite d'un binding externe
# avec un GPU par tache, voir les remarques
# srun /lustre/fshomisc/sup/pub/idrtools/bind_gpu.sh ./executable_multi_gpu
# Pour lancer un script Python, il faut remplacer la dernière ligne par
# srun python -u script_multi_gpu.py
# L'option -u (pour unbuffered) de Python permet de désactiver la bufférisation des sorties standards
The modules accessible by default are not compatible with this partition,
you must first load the arch/h100 module to be able to list
and load compatible modules. To find out more, consult the sectionModules compatible with the A100 and H100 partitions.
- Submit this script using the
sbatchcommand:
sbatch mon_script.slurm
Remarks:
- We recommend compiling and running your code in the same software environment by loading the same modules.
- The
--hint=nomultithreadoption ensures the reservation of physical cores (no hyperthreading). - The memory allocated for the job is proportional to the number of CPU cores requested. For example, if you request 1/4 of the physical CPU cores of a node, you will have access to 1/4 of its RAM memory. It is important to be consistent with the configuration of the nodes used to avoid overcharging of hours, while benefiting from the memory to which you are entitled. You can consult our documentation on this subject: Memory allocation with Slurm.
- In these examples, it is assumed that the executable or Python script used is located in the submission directory, i.e., the directory in which you are located when using the
sbatchcommand: the$SLURM_SUBMIT_DIRvariable is automatically set by Slurm. - The output file of the computation will also be located in the submission directory. It is created at the beginning of the job execution; editing or modifying it during the job execution may disrupt it.
- The
module purgeis made indispensable by Slurm's default behaviour: the modules you have loaded in your environment at the time you runsbatchare taken into account in the submitted job. - The use of the
sruncommand is indispensable when you request a multi-task execution. We discourage the use ofmpirunon Jean Zay, onlysrunguarantees a distribution in accordance with the resource specifications requested in your submission file. - The
/lustre/fshomisc/sup/pub/idrtools/bind_gpu.shscript allows you to associate a different GPU with each process. It is not necessary to use it if your code explicitly manages the association of processes with GPUs. Caution, this script is very basic and can only handle the simple case of 1 GPU for 1 MPI task. It therefore only works for a number of tasks per node less than or equal to the number of GPUs per node. - All jobs have resources defined by a partition and a "Quality of Service" QoS set by default in Slurm. You can modify these limits by specifying a partition and/or a QoS as indicated in our documentation detailing the partitions and QoS for CPU and GPU.
- For multi-project accounts as well as those with CPU and GPU hours, it is essential to specify the hour allocation on which to deduct the computing hours of the job as indicated in our documentation detailing themanagement of computing hours to ensure that the hours consumed by your jobs are deducted from the correct allocation.