#!/bin/bash -l
# File: slurm.tmpl
# Template for using clustermq against a SLURM backend
#SBATCH --job-name={{ job_name }}
#SBATCH --error={{ log_file | /dev/null }}
#SBATCH --mem-per-cpu={{ memory | 1024 }}
#SBATCH --array=1-{{ n_jobs }}
#SBATCH --cpus-per-task={{ cores | 1 }}
export OMP_NUM_THREADS={{ cores | 1 }}
ulimit -v $(( 1024 * {{ memory | 1024 }} ))
CMQ_AUTH={{ auth }} ${R_HOME}/bin/R --no-save --no-restore -e 'clustermq:::worker("{{ master }}")'
Templates
SLURM
The main differences in this SLURM template compared to the one that comes as default with the package installation are
- explicit pointing to the correct R binary via the
R_HOME
environment variable. This is very important for environments where there is multiple versions of R installed that are not necessarily accessible via thePATH
environment variable. - educated guess for nested parallelisation. i.e. if each job/task launched by clustermq can make use of OpenMP parallelisation (settings
cores > 1
) we aready setOMP_NUM_THREADS
accordingly.
The template can be referenced either in .Rprofile
or in the code itself via
options(
clustermq.scheduler = "slurm",
clustermq.template = "slurm.tmpl"
)