Repository navigation
Description
This memory leak error was identified on the branch at https://github.com/pwolfram/MPAS-Model/tree/coastal/Delaware_gaussian_hump with hash ba4bbdab91052b9ff3474a0540436a0e55fed6e5 for the Sandy Hurricane case and produces an insufficient virtual memory error.
@hrmoncada, I have given you the tgz file with the example case on LANL IC, although you can build it from COMPASS for the ocean/hurricane/USDEQU120at30cr10rr2WD/sandy/ case. Modules and run instructions for IC are detailed below.
Error messages occur after some time (depending upon total number of time steps) and are of the form
forrtl: severe (41): insufficient virtual memory
Image PC Routine Line Source
ocean_model 0000000000E6FE10 for_alloc_allocat Unknown Unknown
ocean_model 0000000000749E66 Unknown Unknown Unknown
ocean_model 00000000006C577E Unknown Unknown Unknown
ocean_model 00000000007382D0 Unknown Unknown Unknown
ocean_model 000000000094972C Unknown Unknown Unknown
ocean_model 00000000006ABD6B Unknown Unknown Unknown
ocean_model 0000000000699590 Unknown Unknown Unknown
ocean_model 000000000063EE31 Unknown Unknown Unknown
ocean_model 000000000040F277 Unknown Unknown Unknown
ocean_model 000000000040F1FE Unknown Unknown Unknown
ocean_model 000000000040F1AE Unknown Unknown Unknown
libc-2.17.so 00002ADC24D273D5 __libc_start_main Unknown Unknown
ocean_model 000000000040F0A9 Unknown Unknown Unknown
...
This has occurred for a variety of runs (shown below):
| dt | last stable time stamp |
|---|---|
| 10s | 2012-10-05_22:18:50 |
| 5s | 2012-10-03_11:09:05 |
| 25s | 2012-10-13_07:43:45 |
| 25s | 2012-10-13_08:22:55 |
| 25s restart (from above) | 2012-10-25_08:30:25 |
This was experienced on 360 processors for 51536 cells, or ~143 cells / proc.
As you can see, this is a memory leak because the failure time depends on the time step and it is possible to advance the simulation via a restart.
I'm running with the following approach and modules:
#!/bin/bash
#SBATCH --account=XYZ
#SBATCH --job-name=XYZ
#SBATCH --qos=interactive
#SBATCH --time=4:00:00
#SBATCH --output=run.o%j
#SBATCH --nodes=10
#SBATCH --error=run.e%j
#SBATCH [email protected]
#SBATCH --mail-type=all
# Modules for grizzly
source ~/module_source_gr.sh
gpmetis graph.info 360
srun -n 360 ./ocean_model -n namelist.ocean -s streams.ocean
where module_source_gr.sh is
#!/bin/bash
module purge
module use /usr/projects/climate/SHARED_CLIMATE/modulefiles/all/
echo "loading modules anaconda, intel, openmpi, netcdf, pnetcdf, pio for grizzly"
module load intel/17.0.1 openmpi/1.10.5 netcdf/4.4.1 parallel-netcdf/1.5.0 pio/1.7.2
source /usr/projects/climate/SHARED_CLIMATE/anaconda_envs/base/etc/profile.d/conda.sh
conda activate compass_py3.7
alias metis=gpmetis
@hrmoncada, posting images of your output from valgrind will help us see where the memory leak is and that will help us trace it to the exact line of code where memory is allocated.
cc @mark-petersen and @sbrus89
Activity
hrmoncada commentedon Aug 28, 2019
Cool I will look that issue
pwolfram commentedon Aug 28, 2019
Thanks @hrmoncada! I should also note that I would expect this issue to be independent of this branch, but the branch is needed to run the test case to demonstrate it.
pwolfram commentedon Aug 29, 2019
This is related to #137, which I'm not sure entirely should be closed yet. We tested again in the hurricane case without wetting and drying and had better success with stability, indicating that a large part of the memory leak problem was fixed. However, it eventually did die (at days vs hr simulation scales), which indicates that if there were a few memory leaks found last time that weren't fixed my guess is that these would be great places to start as culprits.
mark-petersen commentedon Sep 5, 2019
@hrmoncada any progress on this? Please tell us if you are stuck on something. Totalview should tell us where the memory leak is.
hrmoncada commentedon Sep 5, 2019
pwolfram commentedon Sep 5, 2019
@mark-petersen, @hrmoncada is going to evaluate this case with 4 processors.
mark-petersen commentedon Sep 9, 2019
@hrmoncada sent this:

The trace implies that the problem is a memory leak in pio. @pwolfram please rerun your test case with all output streams off, and see if it runs past the previous time when it died with "out of memory" error. Of course, pio should not have a memory leak, but it is possible.
pwolfram commentedon Sep 9, 2019
@mark-petersen, I can try this but am very skeptical. Why don't we see this issue in split_explicit, for example? I suppose there could be a difference in usage pattern but do find this confusing.
Will run the case as you propose but would appreciate hearing your ideas as I think about this in the meantime. Any hints from your experience that would be aligned with this type of issue would be really helpful.
hrmoncada commentedon Sep 9, 2019
@pwolfram, I run again the test case but this take a took a snapshot of the HEAP memory on run time, before end to complete the calculation.
mark-petersen commentedon Sep 9, 2019
box_rearrange.F90 is a PIO subroutine:
http://mermaid.uconn.edu/cesm_climatology/CESM_code/cesm1_1_1/models/utils/pio/box_rearrange.F90.in
@pwolfram maybe we need to play with the i/o flags to try to avoid this error. First turn off output altogether. We can also play with:
and the output format.
pwolfram commentedon Sep 10, 2019
@mark-petersen, I made the output frequency for the streams ten-times less frequent and reran, with the outcome of getting the same crash near about the same time happening.
I'll try again with the streams
output_interval='none'and report back...pwolfram commentedon Sep 10, 2019
Note, for the record this is with the default values of
mark-petersen commentedon Sep 10, 2019
OK. Then that line of the memory report is most likely a red herring.
10 remaining items
mark-petersen commentedon Sep 12, 2019
@pwolfram, I can confirm your memory leak. Thanks for setting up your test problem.
I'm running this on IC with intel, DEBUG=true OPENMP=true. OMP_NUM_THREADS=1.
I'm running on one node, 36 cores, with your branch and tar file above, except I put a simple loop around your code in last comment, and it dies on iteration 26075.
Looking into it now...
pwolfram commentedon Sep 12, 2019
@jonbob, I tried your suggestion of
and interestingly, it appears to makes the memory leak even worse.
Furthermore, it isn't completely clear to me the difference between
empty_pool(18s wall clock to crash) anddestroy_pool(10.5min) because what we really want in the loop is a full deallocation of the pool and its data structures. If I recall correctlyempty_poolremoves the pointers to memory locations whereasdestroy_poolactually deallocates the memory locations themselves and then the pointers, albeit apparently incompletely in our code snipet above, unless we are missing another high-level API call in the RK4 loop. Note, adestroy_poolfollowing anempty_poolstill has a larger leak as a consequence (because of hanging memory locations).pwolfram commentedon Sep 12, 2019
@mark-petersen, thanks for taking a look!
pwolfram commentedon Sep 14, 2019
@mark-petersen, it gets out to 16 days with this fix, which is only marginally better than 13 days, indicating that some of the leak was fixed but it doesn't appear to be the lion's share of the leak.
pwolfram commentedon Sep 15, 2019
What is also more troubling is that it is now a hard crash vs an insufficient virtual memory error.
pwolfram commentedon Sep 15, 2019
We also need to check performance-- I think this has made the code slower too although it now nearly runs for a full 4 hr cycle.
mark-petersen commentedon Sep 16, 2019
Wow, it's really disturbing that changing to a more complete 'deallocate' function makes the code run slower. That really makes me think that we should have permanent memory allocated for RK4 "provis" data, rather than the current clone pool and then destroy pool.
pwolfram commentedon Oct 31, 2019
@mgduda's fix proposed in the thread at #367 is working so far based on our checks to resolve the issues; are verifying (with @sbrus89) with more robust cases to stress-test. Thanks @mgduda and @mark-petersen for your engagement on these fixes!
Merge PR #367 'pool_memory_leak' into develop
pwolfram commentedon Jan 15, 2020
Thank you everyone! I believe this issue is now fully resolved and am closing.
Merge PR MPAS-Dev#367 'pool_memory_leak' into develop