#!/bin/bash
#SBATCH --nodes=20
#SBATCH --ntasks-per-node=40
#SBATCH --gres=gpu:2
#SBATCH --time=00:30:00
#SBATCH --output=out.slurm-%A
#SBATCH --error=err.slurm-%A
#SBATCH --partition=gpu
ulimit -s unlimited
ulimit -c unlimited
cd <Path_For_Run_Folder>
echo $SLURM_NODELIST
echo
srun hostname > h.txt
sort -u h.txt > hosts.$SLURM_JOB_ID
sed -i 's/$/ slots=8/' hosts.$SLURM_JOB_ID
NODES=` wc -l < hosts.$SLURM_JOB_ID `
MPITASKS=` expr 8 \* $NODES `
module load gnu8/8.3.0
module load nvhpc/nvhpc/21.9
which mpirun
time mpirun -hostfile ./hosts.$SLURM_JOB_ID -n $MPITASKS <path_for_script_binding_ranks_to_gpu>/ranks_to_gpu_8R_2G.sh