原文:#报错记录#RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cpu!

有numpy和torch两种类型的数据 z mean.clone .detach eps torch.exp logstd 源代码这边报错了,修改如下 eps eps.cuda z mean.cuda eps torch.exp logstd .cuda 就是把和numpy有关的,比如reshape什么的后面加上cuda ...

2021-11-08 09:49 0 1927 推荐指数:

查看详情

【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