Did you try with a num_workers=0. By doing that I think you will eliminate the need of synchronizing the code so it might be faster. For me it was the problem, but I had to do a lot of guess before finding the solution. It might not be your solution but maybe it will work! (num_workers is a parameter of your dataloader) (I have only been working with PyTorch for 6 months so I might do an error!)