Input and parameter tensors are not at the same device

Input and parameter tensors are not at the same device

文章目录

  • Input and parameter tensors are not at the same device


出现这个问题的原因是没有把模型和数据都放到cuda里面

  device = torch.device('cuda:0' if torch.cuda.is_available() else 'cpu')
  model.to(device=device)
  # 一个batch的数据转换为RNN的输入维度
  images = images.to(device)
   labels = labels.to(device)

你可能感兴趣的:(计算机视觉与深度学习,c++,python,开发语言)