Skip to content
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

Use torch.no_grad to reduce GPU memory consumption #192

Merged
merged 1 commit into from
Apr 27, 2023

Conversation

fjxmlzn
Copy link
Contributor

@fjxmlzn fjxmlzn commented Apr 25, 2023

By default, PyTorch will store activations etc. for computing gradients. This will cause the CNN method to consume a large amount of GPU memory, ultimately causing GPU out-of-memory error when the dataset is large.

This pull request adds torch.no_grad context manager to disable gradient calculation and reduce memory consumption when computing CNN features.

@tanujjain tanujjain merged commit 2661472 into idealo:dev Apr 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants