Code Monkey home page Code Monkey logo

Comments (6)

edknv avatar edknv commented on May 29, 2024 1

We can now create a context manager with dataloader (#78), so we can properly release the memory after each loop with:

train = nvt.Dataset(files, part_size="100MB")
for j in range(250):
    with Loader(train, batch_size=1024 * 64, shuffle=True, drop_last=True) as train_dl:
    for i, (inputs, labels) in enumerate(train_dl):
        # do stuff

instead of using dataloader.stop() which is easy to forget to do.

I confirmed that the memory is properly released by using a context manager in the original script.

from dataloader.

bschifferer avatar bschifferer commented on May 29, 2024

The potential solution is to call train_dl.stop() before del train, train_dl.

from dataloader.

viswa-nvidia avatar viswa-nvidia commented on May 29, 2024

@benfred , please check if there is a fix from @oliverholworthy and link it. Thank you

from dataloader.

rnyak avatar rnyak commented on May 29, 2024

@bschifferer did you test that solution and did it work?

from dataloader.

bschifferer avatar bschifferer commented on May 29, 2024

I need to call train_dl.stop() that all elements in the queue are deleted

from dataloader.

oliverholworthy avatar oliverholworthy commented on May 29, 2024

one hypothesis is we might need to implement __del__ to automatically clean itself up for the case where the dataloader doesn't get entirely consumed and the object goes out of scope. Or make it possible to use the loader as a context manager to handle this.

from dataloader.

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.