Fix CUDA out of memory error during backward pass#218
Open
Likhithsai2580 wants to merge 1 commit intomindverse:developfrom
Open
Fix CUDA out of memory error during backward pass#218Likhithsai2580 wants to merge 1 commit intomindverse:developfrom
Likhithsai2580 wants to merge 1 commit intomindverse:developfrom
Conversation
Add fix for CUDA out of memory error during backward pass. * **Environment Variable**: Set `PYTORCH_CUDA_ALLOC_CONF=expandable_segments:True` at the beginning of `lpm_kernel/L2/train.py` to avoid fragmentation. * **Error Handling**: Add a try-except block around the backward pass to catch `torch.cuda.OutOfMemoryError`. * Log an error message when the out of memory error occurs. * Free up GPU memory using `torch.cuda.empty_cache()` in the except block. * Retry the backward pass after freeing up GPU memory.
yingapple
reviewed
Apr 14, 2025
Collaborator
|
Hi @Likhithsai2580 👋, Thank you so much for your contribution to this PR! Your work is really appreciated. If you haven’t already, feel free to join our Discord community here: Discord Invite Link — it's a great place to connect with our team and other contributors, share ideas, and stay up to date with the project! You can find me as @scarlettt_moon there! Looking forward to connecting! 😊 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add fix for CUDA out of memory error during backward pass.
PYTORCH_CUDA_ALLOC_CONF=expandable_segments:Trueat the beginning oflpm_kernel/L2/train.pyto avoid fragmentation.torch.cuda.OutOfMemoryError.torch.cuda.empty_cache()in the except block.