does each worker (num_workers>1) has its own instance of the Dataset object? #14166
-
I am currently working on a code where the dataset has one property that
However, everything works fine if I use only one worker (numworkers=0), so I guess I a doing something wrong and/or I don't understand how dataloader works with multiple workers Any suggestion on how to tackle this problem? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
It's because when you use potential sol you can try: https://stackoverflow.com/questions/63460992/how-do-i-fix-the-dataset-to-return-desired-output-pytorch |
Beta Was this translation helpful? Give feedback.
It's because when you use
num_workers> 0
, the data is loaded, and thecollate_fn
is called inside the worker and that fetched data is pushed to the main process. So all the updates are happening inside the sub-worker process, buttraining_step
runs on the main process, so no effect is reflected there.potential sol you can try: https://stackoverflow.com/questions/63460992/how-do-i-fix-the-dataset-to-return-desired-output-pytorch