Skip to content

Recurrent 3d interface uses a lot of memory #1872

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
mkschleg opened this issue Feb 13, 2022 · 4 comments
Closed

Recurrent 3d interface uses a lot of memory #1872

mkschleg opened this issue Feb 13, 2022 · 4 comments

Comments

@mkschleg
Copy link
Contributor

mkschleg commented Feb 13, 2022

After making the recurrent performance measure in #1871 , I noticed that the memory usage of the 3d interface from #1686 uses significantly more memory than the normal interface. This likely has to do with creating views to walk across the temporal dimension. This wasn't an issue for smaller networks (which is what we mostly used to test), but starts becoming problematic as things get larger/the sequence is longer. Below are the benchmark results

Normal Interface:

CPU n=1000, t=64
  forward
  1.682 s (384 allocations: 728.63 MiB)
  backward
  2.197 s (5928 allocations: 2.13 GiB)
  forw and back
  4.545 s (13591 allocations: 3.32 GiB)

3d Interface:

CPU n=1000, t=64
  forward
  1.765 s (389 allocations: 976.58 MiB)
  backward
  14.547 s (7973 allocations: 32.41 GiB)
  forw and back
  17.122 s (16308 allocations: 33.61 GiB)
@mkschleg mkschleg changed the title Recurrent Recurrent 3d interface uses a lot of memory Feb 13, 2022
@ToucheSir
Copy link
Member

Thanks for testing this, I think it's a good time to think about eachslice again as I noted in #1678 (comment) :)

@mkschleg
Copy link
Contributor Author

mkschleg commented Feb 13, 2022

That definitely fixes this. With eachslice

CPU n=1000, t=64
  forward
  819.105 ms (397 allocations: 976.58 MiB)
  backward
  1.586 s (4208 allocations: 2.37 GiB)
  forw and back
  2.658 s (6147 allocations: 3.57 GiB)

@ToucheSir
Copy link
Member

Those are some pretty good improvements over the normal interface! I'm curious why the amount of memory allocated is slightly higher given that the count is lower (especially for forward + backward, what in the world is going on there!) but figuring that out now is not important.

@mkschleg
Copy link
Contributor Author

Yeah. Learning about the issues using views in zygote has really opened my eyes to some things I wasn't paying attention to before. Thanks for pointing to eachslice again :)!

@mkschleg mkschleg mentioned this issue Feb 14, 2022
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants