@smth  Thanks for your suggestions. I am upgrading PyTorch to the latest version and will try the code once again. But just for clarification, I am not using multiprocessing. I using multi-threading. I have 4 threads(updated the pseudocode I posted to reflect this) that loads the next batches while the network is processing the current batch. I am doing this to avoid the time the network has to wait while the data is being loaded. And as I said, I am using  queue.Queue which is thread-safe to synchronize between loading threads and the main thread(the network thread).