原文:RuntimeError: Expected object of backend CUDA but got backend CPU for argument #4 'mat1'

原因:变量没有加cuda data data.cuda ...

2019-09-03 17:19 0 4232 推荐指数:

查看详情

【E-14-Pytorch】RuntimeError: Expected object of device type cuda but got device type cpu for argument #2 'mat1' in call to _th_addmm

一、出错误背景: Pytorch 中想使用 CUDA 对程序计算进行加速 二、问题分析 错误的意思:object 的 device 类型期望得到的是 cuda 类型,但是实际上的类型确实 cpu 类型,在调用二分类交叉熵损失进行前向计算的时候 三、检查下面几点: 模型是否放到 ...

Sat Oct 24 02:37:00 CST 2020 0 4751
 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM