-
Notifications
You must be signed in to change notification settings - Fork 355
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
Fix memory leak #307
Fix memory leak #307
Conversation
Thanks a lot @kzhang2 -- this looks great (incl. Meta-SGD!). I'll merge and cut a new release as soon as it passes the tests. |
tests/unit/algorithms/maml_test.py
Outdated
N_STEPS = 5 | ||
N_EVAL = 2 | ||
|
||
device = torch.device('cuda:0') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GitHub actions don't have cuda. Can we shield this test with: if torch.cuda.is_available():
so it doesn't run if the machine doesn't have cuda?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
@@ -80,6 +80,34 @@ def test_adaptation(self): | |||
self.assertTrue(hasattr(p, 'grad')) | |||
self.assertTrue(p.grad.norm(p=2).item() > 0.0) | |||
|
|||
def test_memory_consumption(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kzhang2 and shield this test too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
OK, it took a bit of elbow grease but it seems to work now (I also took the opportunity to rewrite some flaky tests). Thanks for contributing this. |
Description
Fixes #284
Fix memory leak in
maml.py
andmeta-sgd.py
and add tests tomaml_test.py
andmetasgd_test.py
to check for possible future memory leaks. A test involving cloning parameters seems to fail, but my changes have nothing to do with it.If necessary, use the following space to provide context or more details.
Contribution Checklist
If your contribution modifies code in the core library (not docs, tests, or examples), please fill the following checklist.
Optional
If you make major changes to the core library, please run
make alltests
and copy-paste the content ofalltests.txt
below.