转载:https://blog.csdn.net/lingyunxianhe/article/details/119454778?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522168718901716800227455818%2522%252C%2522scm%2522%253A%252220140713.130102334.pc%255Fblog.%2522%257D&request_id=168718901716800227455818&biz_id=0&utm_medium=distribute.pc_search_result.none-task-blog-2~blog~first_rank_ecpm_v1~rank_v31_ecpm-1-119454778-null-null.268^v1^koosearch&utm_term=TypeError&spm=1018.2226.3001.4450
使用多GPU训练时总是报错:
TypeError: Caught TypeError in replica 1 on device 1.
TypeError: forward() missing 1 required positional argument: 'x'
百度了一下发现是因为我使用了多个显卡,导致在inference阶段,模型和数据不在同一个显卡上,所以后面同时报了:
TypeError: forward() missing 1 required positional argument: 'x'
详情参考这篇文章:https://www.cnblogs.com/YouXiangLiThon/p/13361448.html
但百度上面没有查询到解决办法,于是去github上试试有没有相同的问题。结果发现真的有人出现了同样问题,大佬的回答是因为自己的数据集数量不是 batch-size 的整数倍,因此会报错。
标签:TypeError,missing,2522%,required,argument,positional,forward From: https://www.cnblogs.com/chamie/p/17492696.html