Hi,
I ran the tools/train.py using python 3.7 and torch 1.7, and the program throws the following exception:
......
File "/home/self-critical.pytorch-master/captioning/models/AttModel.py", line 34, in sort_pack_padded_sequence
tmp = pack_padded_sequence(input[indices], sorted_lengths, batch_first=True)
File "/home/library/miniconda3/envs/py3.7/lib/python3.7/site-packages/torch/nn/utils/rnn.py", line 244, in pack_padded_sequence
_VF._pack_padded_sequence(input, lengths, batch_first)
RuntimeError: 'lengths' argument should be a 1D CPU int64 tensor, but got 1D cuda:0 Long tensor
I searched about this exception and found that it is related to this issue: https://github.com/pytorch/pytorch/issues/43227
It seems that PyTorch 1.7 requires the lengths to be a CPU tensor when calling pack_padded_sequence, and I think that is controversial, too.
Though this is caused by the new version of PyTorch (this weird behavior is not even documented), would you consider adding some workaround to improve the compatibility of the code?
Hi, I ran the
tools/train.py
using python 3.7 and torch 1.7, and the program throws the following exception:I searched about this exception and found that it is related to this issue: https://github.com/pytorch/pytorch/issues/43227 It seems that PyTorch 1.7 requires the
lengths
to be a CPU tensor when callingpack_padded_sequence
, and I think that is controversial, too.Though this is caused by the new version of PyTorch (this weird behavior is not even documented), would you consider adding some workaround to improve the compatibility of the code?