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

'_FakeLoader' object has no attribute 'pin_memory_device' #3996

Open
tiagu opened this issue Dec 21, 2023 · 0 comments
Open

'_FakeLoader' object has no attribute 'pin_memory_device' #3996

tiagu opened this issue Dec 21, 2023 · 0 comments

Comments

@tiagu
Copy link

tiagu commented Dec 21, 2023

Hi

I am trying to run a dataloader .show_batch() but getting an attribute error:

dls.show_batch()

File env/lib/python3.10/site-packages/fastai/data/core.py:100, in TfmdDL.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)

File env/lib/python3.10/site-packages/fastai/data/load.py:137, in DataLoader.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

File env/lib/python3.10/site-packages/fastcore/basics.py:660, in first(x, f, negate, **kwargs)
    658 x = iter(x)
    659 if f: x = filter_ex(x, f=f, negate=negate, gen=True, **kwargs)
--> 660 return next(x, None)

File env/lib/python3.10/site-packages/fastai/data/load.py:101, in DataLoader.__iter__(self)
     99 self.before_iter()
    100 self.__idxs=self.get_idxs() # called in context of main process (not workers/subprocesses)
--> 101 for b in _loaders[self.fake_l.num_workers==0](self.fake_l):
    102     if self.device is not None: b = to_device(b, self.device)
    103     yield self.after_batch(b)

File env/lib/python3.10/site-packages/torch/utils/data/dataloader.py:659, in _SingleProcessDataLoaderIter.__init__(self, loader)
    658 def __init__(self, loader):
--> 659     super().__init__(loader)
    660     assert self._timeout == 0
    661     assert self._num_workers == 0

File env/lib/python3.10/site-packages/torch/utils/data/dataloader.py:587, in _BaseDataLoaderIter.__init__(self, loader)
    583 self._rank = rank
    584 # for other backends, pin_memory_device need to set. if not set
    585 # default behaviour is CUDA device. if pin_memory_device is selected
    586 # and pin_memory is not set, the default behaviour false.
--> 587 if (len(loader.pin_memory_device) == 0):
    588     self._pin_memory = loader.pin_memory and torch.cuda.is_available()
    589     self._pin_memory_device = None

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

Any idea of how to solve this?

Thank you


torch 2.1.1
fastai 2.1.10
torchvision 0.16.1
fastcore 1.5.29

cuda available: True, 12.1

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

1 participant