Giter Club home page Giter Club logo

Comments (5)

ezhang7423 avatar ezhang7423 commented on July 17, 2024

I got the same issue on Linux with 32 GB of RAM.

from rl.

vmoens avatar vmoens commented on July 17, 2024

The output of this network is of size [1, 1000, 7, 215168] which is about 48Gb

import torch
import torchrl
import sys

input = torch.rand((1, 1000, 7, 3, 88, 88), dtype=torch.float32, device="meta")
print(sys.getsizeof(input.storage())/ 1_000_000, " MB") # This prints 650.496048  MB

net = torchrl.modules.ConvNet(in_features=3)
print(net(input).shape)

from rl.

matteobettini avatar matteobettini commented on July 17, 2024

How did you get 48Gb?

I am getting that it should be 6Gb

output = torch.rand((1, 1000, 7, 215168), dtype=torch.float32)
print(sys.getsizeof(output.storage()) / 1_000_000, " MB") # 6024.704048  MB

from rl.

vmoens avatar vmoens commented on July 17, 2024

Without no_grad you are saving each intermediate activation in a computational graph for backward calls
this runs

import torch
import torchrl
import sys

input = torch.rand((1, 1000, 7, 3, 88, 88), dtype=torch.float32)
print(sys.getsizeof(input.storage())/ 1_000_000, " MB") # This prints 650.496048  MB

net = torchrl.modules.ConvNet(in_features=3)
with torch.no_grad():
    print(net(input).shape)

In general I wouldn't advise to call a non-customized conv net on 7000 elements at once on a laptop.

See this recent post on how to profile how big your call is going to be
https://dev-discuss.pytorch.org/t/how-to-measure-memory-usage-from-your-model-without-running-it/2024

from rl.

matteobettini avatar matteobettini commented on July 17, 2024

Got it. Thanks a lot for this!

from rl.

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.