Solved by pritamdamania87 in post #5 
              
              
                I don’t think you need a custom dataloader and using a multiprocessing queue in the dataset should suffice: 
# Initialize a queue.
import multiprocessing as mp
q = mp.Queue()


# Pass the queue to the dataset
class MyDataset(Dataset):
    def __init__(self, q):
        self.data = np.random.randint(…