What do you mean by “get all data” if you are constrained by memory? The purpose of the dataloader is to supply mini-batches of data so that you don’t have to load the entire dataset into memory (which many times is infeasible if you are dealing with large image datasets, for example). If you are dealing with a small-enough dataset, then you can do what you did above, but otherwise you’ll have to settle for mini-batches. Unless you are talking about some other representation of the data- for example if your loading images via a image folder dataset, then your dataset will be composed of image paths, which can be accessed by dataset.imgs and that IS kept entirely in memory. But it’s the dataloader that actually brings specific items from that image-path list into memory.