Hi everyone, I’m trying to run things on a local Jupyter notebook.
When I try to run the following code I get an error.
path = Path('Dance_types')
dances = DataBlock(
blocks=(ImageBlock, CategoryBlock),
get_items=get_image_files,
splitter=RandomSplitter(valid_pct=0.2, seed=42),
get_y=parent_label,
item_tfms=Resize(128))
dls = dances.dataloaders('Dance_types')
The error I get is this:
Could not do one pass in your dataloader, there is something wrong in it. Please see the stack trace below:
RuntimeError Traceback (most recent call last)
Cell In[22], line 1
----> 1 dls = dances.dataloaders(‘Dance_types’)File /usr/local/lib/python3.10/site-packages/fastai/data/block.py:157, in DataBlock.dataloaders(self, source, path, verbose, **kwargs)
155 dsets = self.datasets(source, verbose=verbose)
156 kwargs = {**self.dls_kwargs, **kwargs, ‘verbose’: verbose}
→ 157 return dsets.dataloaders(path=path, after_item=self.item_tfms, after_batch=self.batch_tfms, **kwargs)File /usr/local/lib/python3.10/site-packages/fastai/data/core.py:337, in FilteredBase.dataloaders(self, bs, shuffle_train, shuffle, val_shuffle, n, path, dl_type, dl_kwargs, device, drop_last, val_bs, **kwargs)
335 dl = dl_type(self.subset(0), **merge(kwargs,def_kwargs, dl_kwargs[0]))
336 def_kwargs = {‘bs’:bs if val_bs is None else val_bs,‘shuffle’:val_shuffle,‘n’:None,‘drop_last’:False}
→ 337 dls = [dl] + [dl.new(self.subset(i), **merge(kwargs,def_kwargs,val_kwargs,dl_kwargs[i]))
338 for i in range(1, self.n_subsets)]
339 return self._dbunch_type(*dls, path=path, device=device)File /usr/local/lib/python3.10/site-packages/fastai/data/core.py:337, in (.0)
335 dl = dl_type(self.subset(0), **merge(kwargs,def_kwargs, dl_kwargs[0]))
336 def_kwargs = {‘bs’:bs if val_bs is None else val_bs,‘shuffle’:val_shuffle,‘n’:None,‘drop_last’:False}
→ 337 dls = [dl] + [dl.new(self.subset(i), **merge(kwargs,def_kwargs,val_kwargs,dl_kwargs[i]))
338 for i in range(1, self.n_subsets)]
339 return self._dbunch_type(*dls, path=path, device=device)File /usr/local/lib/python3.10/site-packages/fastai/data/core.py:97, in TfmdDL.new(self, dataset, cls, **kwargs)
95 if not hasattr(self, ‘_n_inp’) or not hasattr(self, ‘_types’):
96 try:
—> 97 self._one_pass()
98 res._n_inp,res._types = self._n_inp,self._types
99 except Exception as e:File /usr/local/lib/python3.10/site-packages/fastai/data/core.py:79, in TfmdDL._one_pass(self)
77 def _one_pass(self):
78 b = self.do_batch([self.do_item(None)])
—> 79 if self.device is not None: b = to_device(b, self.device)
80 its = self.after_batch(b)
81 self._n_inp = 1 if not isinstance(its, (list,tuple)) or len(its)==1 else len(its)-1File /usr/local/lib/python3.10/site-packages/fastai/torch_core.py:285, in to_device(b, device, non_blocking)
283 # if hasattr(o, “to_device”): return o.to_device(device)
284 return o
→ 285 return apply(_inner, b)File /usr/local/lib/python3.10/site-packages/fastai/torch_core.py:222, in apply(func, x, *args, **kwargs)
220 def apply(func, x, *args, **kwargs):
221 “Applyfunc
recursively tox
, passing on args”
→ 222 if is_listy(x): return type(x)([apply(func, o, *args, **kwargs) for o in x])
223 if isinstance(x,dict): return {k: apply(func, v, *args, **kwargs) for k,v in x.items()}
224 res = func(x, *args, **kwargs)File /usr/local/lib/python3.10/site-packages/fastai/torch_core.py:222, in (.0)
220 def apply(func, x, *args, **kwargs):
221 “Applyfunc
recursively tox
, passing on args”
→ 222 if is_listy(x): return type(x)([apply(func, o, *args, **kwargs) for o in x])
223 if isinstance(x,dict): return {k: apply(func, v, *args, **kwargs) for k,v in x.items()}
224 res = func(x, *args, **kwargs)File /usr/local/lib/python3.10/site-packages/fastai/torch_core.py:224, in apply(func, x, *args, **kwargs)
222 if is_listy(x): return type(x)([apply(func, o, *args, **kwargs) for o in x])
223 if isinstance(x,dict): return {k: apply(func, v, *args, **kwargs) for k,v in x.items()}
→ 224 res = func(x, *args, **kwargs)
225 return res if x is None else retain_type(res, x)File /usr/local/lib/python3.10/site-packages/fastai/torch_core.py:282, in to_device.._inner(o)
281 def _inner(o):
→ 282 if isinstance(o,Tensor): return o.to(device, non_blocking=non_blocking)
283 # if hasattr(o, “to_device”): return o.to_device(device)
284 return oFile /usr/local/lib/python3.10/site-packages/fastai/torch_core.py:372, in TensorBase.torch_function(cls, func, types, args, kwargs)
370 if cls.debug and func.name not in (‘str’,‘repr’): print(func, types, args, kwargs)
371 if _torch_handled(args, cls._opt, func): types = (torch.Tensor,)
→ 372 res = super().torch_function(func, types, args, ifnone(kwargs, {}))
373 dict_objs = _find_args(args) if args else _find_args(list(kwargs.values()))
374 if issubclass(type(res),TensorBase) and dict_objs: res.set_meta(dict_objs[0],as_copy=True)File /usr/local/lib/python3.10/site-packages/torch/_tensor.py:1279, in Tensor.torch_function(cls, func, types, args, kwargs)
1276 return NotImplemented
1278 with _C.DisableTorchFunction():
→ 1279 ret = func(*args, **kwargs)
1280 if func in get_default_nowrap_functions():
1281 return retRuntimeError: The MPS backend is supported on MacOS 12.3+.Current OS version can be queried using
sw_vers
I’ve tried updating my system and I have now MacOS 13.2.1 but I still get the same error. I’ve looked around and it seems that people with the M1 chip were getting this type of error but I have the Intel one.
Could anyone help?