After some trial and error, removing the line num_workers completely fixes the issue. Does anybody know what the significance of removing this line is? Looking online it seems to be related to memory, I have 16GB of RAM and python doesn’t consume very much when running the program. It seems to be similar to this issue https://github.com/pytorch/pytorch/issues/1355 68