Hi everyone,
I am solving a very large (~10^8) system of ODE’s. I would like to use the VCABM
solver from ordinaryDiffEq since that seems to be fastest, but I have memory issues that I would like to understand better.
I am aware that the ODE solvers will allocate their cache dependent on the order.
It looks like VCABM needs quite a few caches about 60, looking at the implementation in OrdinaryDiffEq:
alg_cache
function alg_cache(alg::VCABM, u, rate_prototype, ::Type{uEltypeNoUnits},
::Type{uBottomEltypeNoUnits}, ::Type{tTypeNoUnits}, uprev, uprev2, f, t,
dt, reltol, p, calck,
::Val{true}) where {uEltypeNoUnits, uBottomEltypeNoUnits, tTypeNoUnits}
fsalfirst = zero(rate_prototype)
k4 = zero(rate_prototype)
dts = fill(zero(dt), 13)
c = fill(zero(t), 13, 13)
g = fill(zero(t), 13)
ϕ_n = Vector{typeof(rate_prototype)}(undef, 13)
ϕstar_nm1 = Vector{typeof(rate_prototype)}(undef, 13)
ϕstar_n = Vector{typeof(rate_prototype)}(undef, 13)
ϕ_np1 = Vector{typeof(rate_prototype)}(undef, 14)
for i in 1:13
ϕ_n[i] = zero(rate_prototype)
ϕstar_nm1[i] = zero(rate_prototype)
ϕstar_n[i] = zero(rate_prototype)
end
for i in 1:14
ϕ_np1[i] = zero(rate_prototype)
end
β = fill(zero(t), 13)
order = 1
max_order = 12
atmp = similar(u, uEltypeNoUnits)
recursivefill!(atmp, false)
tmp = zero(u)
ξ = zero(dt)
ξ0 = zero(dt)
utilde = zero(u)
utildem2 = zero(u)
utildem1 = zero(u)
utildep1 = zero(u)
atmp = similar(u, uEltypeNoUnits)
recursivefill!(atmp, false)
atmpm1 = similar(u, uEltypeNoUnits)
recursivefill!(atmpm1, false)
atmpm2 = similar(u, uEltypeNoUnits)
recursivefill!(atmpm2, false)
atmpp1 = similar(u, uEltypeNoUnits)
recursivefill!(atmpp1, false)
VCABMCache(u, uprev, fsalfirst, k4, ϕstar_nm1, dts, c, g, ϕ_n, ϕ_np1, ϕstar_n, β, order,
max_order, atmp, tmp, ξ, ξ0, utilde, utildem1, utildem2, utildep1, atmpm1,
atmpm2, atmpp1, 1)
end
I confirmed this by printing sizeofcache = Base.format_bytes(Base.summarysize(cache))
(gives 64 times the size of my state array).
This is quite a lot, but should still fit in my memory (for 100 caches the size of my input array, I should be only at 56 GB memory).
Nonetheless, I find my calculation to consume 2-3 times that amount (~133 GB).
Can anyone give me a pointer if this is expected? How do I find out why so much memory is allocated? A few more points:
- I use
save_everystep = false
. More generally, the memory allocation does not increase after the simulation is started, so it is no memory leak - I realize that arrays may allocate more memory than they need, but I believe this should not be an issue here, since I allocate my state with zeros(dims…)