I am trying to run a R code in a HPC environment. The HPC system has 8 nodes with 20 cores each. I wish to use 2 nodes, utilizing 40 cores in total. I am submitting the job through SLURM and it is running the .R file which has a parallel computing code in it. I have the following .sbatch code
#!/bin/bash
#SBATCH --job-name=my_r_script # Job name
#SBATCH --nodes=2 # Number of nodes
##SBATCH --ntasks-per-node=20 # Number of tasks per node
#SBATCH --ntasks=40 # Total number of tasks (cores)
#SBATCH --cpus-per-task=1 # Number of CPU cores per task
#SBATCH --mem=4G # Memory per node (e.g., 4G, 8G, 16G)
#SBATCH --time=1:00:00 # Wall clock time limit (hh:mm:ss)
module load R # Load the R module
Rscript my_Rscript.R
However when I see the results, I know that it is only using 20 cores from a single node and not 40 cores together. How do I write the .sbatch file to ensure that all 40 cores from 2 nodes are utilized to run the R code for parallel computing.
I have used the idea presented in the response here: https://stackoverflow.com/a/73828155/12493753 to understand --ntasks and --cpus-per-task=1.