question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. ItĀ collects links to all the places you might be looking at while hunting down a tough bug.

And, if youā€™re still stuck at the end, weā€™re happy to hop on a call to see how we can help out.

Subclasses of torch.utils.data.DataLoader are not supported

See original GitHub issue

šŸ› Bug description

When using the Ignite engine with a subclass of torch.utils.data.DataLoader, the engine re-instantiates the dataloader with its torch.utils.data.DataLoader base class, if the DataLoaderā€™s batch_sampler is not a ReproducibleBatchSampler. See engine.py, line 874 in my version (call to _update_dataloader).

This is super-dangerous, as people might not even notice that their custom DataLoader isnā€™t being used at all. Only found the issue because my custom DataLoader has some additional public members that arenā€™t parameters of the torch.utils.data.DataLoader constructor, which is being called in _update_dataloader.

Environment

  • PyTorch Version: 1.4.0
  • Ignite Version: 0.3.0
  • OS: Linux
  • How you installed Ignite: conda
  • Python version: 3.7.6

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
justusschockcommented, Mar 18, 2020

To jump into this: wrapping the whole dataloader would be difficult I think, because then we would probably bypass the userā€™s custom dataloader and directly use the dataset, which is also not wanted here.

IMO raising an exception is also not a good idea, since there are some userā€™s (like me) who carefully designed their custom dataloader to work and behave as expected with ignite. Raising a warning and improving the docs would be the way to go IMO.

If the user wishes to use a custom dataloader, we should expect him to make it work as he wishes and therefore simply making him aware of that problem should be sufficient

1reaction
vfdev-5commented, Feb 27, 2020

Yes, you are right about the warning, thanks for that.

In any case, in my opinion, re-initializing the DataLoader without a warning is not a good idea, as the constructor call may have side effects and doesnā€™t necessarily produce an ā€œidenticalā€ DataLoader instance.

If you have an idea on how to improve that, we are happy to discuss and implement that šŸ˜ƒ

Either way, I hope that this issue will soon be fixed with a future release!

You can also try our nightly releases with the latest features.

Read more comments on GitHub >

github_iconTop Results From Across the Web

torch.utils.data ā€” PyTorch 1.13 documentation
At the heart of PyTorch data loading utility is the torch.utils.data.DataLoader class. It represents a Python iterable over a dataset, with support for....
Read more >
Complete Guide to the DataLoader Class in PyTorch
This post covers the PyTorch dataloader class. We'll show how to load built-in and custom datasets in PyTorch, plus how to transform and...
Read more >
torch.utils.data.dataloader ā€” mmcv 1.3.3 documentation
Source code for torch.utils.data.dataloader. r"""Definition of the DataLoader and associated iterators that subclass _BaseDataLoaderIter To support theseĀ ...
Read more >
PyTorch: How to use DataLoaders for custom Datasets
Dataset and torch.utils.data.DataLoader on your own data (not just the torchvision.datasets )?. Is there a way to use the inbuiltĀ ...
Read more >
torch.utils.data.dataset ā€” Catalyst 20.02 documentation
To make it work with a map-style dataset with non-integral indices/keys, a custom sampler must ... When a subclass is used with :class:`~torch.utils.data....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found