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)

版权声明:本文为CSDN博主「爱猫的吴小圆」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/qq_48345413/article/details/121645015

我还没有学会写个人说明!

暂无评论

发表评论

相关推荐

酒瓶检测流程

数据清洗https://tianchi.aliyun.com/forum/postDetail?spm5176.12586969.1002.21.125b13e2xpCMec&postId87373 处理后图片为3370张 训练集和验证集划

Win10+vs2017下配置libtorch

我的配置如下: 系统:win10-64位 VS:vs2017 Libtorch:cu102-1.6 安装步骤如下: 一、确定可选版本 C下实现torch,主要用于网络的预测&#xff