Thanks the for information!
If you are preloading all samples into the RAM, you might also try to simply index the tensors in your loop and push each chunk to the GPU. I assume you don’t apply any transformation etc. in your Dataset.
If that’s the case, the “manual” indexing might be a bit faster, as the DataLoader might add some overhead to load each sample.
Could you try that and check the performance?
Also, you could try to call pin_memory() on the data tensors and use .to("cuda", non_blocking=True).