The avaiable RAM for a given SLURM instance can be found by:
import os
mem_per_proc = int(os.environ['SLURM_MEM_PER_CPU']) * 1e6
n_cpu = int(os.environ['SLURM_CPUS_PER_TASK'])
mem_av = (mem_per_proc * n_cpu) / 1e9
print(f"Available RAM: {mem_av:.2f} Gb")
Note that instead the code:
import psutil
mem = psutil.virtual_memory()
mem_av = mem.available
print(f"Available RAM: {mem_av / 1e9:.2f} Gb")
Gives the available memory in the full node, i.e. not that which can be used by the user.
The memory used by a process spawned via multiprocessing
can be found by:
import multiprocessing as mp
import psutil
pid = mp.current_process().pid
proc = psutil.Process(pid)
print(f"Process {pid} used {proc.memory_info().rss / 1e9} Gb (RSS)")
This needs to be placed inside the function called by mp
.
The idea is to find a way to compute the number of processes that allow get_qspace_avg
to run via multiprocessing
without failing, restricting the amount of data sent to memory at any given time. In this sense the library joblib or the shared memory capability of multiprocessing
could be useful.
Finally note that using the @profile
decorator of memory_profiler gives good insights of the mem usage of a function.
Other useful links:
Edoardo Zatterin (0caedb17) at 13 Mar 19:20
test widget state in example nb build_doc
Edoardo Zatterin (c183b6fd) at 13 Mar 19:12
test widget state in example nb build_doc
... and 1 more commit
Edoardo Zatterin (a5922fe9) at 13 Mar 19:04
test widget state in example nb build_doc
Edoardo Zatterin (0378fbd0) at 13 Mar 18:51
test widget state in example nb build_doc
Edoardo Zatterin (413fb427) at 13 Mar 18:09
updated CI pipeline build_doc
Edoardo Zatterin (9093c6c0) at 13 Mar 18:05
updated doc conf build_doc
Edoardo Zatterin (fa8613e6) at 12 Mar 19:09
Update .gitlab-ci.yml file build_doc
Edoardo Zatterin (527e1b2a) at 12 Mar 19:03
updated doc conf build_doc
Edoardo Zatterin (2c779419) at 12 Mar 19:00
Update .gitlab-ci.yml file build_doc
Edoardo Zatterin (54719b87) at 12 Mar 18:55
Update .gitlab-ci.yml file
Edoardo Zatterin (739576a0) at 12 Mar 18:44
Update .gitlab-ci.yml file
Edoardo Zatterin (19f64f53) at 12 Mar 18:36
Merge branch 'main' of https://gitlab.esrf.fr/id01-science/id01-sxd...
... and 1 more commit
Edoardo Zatterin (20715c7c) at 12 Mar 18:34
Update README.md
Edoardo Zatterin (d1adf2ed) at 12 Mar 18:33
Update README.md
Edoardo Zatterin (73e60294) at 12 Mar 18:32
Update README.md
Edoardo Zatterin (8083446a) at 12 Mar 18:30
Update README.md
Edoardo Zatterin (43a6479e) at 12 Mar 18:23
merge lzatt into rnice (mainly docs)
... and 1 more commit
Edoardo Zatterin (3d4894d4) at 11 Mar 18:41
added zenodo DOI to readme