关于GPU训练时出现的错误(请大佬帮忙解析一下,跪谢)

yimu8888 • 1291 次浏览 • 0 个回复 • 2020年11月26日

下面是运行时的错误 大概意思就是训练数据在cpu,网络权重在GPU,但是要求其二者都应该在GPU

training on  cuda
Traceback (most recent call last):
  File "D:/python1/VGG5_7/GOOGLENET5_9/GOOGLENET5_9.py", line 73, in 
    d2l.train_ch5(net,train_iter,test_iter,batch_size,optimizer,device,num_epochs)
  File "C:\Users\86156\Anaconda3\lib\site-packages\d2lzh_pytorch\utils.py", line 243, in train_ch5
    test_acc = evaluate_accuracy(test_iter, net)
  File "C:\Users\86156\Anaconda3\lib\site-packages\d2lzh_pytorch\utils.py", line 792, in evaluate_accuracy
    acc_sum += (net(X).argmax(dim=1)==y).float().sum().item()
  File "C:\Users\86156\Anaconda3\lib\site-packages\torch\nn\modules\module.py", line 722, in _call_impl
    result = self.forward(*input, **kwargs)
  File "C:\Users\86156\Anaconda3\lib\site-packages\torch\nn\modules\container.py", line 117, in forward
    input = module(input)
  File "C:\Users\86156\Anaconda3\lib\site-packages\torch\nn\modules\module.py", line 722, in _call_impl
    result = self.forward(*input, **kwargs)
  File "C:\Users\86156\Anaconda3\lib\site-packages\torch\nn\modules\container.py", line 117, in forward
    input = module(input)
  File "C:\Users\86156\Anaconda3\lib\site-packages\torch\nn\modules\module.py", line 722, in _call_impl
    result = self.forward(*input, **kwargs)
  File "C:\Users\86156\Anaconda3\lib\site-packages\torch\nn\modules\conv.py", line 419, in forward
    return self._conv_forward(input, self.weight)
  File "C:\Users\86156\Anaconda3\lib\site-packages\torch\nn\modules\conv.py", line 416, in _conv_forward
    self.padding, self.dilation, self.groups)
RuntimeError: Input type (torch.FloatTensor) and weight type (torch.cuda.FloatTensor) should be the same

原创文章,转载请注明 :关于GPU训练时出现的错误(请大佬帮忙解析一下,跪谢) - pytorch中文网
原文出处: https://ptorch.com/news/255.html
问题交流群 :168117787
提交评论
要回复文章请先登录注册
用户评论
  • 没有评论
Pytorch是什么?关于Pytorch! 如何列出所有pytorch能用的GPU?pytorch查看GPU列表