-
Notifications
You must be signed in to change notification settings - Fork 1.2k
DataLoader with num_workers > 1, and a Rand[Zoom/Rotate/Flip)d transforms #398
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
Comments
Hi @hjmjohnson , Thanks for your bug report. def worker_init_fn(worker_id):
worker_info = torch.utils.data.get_worker_info()
worker_info.dataset.transform.set_random_state(worker_info.seed % (2 ** 32 - 1))
dataloader = torch.utils.data.DataLoader(... worker_init_fn=worker_init_fn) Thanks. |
FYI: I also came across documentation that indicates the real problem is out of the scope of MONAI.
|
@Nic-Ma THANK YOU! Sorry for the invalid MONAI bug report. Your solution worked wonderfully! |
You are welcome. |
Should a note about this be put in our wiki or somewhere similar to start collating an FAQ? |
Hi @tvercaut , Good idea, maybe @atbenmurray can help add this to our wiki page? |
@Nic-Ma It would be nice if the FAQ were indexed in a way that the Sphinx documentation could reference the FAQ content. |
I will try to raise the topic to set up FAQ to the core team guys. |
Describe the bug
When using a DataLoader with num_workers > 1, and a Rand[Zoom/Rotate/Flip)d transform, all the data in the multiple workers have the same random state.
To Reproduce
With
train_ds
having some random parameterized transforms.This is particularly disturbing when running on a machine with 40+ CPUs and huge numbers of images have the same parameter augmentation.
Expected behavior
Each transform should have it's own random parameters chosen, regardless of the number of workers chosen.
Screenshots
NOTE: The number of replicated rotation values is always equal to the num_workers specified.
The text was updated successfully, but these errors were encountered: