You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Running 00b_How_to_use_numpy_arrays_in_fastai.ipynb from source code as checked out today (below are commit hashs and repro version info). Reporting for the record; I'll see if I can find a fix and submit a PR.
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
Input In [10], in <cell line: 6>()
4 valid_dl = DataLoader(valid_ds, bs=128, num_workers=0)
5 dls = DataLoaders(train_dl, valid_dl, device=default_device())
----> 6 xb,yb = next(iter(dls.valid))
7 print(xb, yb)
8 print(f'shape: {str(len(train_ds)):10} bs: {xb.shape}')
File ~/src/fastai/fastai/data/load.py:125, in DataLoader.__iter__(self)
123 self.before_iter()
124 self.__idxs=self.get_idxs() # called in context of main process (not workers/subprocesses)
--> 125 for b in _loaders[self.fake_l.num_workers==0](self.fake_l):
126 # pin_memory causes tuples to be converted to lists, so convert them back to tuples
127 if self.pin_memory and type(b) == list: b = tuple(b)
128 if self.device is not None: b = to_device(b, self.device)
File ~/miniconda/envs/fai_pt/lib/python3.9/site-packages/torch/utils/data/dataloader.py:530, in _BaseDataLoaderIter.__next__(self)
528 if self._sampler_iter is None:
529 self._reset()
--> 530 data = self._next_data()
531 self._num_yielded += 1
532 if self._dataset_kind == _DatasetKind.Iterable and \
533 self._IterableDataset_len_called is not None and \
534 self._num_yielded > self._IterableDataset_len_called:
File ~/miniconda/envs/fai_pt/lib/python3.9/site-packages/torch/utils/data/dataloader.py:570, in _SingleProcessDataLoaderIter._next_data(self)
568 def _next_data(self):
569 index = self._next_index() # may raise StopIteration
--> 570 data = self._dataset_fetcher.fetch(index) # may raise StopIteration
571 if self._pin_memory:
572 data = _utils.pin_memory.pin_memory(data)
File ~/miniconda/envs/fai_pt/lib/python3.9/site-packages/torch/utils/data/_utils/fetch.py:39, in _IterableDatasetFetcher.fetch(self, possibly_batched_index)
37 raise StopIteration
38 else:
---> 39 data = next(self.dataset_iter)
40 return self.collate_fn(data)
File ~/src/fastai/fastai/data/load.py:136, in DataLoader.create_batches(self, samps)
134 if self.dataset is not None: self.it = iter(self.dataset)
135 res = filter(lambda o:o is not None, map(self.do_item, samps))
--> 136 yield from map(self.do_batch, self.chunkify(res))
File ~/miniconda/envs/fai_pt/lib/python3.9/site-packages/fastcore/basics.py:219, in chunked(it, chunk_sz, drop_last, n_chunks)
217 if not isinstance(it, Iterator): it = iter(it)
218 while True:
--> 219 res = list(itertools.islice(it, chunk_sz))
220 if res and (len(res)==chunk_sz or not drop_last): yield res
221 if len(res)<chunk_sz: return
File ~/src/fastai/fastai/data/load.py:151, in DataLoader.do_item(self, s)
150 def do_item(self, s):
--> 151 try: return self.after_item(self.create_item(s))
152 except SkipItemException: return None
File ~/src/fastai/fastai/data/load.py:158, in DataLoader.create_item(self, s)
157 def create_item(self, s):
--> 158 if self.indexed: return self.dataset[s or 0]
159 elif s is None: return next(self.it)
160 else: raise IndexError("Cannot index an iterable dataset numerically - must use `None`.")
File ~/src/tsai/tutorial_nbs/tsai/data/core.py:256, in TSDataset.__getitem__(self, idx)
254 y = self._types[1](self.y[idx].compute(), device=self.device, dtype=self.dtype)
255 else:
--> 256 y = self._types[1](self.y[idx], device=self.device, dtype=self.dtype)
257 return (X, y)
File ~/src/fastai/fastai/torch_core.py:319, in TensorBase.__new__(cls, x, **kwargs)
317 def __new__(cls, x, **kwargs):
318 res = cast(tensor(x), cls)
--> 319 for k,v in kwargs.items(): setattr(res, k, v)
320 return res
AttributeError: attribute 'device' of 'torch._C._TensorBase' objects is not writable
Thanks for reporting this issue, @jmp75!
I've just fixed the issue and rerun the notebook. It should work now.
It'd be great if you try it in your environment. If it works, please, feel free to close the issue.
Running 00b_How_to_use_numpy_arrays_in_fastai.ipynb from source code as checked out today (below are commit hashs and repro version info). Reporting for the record; I'll see if I can find a fix and submit a PR.
Symptoms
Call stack is:
Environment
To be a bit more precise since installed from source:
The text was updated successfully, but these errors were encountered: