DiffEqFlux.jl icon indicating copy to clipboard operation
DiffEqFlux.jl copied to clipboard

High memory usage

Open Emmanuel-R8 opened this issue 5 years ago • 3 comments

I ran the CNF example. @time repeatedly gives memory allocations around 50GB. Given that the example looks simplistic, I had expected to see much lower numbers.

Is that number in line with your expectations?

Emmanuel-R8 avatar Jul 10 '20 07:07 Emmanuel-R8

Note that's not peak memory usage but total, so it's not out of the realm of possibility when reverse-mode AD gets involved. That said, it seems rather high so there's probably some optimization that can be done.

ChrisRackauckas avatar Jul 10 '20 13:07 ChrisRackauckas

"Not peak usage". That's another aspect. I didn't check in detail, but the RAM system monitor hardly moves (total allocation at any point in time must remain quite limited). So it is an awful lot of memory churning.

I have never profiled Julia code. How easy would it be to get my feet wet tracking this?

Emmanuel-R8 avatar Jul 11 '20 03:07 Emmanuel-R8

https://stackoverflow.com/questions/49719076/macos-python-with-numpy-faster-than-julia-in-training-neural-network/49724611#49724611 describes a whole example. In modern Juno it color codes and shows you what lines have the allocations as well

ChrisRackauckas avatar Jul 11 '20 03:07 ChrisRackauckas

It was due to how Zygote handles nested diff. Using a different vjp backend (Enzyme) handles this.

ChrisRackauckas avatar Nov 22 '23 16:11 ChrisRackauckas