How to prefetch data when processing with GPU?

Pytorch provides the dataloader for some common vision datasets.

You could also follow what’s in https://github.com/pytorch/pytorch/tree/master/torch/utils/data, and build you own.