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

继续说,多说也没用!

[En]

Introduction: keep talking, it is useless to talk more!

1.错误:

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

reason:(小琼说一下自己的错误)出现在此错误的原因在于将网络使用GPU训练,但是只是 部分训练用GPU一部分使用CPU,所以会出现这种情况。

solve:将网络修改为使用GPU训练,同时 所有相关的都修为使用GPG 训练

代码:

model=model.to(device)

说完了。

2.结束

GAME OVER

如果您理解错误,欢迎您及时批评和改正小琼的错误。谢谢您的更正!

[En]

If you understand the mistake, you are welcome to criticize and correct Xiaoqiong’s mistake in time. Thank you for your correction!

如果您有任何问题,欢迎您在评论区留言!

[En]

If you have any questions, you are welcome to leave a message in the comment area!

如果感觉不错的话!点个赞呗,不用客气!(O(∩_∩)O哈哈~)

欢迎与梦想伙伴一起学习,一起努力,加油!

[En]

Welcome to study with your partner Dream, work hard together, come on!

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

图片来自网络(如有侵权行为,请联系我)

[En]

The picture is from the Internet (if there is any infringement, please contact me)

see you next time!!!

Original: https://blog.csdn.net/m0_56654441/article/details/120895807
Author: 桀骜不驯的山里男人
Title: Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cpu!

原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/496476/

转载文章受原作者版权保护。转载请注明原作者出处!

(0)

大家都在看

亲爱的 Coder【最近整理,可免费获取】👉 最新必读书单  | 👏 面试题下载  | 🌎 免费的AI知识星球