Comments (5)
Hi @FredrikM97,
Good catch! I just opened a PR that will fix this, let me know if you encounter other issues 👌
from torch-cam.
@frgfm Thank you very much! I did find something yesterday. I modified SSCAM to support 5D input but during the init of the weights the GPU memory usage shoot up to >18gb.This is on a singel image of size (1,79,95,79). There after I resize the image to (1,79,224,224) and this takes ~30 gb memory which seem unreasonable. I assume there is a memory leak. Either by me or that already existed. When training the model on a batch size of 6 it take ~5gb memory. For SSCAM I use a batch size of 1 and num_samples is 1. Any ideas? Maybe the garbage collector does not free the memory or the become to big?
from torch-cam.
I see that you opened an issue, but a few things to keep in mind:
- what do you mean by 5D precisely? tensors of higher dimensions are naturally taking orders of magnitudes more RAM
- compared to a tensor of a RGB image (1, 3, 224, 224), your (1, 79, 224, 224) tensor only takes ~26 times more RAM. Since you forward this into a model, you can be sure that it will take a lot of memory.
- you're comparing training with SSCAM, but the paper is not exactly memory or computation-savy. Feel free to read the paper, but I would suggest SmoothGradCAMpp which is much much faster (the gradient will take some RAM but you won't have the multiple forward mechanism)
from torch-cam.
By 5D I mean: (batch, rgb, depth, hight, width). Read the paper but maybe a bit to fast.
In order to reduce the memory usage could one approach be to take one depth at the time (1,1,1,224,224) and merge them afterwards? Wanted to do at least comparison with SSCAM so still working on a solution.
from torch-cam.
Gotcha, let's move the discussion to the issue #44
from torch-cam.
Related Issues (20)
- VGG16 can't assist with plain CAM? HOT 2
- IS-CAM formula error? HOT 4
- Error when clearing hooks HOT 1
- self._normalize() got NAN... HOT 7
- What is class_idx in __call__() ?? HOT 6
- What are the requirements of the model by using these visual code? HOT 10
- [demo] Automate deployment to HF Spaces
- Upcoming support for new CAM methods
- Release tracker - v0.5.0
- More NaNs HOT 7
- didn't find remove_hooks() in cam_extractor HOT 2
- RuntimeError: 'cannot register a hook on a tensor that doesn't require gradient' HOT 7
- Remove hooks once we're done with CAM extractors
- use torch-cam/scripts/cam_example.py throw a exception: HOT 5
- target_layer path error HOT 3
- Does torch-cam still support 3D resnet model? HOT 3
- SmoothGradCAMpp returning GRAD CAM with NANs for some images, not all HOT 3
- How to get CAM for custom 3D model? HOT 19
- RuntimeError: cannot register a hook on a tensor that doesn't require gradient HOT 1
- No difference between GradCAM and XGradCAM HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from torch-cam.