ysdu@-Z9PE-D8-WS-Invalid-entry-length-16-Fixed-up-to-11:~/pytorchTrain/ssd.pytorch$ python train.py
/home/pytorchTrain/ssd.pytorch/ssd.py:34: UserWarning: volatile was removed and now has no effect. Use with torch.no_grad(): instead.
self.priors = Variable(self.priorbox.forward(), volatile=True)
/home/pytorchTrain/ssd.pytorch/layers/modules/l2norm.py:17: UserWarning: nn.init.constant is now deprecated in favor of nn.init.constant_.
init.constant(self.weight,self.gamma)
Loading base network...
Initializing weights...
train.py:214: UserWarning: nn.init.xavier_uniform is now deprecated in favor of nn.init.xavier_uniform_.
init.xavier_uniform(param)
Loading the dataset...
Training SSD on: VOC0712
Using the specified args:
Namespace(basenet='vgg16_reducedfc.pth', batch_size=32, cuda=True, dataset='VOC', dataset_root='/home/data/VOCdevkit/', gamma=0.1, lr=0.001, momentum=0.9, num_workers=4, resume=None, save_folder='weights/', start_iter=0, visdom=False, weight_decay=0.0005)
Traceback (most recent call last):
File "train.py", line 255, in
train()
File "train.py", line 150, in train
batch_iterator = iter(data_loader)
File "/home/anaconda3/lib/python3.6/site-packages/torch/utils/data/dataloader.py", line 451, in __iter__
return _DataLoaderIter(self)
File "/home/ysdu/anaconda3/lib/python3.6/site-packages/torch/utils/data/dataloader.py", line 247, in __init__
self._put_indices()
File "/home/anaconda3/lib/python3.6/site-packages/torch/utils/data/dataloader.py", line 295, in _put_indices
indices = next(self.sample_iter, None)
File "/home/anaconda3/lib/python3.6/site-packages/torch/utils/data/sampler.py", line 138, in __iter__
for idx in self.sampler:
File "/home/anaconda3/lib/python3.6/site-packages/torch/utils/data/sampler.py", line 51, in __iter__
return iter(torch.randperm(len(self.data_source)).tolist())
RuntimeError: randperm is only implemented for CPU
I solved it like this:
def __iter__(self):
add : cpu = torch.device('cpu')
modifiy: return iter(torch.randperm(len(self.data_source), device=cpu).tolist())
@chinadu where did you put that function?
@bareblackfoot
“python3.6/site-packages/torch/utils/data/sampler.py", line 51
i have same issue here, is it something wrong with pytorch its self?
refer to this: https://github.com/pytorch/pytorch/issues/6874
l think you use the torch with version 0.4.0 or higher!
You can change your torch version to 0.3.0 , l solved the same problem in this way!
@tanxjtu thank you. downgrading to 0.3.0 worked.
good job, thanks...(0.4 torch )
I have this problem in Pytorch 0.4.0 (by using torch.utils.data.DataLoader with shuffle=True). However, I do not have this problem with Pytorch 0.4.1.
Most helpful comment
I solved it like this:
def __iter__(self):
add : cpu = torch.device('cpu')
modifiy: return iter(torch.randperm(len(self.data_source), device=cpu).tolist())