Expected object of device type cuda but got device type cpu...
2022/3/21 23:33:12
本文主要是介绍Expected object of device type cuda but got device type cpu...,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
Pytorch RuntimeError: Expected object of device type cuda but got device type cpu for argument #1 ‘self’ in call to _th_index_select
这个报错的原因是:模型的部分参数或数据不在GPU而在CPU上。
遇到这个问题需要仔细排查, 模型是否已经放在在GPU上, 通常使用
model = model.cuda() data = data.cuda()
把模型和数据分别放到GPU上。 这个一般不会出错, 除此之外, 需要排查在这些操作之后是否又对模型或数据进行了其他操作, 导致部分参数不在GPU上的情况。
这篇关于Expected object of device type cuda but got device type cpu...的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-06-26解决google chrome helper 内存占用较高!
- 2024-04-01got an unexpected keyword argument
- 2024-03-30维多利亚的秘密 golang入坑系统
- 2024-03-29mongodb sort by date
- 2024-03-29go swagger
- 2024-03-25mongodb cdc
- 2024-03-25how to use go in vscode
- 2024-03-22mongooseserverselectionerror: connect econnrefused ::1:27017
- 2024-03-21pymongo insert_many
- 2024-03-18projection mongodb