Skip to content

Dataset class usage in jupyter lab #20

@manerotoni

Description

@manerotoni

Hi,
I spotted an issue in the notebooks when using python 3.11 (and may be other versions) on my Windows machine.
Somehow the Dataset Class (CustomDataset) when defined in the notebook (e.g. torch_infection_classifier.ipynb) issues an error upon the

x, y = next(iter(train_loader))

The error on the command windows is

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\Users\apoliti\Miniconda3\envs\dl-for-micro-2\Lib\multiprocessing\spawn.py", line 122, in spawn_main
    exitcode = _main(fd, parent_sentinel)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\apoliti\Miniconda3\envs\dl-for-micro-2\Lib\multiprocessing\spawn.py", line 132, in _main
    self = reduction.pickle.load(from_parent)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: Can't get attribute 'CustomDataset' on <module '__main__' (built-in)>

A few google search indicate that the somehow the declaration in the notebook is not understood and there is some incompatibilities of multiprocessing and interactive mode (jupyter notebooks)
See https://discuss.pytorch.org/t/issue-with-pretrained-resnet-fixed/109637/4 and https://stackoverflow.com/questions/73763151/multiprocessing-error-self-reduction-pickle-loadfrom-parent-attributeerror

Metadata

Metadata

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions