Bro, Have you solve this problem? I meet this error when I use   torch.nn.parallel.DistributedDataParallel.
the problem is from sampler = DistributedSampler(dataset)  and
data.DataLoader(dataset,…, sampler=sampler)
Here is log.
Traceback (most recent call last):
File “train.py”, line 152, in 
sampler=sampler))
File “/home/xdjf/.conda/envs/py36torch041/lib/python3.6/site-packages/torch/utils/data/dataloader.py”, line 501, in iter
return _DataLoaderIter(self)
File “/home/xdjf/.conda/envs/py36torch041/lib/python3.6/site-packages/torch/utils/data/dataloader.py”, line 297, in init
self._put_indices()
File “/home/xdjf/.conda/envs/py36torch041/lib/python3.6/site-packages/torch/utils/data/dataloader.py”, line 345, in _put_indices
indices = next(self.sample_iter, None)
File “/home/xdjf/.conda/envs/py36torch041/lib/python3.6/site-packages/torch/utils/data/sampler.py”, line 138, in iter
for idx in self.sampler:
File “/home/xdjf/.conda/envs/py36torch041/lib/python3.6/site-packages/torch/utils/data/distributed.py”, line 42, in iter
indices = list(torch.randperm(len(self.dataset), generator=g))
RuntimeError: Expected a ‘N2at13CUDAGeneratorE’ but found ‘PN2at9GeneratorE’