[SciPy-User] odeint MemoryError

Fabrice Silva silva@lma.cnrs-mrs...
Sat Jul 21 07:38:30 CDT 2012

Le mercredi 11 juillet 2012 à 13:05 +0000, Loïc a écrit :
> Hi,
> I'm trying to run scipy.integrate.odeint on a rather large vector, but obtain a 
> memory error.
> I do not really understand why I'm getting this error as my vector can fit into 
> memory...
> Which scipy internal operation could trigger the error?
> Maybe is there some internal parameter to tune?
> Here is a small test program which obtain a MemoryError :
> --
> from scipy import *
> from scipy.integrate import *
> n = 45000

Note that odeint bases on lsoda, an algorithm suited for stiff and
nonstiff problems. When detecting that the problem is stiff and if you
do not provide a banded jacobian matrix, the algorithm need an internal
work array with size 22 + 9 * n + n**2 which may be way too big for your

The solution may be either to provide a banded jacobian (easy in the toy
example you provided) or to use simpler ODE solver as vode (with Adams
integrator, not BDF) or Runge-Kutta ones.
Fabrice Silva

More information about the SciPy-User mailing list