I have a function, let’s call it
model_build(), that does a bunch of stuff, like building a model, sampling to get the posterior, and then doing
sample_ppc(). It saves stuff to file but doesn’t return anything. It’s able to run fine for me, and with the sample sizes/etc I’m using, takes ~1.5 GB of memory to run.
However, what I’m doing is calling it in a for loop, with different sets of parameters. What I’m finding is that the memory is growing without bound, until by about the 4th or 5th iteration, it eats up the 8GB of memory my laptop has, and crashes, giving a memory error.
This is confusing to me, because
model_build() doesn’t return anything – therefore, I would intuitively guess that anything that happens internally releases all the memory used when the iteration is done, so it doesn’t have to hold data/info/traces/etc from previous iterations.
But clearly, something is persistent, which makes me think it’s something PyMC3 is doing… anyone have any guesses? thanks!