idealo / imagededup

😎 Finding duplicate images made easy!
https://idealo.github.io/imagededup/
Apache License 2.0
5.18k stars 459 forks source link

Use torch.no_grad to reduce GPU memory consumption #192

Closed fjxmlzn closed 1 year ago

fjxmlzn commented 1 year ago

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.