12

I tried to execute mpiexec -16 ... on a 384 GB RAM server, but it induced OOM Killer and was aborted.

How can I set a memory limit for mpiexec execution?

I know ulimit, but it might affect other processes.

Thank you.

Benben
  • 225

1 Answers1

10

I think this can be done using cgroups:

Create a cgroup named mpigroup (or whatever name you choose) with a memory limit (of 50GB, for example):

cgcreate -g memory,cpu:mpigroup
cgset -r memory.limit_in_bytes=$((50*1024*1024*1024)) mpigroup

Then, if mpiexec is already running, bring it into this cgroup:

cgclassify -g memory,cpu:mpigroup $(pidof mpiexec)

Or execute mpiexec within this cgroup:

cgexec -g memory,cpu:mpigroup mpiexec -16 ...
muru
  • 197,895
  • 55
  • 485
  • 740
  • Shouldn't the memory controller be enough: cgcreate -g memory:mpigroup? – heemayl Oct 24 '16 at 14:45
  • @heemayl should be. I just lifted this example straight from the wiki – muru Oct 24 '16 at 14:45
  • 1
    settings are stored at /sys/fs/cgroup/memory/, and to work sudo is required even if it dont fail while not using sudo – Aquarius Power Jul 08 '17 at 23:25
  • I managed to limit the physical memory to 2GB, worked perfectly, but the virtual memory was still going to 8GB, but that was completely ok because the wine game would just use the swap instead of sending all other linux applications to swap, and that made the whole system work better! thx! – Aquarius Power Jul 09 '17 at 00:51