Fastai: AttributeError: '_FakeLoader' object has no attribute 'persistent_workers' (using pytorch master)

Created on 4 Sep 2020  路  3Comments  路  Source: fastai/fastai

Describe the bug
Bug introduced by https://github.com/pytorch/pytorch/pull/35795 in pytorch master branch.

To Reproduce

from fastai.vision.all import *

path = Path('../Data/imagewoof2/')
dls = ImageDataLoaders.from_folder(path, valid='val', 
    item_tfms=RandomResizedCrop(128, min_scale=0.35), batch_tfms=Normalize.from_stats(*imagenet_stats))

dls.show_batch()
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-4-90634fcc3c9e> in <module>
----> 1 dls.show_batch()

~\miniconda3\lib\site-packages\fastai\data\core.py in show_batch(self, b, max_n, ctxs, show, unique, **kwargs)
     98             old_get_idxs = self.get_idxs
     99             self.get_idxs = lambda: Inf.zeros
--> 100         if b is None: b = self.one_batch()
    101         if not show: return self._pre_show_batch(b, max_n=max_n)
    102         show_batch(*self._pre_show_batch(b, max_n=max_n), ctxs=ctxs, max_n=max_n, **kwargs)

~\miniconda3\lib\site-packages\fastai\data\load.py in one_batch(self)
    135     def one_batch(self):
    136         if self.n is not None and len(self)==0: raise ValueError(f'This DataLoader does not contain any batches')
--> 137         with self.fake_l.no_multiproc(): res = first(self)
    138         if hasattr(self, 'it'): delattr(self, 'it')
    139         return res

~\miniconda3\lib\site-packages\fastcore\utils.py in first(x)
    209 def first(x):
    210     "First element of `x`, or None if missing"
--> 211     try: return next(iter(x))
    212     except StopIteration: return None
    213 

~\miniconda3\lib\site-packages\fastai\data\load.py in __iter__(self)
    101         self.randomize()
    102         self.before_iter()
--> 103         for b in _loaders[self.fake_l.num_workers==0](self.fake_l):
    104             if self.device is not None: b = to_device(b, self.device)
    105             yield self.after_batch(b)

~\miniconda3\lib\site-packages\torch\utils\data\dataloader.py in __init__(self, loader)
    464 class _SingleProcessDataLoaderIter(_BaseDataLoaderIter):
    465     def __init__(self, loader):
--> 466         super(_SingleProcessDataLoaderIter, self).__init__(loader)
    467         assert self._timeout == 0
    468         assert self._num_workers == 0

~\miniconda3\lib\site-packages\torch\utils\data\dataloader.py in __init__(self, loader)
    413         self._sampler_iter = iter(self._index_sampler)
    414         self._base_seed = torch.empty((), dtype=torch.int64).random_(generator=loader.generator).item()
--> 415         self._persistent_workers = loader.persistent_workers
    416         self._num_yielded = 0
    417 

AttributeError: '_FakeLoader' object has no attribute 'persistent_workers'

Most helpful comment

Any solution to this? I encountered the same problem and could not even finish the first course. Thanks much!

All 3 comments

Moved to #2768

Any solution to this? I encountered the same problem and could not even finish the first course. Thanks much!

Any solution to this? I encountered the same problem and could not even finish the first course. Thanks much!

I have the same problem too.. frustrating. I know use Paperspace untill there is a solution

Was this page helpful?
0 / 5 - 0 ratings

Related issues

FrancescoSaverioZuppichini picture FrancescoSaverioZuppichini  路  3Comments

rfernand2 picture rfernand2  路  4Comments

MinuteswithMetrics picture MinuteswithMetrics  路  5Comments

samshipengs picture samshipengs  路  4Comments

srmsoumya picture srmsoumya  路  5Comments