Interface Matlab call with ulimit and oom score?
In addition to the ulimit -v
call demonstrated in the current Readme, we could add something like this:
matlab -nodesktop -nosplash & (echo 1000 > /proc/$!/oom_score_adj) && fg
This sends the Matlab call to the background, captures its PID (as $!
), and uses the PID to set the oom_score_adj
to its maximum value hence making Matlab the biggest target for the OOM Killer. In the end, it brings Matlab back to the foreground so that the user gets a prompt.
I've confirmed this works on scalc02
and within singularity.
Todo:
-
How to generalize this to capture arbitrary args we want to pass to Matlab? Something like this could do: function run_matlab { matlab -nodesktop -nosplash "$*" & (echo 1000 > /proc/$!/oom_score_adj) && fg; }
-
How to automatically have the ulimit -v
adjust to n percent of the total memory? (Parsingfree
? Or is there a cleaner way?) -
Put all into a single function or script replacing matlab
in the path. -
The OOM Killer stops jobs (state T
inps
). Do we need to get rid of these automatically?