Memory Options (Slurm)
It is vital to request enough memory for your job to run efficiently but not to request too much memory which may deprive other users.
Slurm
There are two memory options in the Slurm scheduler: --mem and --mem-per-cpu.
--mem
This option is similar to HTCondor's request_memory option.
You can append different suffixes like K, M, G or T. It can either be a command line option like
--mem=16G
or a directive like
#SBATCH --mem=16G
It will request an amount of RAM for the whole job. For example, if you want 2 cores and 2GiB for each core then you should use
--mem=4G
If your job exceeds the memory requested, it will be killed and a message like the following will be sent to stdout:
/var/spool/slurmd/job00938/slurm_script: line 15: 24509 Killed memgrab -s 10 -w 100
slurmstepd: error: Detected 1 oom-kill event(s) in StepId=938.batch cgroup. Some of your processes may have been killed by the cgroup out-of-memory handler.
The manpage and other documentation may read that the units for the --mem and --mem-per-cpu options are in megabytes (Base10 units, a.k.a. MB). Technically they are in mebibytes (Base2 units a.k.a. MiB). For the most part the difference is minimal and can be ignored.