Dataloader works fine with Python 2.7, crashes with Python 3.5

I am having a cryptic issue upon loading data from a custom Dataset with the Dataloader when switching from python 2.7 to 3.5. See below the incriminated piece of code, where train_set and test_set are custom Dataset objects that I use to train/eval a parallelized model in a multi-gpu environment:

train_loader = DataLoader(train_set,batch_size=batch_size, shuffle = True,num_workers=8*self.GPU) 
test_loader = DataLoader(test_set, batch_size=batch_size, shuffle=True,num_workers=8*self.GPU) 

for n in list(range(nb_epoch + 1)):

 def train(self,epoch,train_loader,test_loader):

        print ("**** Epoch ",epoch,"********")

        for i, batch in enumerate(train_loader):

            batch_maps = batch['map']
            batch_labels = batch['label']

Here is the error I get:

    for i, batch in enumerate(train_loader):
  File "/home/julien/.local/lib/python3.5/site-packages/torch/utils/data/", line 281, in __next__
    return self._process_next_batch(batch)
  File "/home/julien/.local/lib/python3.5/site-packages/torch/utils/data/", line 301, in _process_next_batch
    raise batch.exc_type(batch.exc_msg)
TypeError: function takes exactly 5 arguments (1 given)

When I run the same exact code with python 2.7, everything works fine. Any clue?

Run with num_workers=0 to get better trace.


That worked! I could find where the error was coming from. Thanks!

which error?pls tell us?

what?.. I don’t understand what you are talking about.