RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cpu!

错误原因:数据有的在cpu上有的在gpu上
debug:断点到出错位置查看类型,或者打印`x.is_cuda`查看
修改:将cpu上的数据通过`.to(device)`加载到gpu上
posted @ 2023-02-09 16:18  不要肥宅  阅读(1967)  评论(0编辑  收藏  举报