当前位置:网站首页>Pytorch——报错解决:RuntimeError: Expected all tensors to be on the same device, but found at least two
Pytorch——报错解决:RuntimeError: Expected all tensors to be on the same device, but found at least two
2022-07-16 02:51:00 【William.csj】
Pytorch——报错解决:RuntimeError: Expected all tensors to be on the same device, but found at least two devices
一、报错信息
RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cpu! (when checking argument for argument weight in method wrapper_nll_loss_forward)
二、报错原因
tensors 一会在CPU运算,一会在GPU运算。
三、解决方法
都改成在GPU运算。
四、原代码


五、现代码

参考博客
边栏推荐
猜你喜欢

可爱的图像分类——Conv网络终于出了一口气:打爆了Swin的ConvNeXt

开源数据集——花分类数据集

Word——设置Tab键宽度

Unity screenshot function and let the UI display

Summary of common JVM interview questions

Classic examples of C language: 11-20 examples: finding the maximum and minimum values of two-dimensional arrays, finding prime numbers in arrays, compiling perpetual calendars, sorting array elements

Harbor: modify the default 172 network segment

3分钟弄懂web自动化的三种等待方式

如何免費系統化入門數據科學?

How to systematically and efficiently learn the entry-level software testing and find the work of software testing?
随机推荐
Grid layout
Analysis of container health inspection
Linux -- connecting to MySQL database and basic operations
2022.07.12 group a summary
Maximum return alternative method
MySQL Basic - add and Advanced Query
How does an enterprise choose the right time series database?
Network security -- Kali uses mdk3 to attack WiFi (detailed tutorial)
沉睡者的简历-有老板需要招兵买马吗?您的成功就差一个我
Ubuntu 离线安装Mysql
DINO&PAWS
取消默认样式
本周投融报:多风投机构完成募资 Web3.0赛道继续吸金
Hyperspace travel solution
自动追番工具BGmi
ORA-00322&ORA-00312
[flag]小程序-day2
[slow live broadcast in the post epidemic era: a good time under the lens]
Kotlin compose bottom bar
编程老司机带你玩转 CompletableFuture 异步编程