yunjey / pytorch-tutorial

PyTorch Tutorial for Deep Learning Researchers

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Hi,I has this problem in style transfer!

BCWang93 opened this issue · comments

commented

I have this error in run the code of style transfer:
'
Traceback (most recent call last):
File "main.py", line 86, in
main(opt)
File "main.py", line 81, in main
img=denorm(img.to(device)).clamp_(0,1)
File "/home/a/anaconda3/envs/bcw_env/lib/python3.6/site-packages/torchvision/transforms/transforms.py", line 163, in call
return F.normalize(tensor, self.mean, self.std, self.inplace)
File "/home/a/anaconda3/envs/bcw_env/lib/python3.6/site-packages/torchvision/transforms/functional.py", line 208, in normalize
tensor.sub_(mean[:, None, None]).div_(std[:, None, None])
RuntimeError: expected type torch.cuda.FloatTensor but got torch.FloatTensor

'
anyone can help me solve this?Thanks!

@BCWang93 How about change device

device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')

to just

device = torch.device('cpu')

Is there someone who knows how to edit code to use "cuda" to train the model instead of 'cpu'?
Thanks a lot!