Hi,
According to this thread, each worker loads a single batch. The more number of workers essentially means it preloads “future” data in memory.
If that’s the case, then is there any benefit of using the iter/next approach to read batches from a loader?
If you are using the iter/next
approach, the DataLoader
iterator might already start preloading the data once you call the next
op on it, so you could potentially overlap the loading of the first batches with other operations in your main script.
Such an approach can be seen here.
1 Like
Thanks @ptrblck, I can confirm that in the iter/next
approach, the dataloader behaves as expect and preloads future batches when number of workers > 0. My observation is based on a vanilla dataloader from torch.