Git Product home page Git Product logo

Comments (5)

frgfm avatar frgfm commented on May 17, 2024

Hi @FredrikM97,

Good catch! I just opened a PR that will fix this, let me know if you encounter other issues 👌

from torch-cam.

FredrikM97 avatar FredrikM97 commented on May 17, 2024

@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.

frgfm avatar frgfm commented on May 17, 2024

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.

FredrikM97 avatar FredrikM97 commented on May 17, 2024

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.

frgfm avatar frgfm commented on May 17, 2024

Gotcha, let's move the discussion to the issue #44

from torch-cam.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.