-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Better error message when trying to re-initialize CUDA in forked subprocess #14709
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
Conversation
for more information, see https://pre-commit.ci
…into feature/cuda-initialized-check
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.
I am subscribed to your PRs, reviewing them before you even mark them as ready 🐎
Thank you! Is that a horse? Will mark it ready once I gave this a final check in Google Colab as well. |
Co-authored-by: Carlos Mocholí <[email protected]>
Co-authored-by: Carlos Mocholí <[email protected]>
Co-authored-by: Carlos Mocholí <[email protected]>
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.
LGTM!
What does this PR do?
Follow up to #14631
Follow up to #13405
We recently launched DDP Fork support in notebooks (ddp_notebook), and some users will soon report issues when seeing this error message in their notebooks: "Cannot re-initialize CUDA in forked subprocess".
The issue is mitigated by #14631 for our internal calls, and pytorch addresses torch.cuda utility function calls in pytorch/pytorch#84879 and pytorch/pytorch#85024. However, it can always happen that the user allocates CUDA memory accidentally without knowing that this is not supported with the fork start method. We point it out in our documentation, but that's not enough.
This PR introduces an error message that is more helpful than the default PyTorch one.
Does your PR introduce any breaking changes? If yes, please list them.
No
Before submitting
PR review
Anyone in the community is free to review the PR once the tests have passed.
Before you start reviewing make sure you have read Review guidelines. In short, see the following bullet-list:
Did you have fun?
I made sure I had fun coding 🙃
cc @Borda @carmocca @justusschock @awaelchli @akihironitta