我的pytorch报错解决记录
每次报错都百度解决,现记录一下我的报错问题,防止遗忘。
仅限于个人解决方案,不一定能解决你的报错问题。望周知
1error: the following arguments are required: model.devices
这是由于在最开始的写命令行参数(model.devices)时格式不规范,注意格式
2.RuntimeError: Expected object of type torch.LongTensor but found type torch.FloatTensor for argument #3 ‘index’
这是我把 pytorch0.3代码迁移到0.4时产生的错误,调用forward函数时出错。如错误所述,正向函数“torch.cuda.longensor类型的预期对象”,输入批仍在CPU中,需要传输到cuda设备。
https://discuss.pytorch.org/t/runtimeerror-expected-object-of-type-torch-longtensor-but-found-type-torch-cuda-longtensor-for-argument-3-index/22577
https://stackoverflow.com/questions/58690338/how-to-fix-pytorch-runtimeerror-expected-object-of-type-torch-cuda-longtensor#