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

DataLoader tutorial does not handle num_workers > 0 #352

Closed
NicolasHug opened this issue Apr 7, 2022 · 3 comments
Closed

DataLoader tutorial does not handle num_workers > 0 #352

NicolasHug opened this issue Apr 7, 2022 · 3 comments
Labels
documentation Improvements or additions to documentation

Comments

@NicolasHug
Copy link
Member

I just wanted to document an issue with the tutorials https://pytorch.org/data/beta/tutorial.html#working-with-dataloader

The code in the tutorial will not work when running multiple DataLoader processes as the datapipe will be duplicated across workers:

    dl = DataLoader(dataset=datapipe, batch_size=2, shuffle=True, num_workers=2)

    for i, e in enumerate(dl):
        print(e)

gives

{'label': tensor([7, 0], dtype=torch.int32), 'data': tensor([[0.5105, 0.7899],
        [0.0152, 0.5981]], dtype=torch.float64)}
{'label': tensor([7, 0], dtype=torch.int32), 'data': tensor([[0.5105, 0.7899],
        [0.0152, 0.5981]], dtype=torch.float64)}
{'label': tensor([4, 6], dtype=torch.int32), 'data': tensor([[0.9998, 0.5452],
        [0.8515, 0.8264]], dtype=torch.float64)}
{'label': tensor([4, 6], dtype=torch.int32), 'data': tensor([[0.9998, 0.5452],
        [0.8515, 0.8264]], dtype=torch.float64)}
{'label': tensor([1, 9], dtype=torch.int32), 'data': tensor([[0.8423, 0.3664],
        [0.6397, 0.6408]], dtype=torch.float64)}
{'label': tensor([1, 9], dtype=torch.int32), 'data': tensor([[0.8423, 0.3664],
        [0.6397, 0.6408]], dtype=torch.float64)}
...

Even though this is still beta, it may still be worth letting users know about such pitfalls.

Also, since there are various ways to achieve the sharding, it could be useful to settle on a definite canonical way of handling all this.

@ejguan
Copy link
Contributor

ejguan commented Apr 7, 2022

Thanks for the feedback!!!

Also, since there are various ways to achieve the sharding, it could be useful to settle on a definite canonical way of handling all this.

Yeah. Like where users should put sharding in the datapipe graph. Also, the discrepancy of result should be mentioned as well in #302

@ejguan ejguan added the documentation Improvements or additions to documentation label Apr 7, 2022
@franchesoni
Copy link

It would be nice to see an updated tutorial, I don't know how to do this in an easy way 😭

Using 0 < num_workers is a very common usecase, it could be nice to have a default solution. On top, the datapipe examples provided have no consideration for this case (except https://github.com/pytorch/torchrec/blob/main/torchrec/datasets/criteo.py).

Maybe a quick explanation here could suffice for now 😜

NivekT added a commit that referenced this issue May 24, 2022
Updating the tutorial and README with more relevant/correct information

Fixes #352 

Differential Revision: [D36645515](https://our.internmc.facebook.com/intern/diff/D36645515)

[ghstack-poisoned]
NivekT added a commit that referenced this issue May 25, 2022
Updating the tutorial and README with more relevant/correct information. Minor fix to one part of `MapDataPipe` documentation as well.

Fixes #352 

Differential Revision: [D36645515](https://our.internmc.facebook.com/intern/diff/D36645515)

[ghstack-poisoned]
NivekT added a commit that referenced this issue May 25, 2022
Updating the tutorial and README with more relevant/correct information. Minor fix to one part of `MapDataPipe` documentation as well.

Fixes #352 

Differential Revision: [D36645515](https://our.internmc.facebook.com/intern/diff/D36645515)

[ghstack-poisoned]
NivekT added a commit that referenced this issue May 25, 2022
Updating the tutorial and README with more relevant/correct information. Minor fix to one part of `MapDataPipe` documentation as well.

Fixes #352
NivekT added a commit that referenced this issue May 25, 2022
Updating the tutorial and README with more relevant/correct information. Minor fix to one part of `MapDataPipe` documentation as well.

Fixes #352
@NivekT
Copy link
Contributor

NivekT commented Jun 10, 2022

The tutorial has been updated. If anyone is still experiencing any issue with the nightly version, feel free to re-open.

@NivekT NivekT closed this as completed Jun 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

4 participants