I think the issue with the freezing is possibly related to:

  
      github.com/pytorch/pytorch
  
  
    



Issue: possible deadlock in dataloader 65


	
	opened by zym1010
	on 2017-04-25
	
	
	


the bug is described at pytorch/examples#148. I just wonder if this is a bug in PyTorch itself, as the example code...




  
  
    
    
  
  


I’m using numpy and linecache, and it is possible that one of the library is causing the dataloader to freeze.
Since the output of the DataLoader is now a FloatTensor instead of cuda.FloatTensor, I wrote a script using to convert the output from CPU’s dataloader output to GPU RNN nn.module:
def convert_pack_to_cuda(pack, label):
    if torch.cuda.is_available():
        unpack, lengths = torch.nn.utils.rnn.pad_packed_sequence(pack, batch_first=True)
        unpack = unpack.type(dtype)
        pack = torch.nn.utils.rnn.pack_padded_sequence(unpack, lengths, batch_first=True)
        label = label.type(dtype)
    return pack, label

And it seems to work in harmony.