0

I'm trying to generate a script that automatically adapt its requirements to whatever is the environment where it is running.

I already got the number of CPUs available by accessing the SLURM_CPUS_PER_TASK environment variable. If it does not exists, I assume it is an interactive execution and default the value to 1.

Now I need to get the memory available, but this is not so straightforward. We have SLURM_MEM_PER_CPU and SLURM_MEM_PER_NODE. If I'm not wrong, this numbers are not always present, and there's the special case of asking for zero memory. But I need to have the real number, as I'm trying to run a java application and I need to put something specific in the -Xmx parameter.

Is there any easy way to get that info? Or I have to test for availability of any of the variables and query SLURM/the system in order to get total memory available in case of zero?

Poshi
  • 5,332
  • 3
  • 15
  • 32

1 Answers1

0

If you request memory (--mem) on your submit script these environment variables should be set.

Else you can try (scontrol show config) or parse /etc/slurm/slurm.conf for MaxMemPerNode with the PartitionName you are running.

ref: https://slurm.schedmd.com/sbatch.html

user42061
  • 81
  • 4
  • If I request `--mem`, only `SLURM_MEM_PER_NODE` will be set. If I request `--mem-per-cpu`, only `SLURM_MEM_PER_CPU` will be set. And If I request zero memory to be able to use all available memory... it looks like I have to query somewhere else to get that number. That's precisely what I don't want to do. I know I can query two variables and a scontrol output, but I was looking for something that could be put in a one-liner. – Poshi Mar 19 '21 at 13:18