Prefetch_factor in Dataloader

Hi,

According to doc, the prefetch_factor is the number of samples loaded in advance by each worker, and it’s 2 by default.
I’m wondering what’s the meaning of pre-loading merely 2 examples, instead of pre-loading, say, 2 batches of data.
Does pre-loading a few examples really help?

Thanks

As with many things, the best way to answer a setup-dependent question like that is to instrument a working example. Depending on the speed of model execution, the speed of storage, the number of workers, the OS filesystem caching policy, the “optimal” prefetch factor will vary, so if you find evidence that this isn’t a sane default, please open an upstream issue or PR!

It does pre-load 2 batches of data (not samples). The docstring on the master branch has been corrected.

2 Likes