Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Memory Error: Loads the entire dataset into Memory #184

Closed
srmsoumya opened this issue Mar 2, 2018 · 5 comments
Closed

Memory Error: Loads the entire dataset into Memory #184

srmsoumya opened this issue Mar 2, 2018 · 5 comments

Comments

@srmsoumya
Copy link

The RAM is getting filled up after a few iterations, this causes a problem in handling large datasets. I am not sure but I think it is loading the entire data into Memory.

@farhanhubble
Copy link

farhanhubble commented Mar 4, 2018

I faced the same OOM issue. It's caused by ThreadPoolExecutor in DataLoader class defined in fastai/dataloader.py. I am able to run the code after replacing the thread pool by a single execution thread. Here's the diff:

-        with ThreadPoolExecutor(max_workers=self.num_workers) as e:
-            for batch in e.map(self.get_batch, iter(self.batch_sampler)):
-                yield get_tensor(batch, self.pin_memory)
+        for batch in map(self.get_batch, iter(self.batch_sampler)):
+            yield get_tensor(batch, self.pin_memory)

I tried to set max_workers to 1 too but that didn't work. Understanding where memory is being lost will require more ananlysis.

@farhanhubble
Copy link

After a little bit of analysis, the OOM error is caused because ThreadPoolExecutor creates all batches and stores them in memory and then returns a generator to fetch the batches from. This behavior has changed from Python 3.5 to 3.6
executer_map_python3 5
executer_map_python3 6

@WilliamNurmi
Copy link

WilliamNurmi commented Mar 6, 2018

Linking a related forum thread. The pool executor change doesn't seem to solve issue for me. 30GB RAM is used up in no time by Kaggle's google landmark dataset.

EDIT: Maybe a slightly different issue since this one was reported to only occur after a few iterations..

@jph00
Copy link
Member

jph00 commented Mar 6, 2018

Best off using the forum for this.

@jph00 jph00 closed this as completed Mar 6, 2018
@jaideep11061982
Copy link

with ThreadPoolExecutor

making num workers =0 will execute the code that you are putting there is a if condition in a dataloader...
so that we dont have to modify the loader at all

borisdayma pushed a commit to borisdayma/fastai that referenced this issue Aug 18, 2020
…tation (fastai#184)

* add classification report to ClassificationInterpretation"

* merge upstream
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants