RuntimeError: Caught RuntimeError in replica 0 on device 0.

报错:

File "/opt/conda/lib/python3.7/site-packages/torch/nn/modules/module.py", line 722, in _call_impl
    result = self.forward(*input, **kwargs)
  File "/opt/conda/lib/python3.7/site-packages/torch/nn/modules/batchnorm.py", line 136, in forward
    self.weight, self.bias, bn_training, exponential_average_factor, self.eps)
  File "/opt/conda/lib/python3.7/site-packages/torch/nn/functional.py", line 2016, in batch_norm
    training, momentum, eps, torch.backends.cudnn.enabled
RuntimeError: Expected tensor for argument #1 'input' to have the same device as tensor for argument #2 'weight'; but device 1 does not equal 0 (while checking arguments for cudnn_batch_norm)

RuntimeError: Caught RuntimeError in replica 0 on device 0.

有两种解决方案,我没有探这个问题咋解决,我的问题是一个简单的验证问题,用了三张卡训练报的错如上,我是改成一张卡就问题ok了, 有小伙伴多卡解决这个问题的可以留个言,感谢!!!!

你可能感兴趣的:(日常bug系列,pytorch,深度学习,人工智能)