Memory usage increasing with each epoch

This is a recurring problem with Flux and Julia in general. You can see similar topics here:

There can be few problems.

  • If you have type instability, it consumes memory.
  • Sometimes, you keep julia compiling new version of the same function. This happens usually when you do something like cat(x...) where x is an array or tuple of different length.
  • The, there might not be enough. pressure on GC. Try to run GC.gc() after every iteration. It will be slow, but the memory will not grow, you will see that this solves the problem.
2 Likes