This page was translated by an AI (LLM) with a cursory human check and is awaiting full review.
Running a multi-GPU MPI CUDA-aware and GPUDirect batch job
Jobs are managed across all nodes by the Slurm software.
To submit a distributed multi-GPU MPI CUDA-aware and GPUDirect batch job on Jean Zay, you need to create a submission script based on the two examples provided below.
It is necessary to run the code using the same OpenMPI CUDA-aware library that you used to compile your code. Additionally, using the MPI CUDA-aware GPUDirect feature on Jean Zay requires following a specific initialisation order for CUDA or OpenACC and MPI in the code. Please refer to theMPI CUDA-aware and GPUDirect page.
- Create a submission script:
- Quad-GPU V100 example
- Octo-GPU V100 example
- Octo-GPU A100 example
- Quad-GPU H100 example
#!/bin/bash
#SBATCH --job-name=multi_gpu_mpi_cuda-aware # 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_mpi_cuda-aware
#!/bin/bash
#SBATCH --job-name=multi_gpu_mpi_cuda-aware # 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_mpi_cuda-aware
#!/bin/bash
#SBATCH --job-name=multi_gpu_mpi_cuda-aware # 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_mpi_cuda-aware
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_mpi_cuda-aware # 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_mpi_cuda-aware
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 command
sbatch:
sbatch multi_gpu_mpi_cuda-aware.slurm
Remarks:
- The error
CUDA failure: cuCtxGetDevice()returned during execution probably means that you did not follow the CUDA or OpenACC and MPI initialisation order, as indicated on the MPI CUDA-aware and GPUDirect page. - We recommend compiling and running your code in the same software environment by loading the same modules.
- The option
--hint=nomultithreadensures 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
executable_multi_gpu_mpi_cuda-awareis located in the submission directory, i.e. the directory in which you are located when using the commandsbatch: the variable$SLURM_SUBMIT_DIRis 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 necessary 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 command
srunis essential when you request a multi-task execution. We advise against usingmpirunon Jean Zay, onlysrunguarantees a distribution in accordance with the resource specifications requested in your submission file. - All jobs have resources defined by a partition and a "Quality of Service" QoS (Quality of Service) set by default in Slurm. You can modify these limits by specifying a partition and/or a QoS as indicated in our documentation detailing GPU partitions and QoS.
- 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 the management of computing hours to ensure that the hours consumed by your jobs are deducted from the correct allocation.