-
-
Notifications
You must be signed in to change notification settings - Fork 369
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
Clean up var memory in laplace_sample #3324
Conversation
Jenkins Console Log Machine informationNo LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 20.04.3 LTS Release: 20.04 Codename: focalCPU: G++: Clang: |
Submission Checklist
./runTests.py src/test/unit
make cpplint
Summary
First reported here: https://discourse.mc-stan.org/t/memory-errors-with-laplace-approximation-in-cmdstanr/37585
The call to log_prob needs to create vars so that the
propto=true
template argument works as intended. However, the vars created here are never cleaned up, so memory grows over iterations.Intended Effect
This uses the
stan::math::nested_rev_autodiff
RAII class to ensure the memory is always cleaned up each iteration.How to Verify
Running the model in the forum post and keeping an eye on
htop
Side Effects
None
Documentation
None
Copyright and Licensing
Please list the copyright holder for the work you are submitting (this will be you or your assignee, such as a university or company):
Simons Foundation
By submitting this pull request, the copyright holder is agreeing to license the submitted work under the following licenses: