Code Monkey home page Code Monkey logo

Comments (2)

jbms avatar jbms commented on May 29, 2024

Regardless of whether you use fork or spawn, it is not possible for caches to be shared across multiple processes. Instead, each process will have an independent cache with the same configuration (i.e. total_bytes_limit).

It is unfortunate that the PyTorch data loader does not offer a way to use multiple threads rather than multiple processes --- ultimately that would be the best solution when using libraries like tensorstore that internally release the Python Global Interpreter Lock (GIL), and it seems to have been asked a number of times on the PyTorch discussion forum:

https://discuss.pytorch.org/t/dataloader-using-python-thread-as-opposed-to-multiprocess/86565

It might be worth looking into the PyTorch source code to see what would be required to allow DataLoader to use multiple threads and/or allow data loading to be done asynchronously. I expect that may ultimately be the easiest solution.

A hacky alternative would be something along the lines of the following:

  • You start a single additional process (possibly using pytorch's multiprocessing facilities) that will use tensorstore to load data.
  • Someone have each process started by PyTorch data loader forward its requests to this other process

from tensorstore.

ziw-liu avatar ziw-liu commented on May 29, 2024

@jbms Thanks for the answer! I will look into rolling my own cache implementation then.

from tensorstore.

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.