memory usage in assimulo?

7 posts / 0 new
Last post
katief
Offline
Joined: 2011-11-29
memory usage in assimulo?

I would like to run code like this many times within a loop:

mod = Explicit_Problem()
mod.f = rhs # rhs in each iteration is slightly different
y0 = [...]
....
sim = CVode(mod, y0)
sim.simulate()

When I run this, the memory used steadily increases with each iteration. It seems that the memory associated with sim is not freed (?). Is there a way to explicitly free this memory? Or reuse sim with a new rhs?

thanks!

chria
Offline
Joined: 2009-07-29
Hi Kate,   I remember seeing

Hi Kate,
 
I remember seeing this before when we used Sundials in a multiple shooting algorithm. In the current version of Assimulo when a simulation is complete we call sundials CVodeFree method to free the memory used by the solver. In this case this is necessary as we do not know if the user plans to change the method used (BDF, Adams) in the next simulation which needs a different sized chunk of memory.
 
As I look at it, that free method may not be called correctly in all cases. However I'm working on a new version of Assimulo where I believe that problem should be fixed, among other things and which should be released very soon. May I ask if you are using Assimulo as a standalone package? Btw which version of Assimulo are you using? And what platform?
 
Best
/Christian

katief
Offline
Joined: 2011-11-29
Thanks Christian! I am

Thanks Christian! I am running ubuntu 10.04, sundials 2.4, and assimulo 1.4b3. I am importing CVode through assimulo using statements like
from assimulo.explicit_ode import CVode
from assimulo.problem import Explicit_Problem

I should also mention that the function I pass to Explicit_Problem().f is a cython (version .15.1) compiled function. I've tried a pure python function as well but the memory usage problem remains.

I appreciate your help.

thanks,
katie

guitorri
Offline
Joined: 2011-11-30
IDA also leaking?

Hello Christian,

I also observe a steep increase in memory consumption when I do repeated calls to .simulate(). I have setup a Implicit_Problem using IDA. The model has some 15 equations an I am asking for quite some communication points on every simulation.

I have a closer look into my code, but I don't think my residual and jacobian functions are leaking that much... after a handful of runs 4-5GB of memory are used up. I need to close the session to have it released...

Any change it is already patched on Assimulo 1.4b3 ? ( I will upgrade anyway )

How do you debug it? Does Valgrind helps? I might try some debug here...

By the way, I am using Assimulo under Sage.

My enviroment:
Mac OXS 10.6.8 / Sundials 2.4.0 / Assimulo 1.4b2 / Sage 4.7.1

Any help is appreciated!

Regards,
Guilherme

chria
Offline
Joined: 2009-07-29
Hi Katie and Guilherme   I

Hi Katie and Guilherme
 
I think I know whats wrong with the memory consumption and believe that I have fixed it in the new version which we will be releasing next week. Do you think you could hold on for a few days and then try out the new version to see if it still persist? That would be most helpful.
 
Best
/Christian

katief
Offline
Joined: 2011-11-29
thanks again, Christian. This

thanks again, Christian. This would be very helpful. I'd be happy to help test the new version next week. Looking forward to trying it out!

katie

chria
Offline
Joined: 2009-07-29
Hi Katie,   I just put out a

Hi Katie,

 

I just put out a beta version of 2.0, alot have been changed internally so there might be some issues to sort out, hopefully minor. The version can be download from http://www.jmodelica.org/assimulo and if you go to download. It requires that you have Cython version 0.15, Numpy, Scipy and Sundials 2.4. Just download, unzip and type:

python setup.py install --sundials-home=/where/sundials/is

 

Also the interface have been changed slightly, say for instance you want so simulate an ode with CVode:

from assimulo.solvers.sundials import CVode
from assimulo.problem import Explicit_Problem
import numpy as N

def rhs(t,y):
   ydot = -y[0]
   return N.array([ydot])

#Define an Assimulo problem
exp_mod = Explicit_Problem(rhs, y0=4) #Input the function and initial condtions
#It is also allowed to input the function as "exp_mod.rhs = f" Notice the "rhs".
    
#Define an explicit solver
exp_sim = CVode(exp_mod) #Create a CVode solver

#Simulate
t, y = exp_sim.simulate(5,100) #The result is now returned from the simulate command

In the documentation on the Assimulo site, there is a bunch of describing examples as well.

 

Let me know how it goes and any input/suggestions for improvement is much appreciated! Hopefully the memory issue is taken care of, if not I'll dig deeper.

 

Best

/Christian

Login or register to post comments