-
Notifications
You must be signed in to change notification settings - Fork 31.2k
Fix eval thread fork bomb #39717
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 eval thread fork bomb #39717
Conversation
15e6a3a to
29d47b2
Compare
SunMarc
left a comment
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.
It would be better indeed to reuse the prepared dl. Can you share a reproducer btw ?
|
No problem, here's a reproducer. You can watch the number of processes grow by running |
29d47b2 to
b8b6b32
Compare
b8b6b32 to
d650d21
Compare
|
@SunMarc Do you need anything else from me or can this be merged? Thanks. |
Yeah, sorry for the long wait. I was able to reproduce and your fix works nicely ! |
|
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
What does this PR do?
Currently a fork bomb is being created due to the accelerator preparing a new dataloader at each evaluation when dataloader_persistent_workers=True.
It appears there was an attempt to fix this issue #29538 but the problem seems to still exist. I tried using version 4.39.0 which was the first release version that included that fix along with the most recent version of accelerate for that point in time (0.27.2) and was still able to reproduce the fork bomb.
This PR makes a minor change to the original fix by storing the prepared dataloader rather than the dataloader prior to preparing it with the accelerator.
The author of the original fix left a comment in the code specifically about storing the dataloader prior to being prepared due to accelerator.free_memory() destroying the references. I was unable to reproduce that problem when storing the prepared dataloader (even when calling accelerator.free_memory() before each evaluation), but wouldn't mind hearing from @muellerzr on why they did that in case I have missed something. Though at the same time he left this comment on the GitHub Issue suggesting he intended to make these same proposed changes.
Fixes #28469
Before submitting
Pull Request section?
to it if that's the case.
documentation guidelines, and
here are tips on formatting docstrings.
Who can review?
Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.
@SunMarc @amyeroberts