So it seems that this runtime error occurs with pack_padded_sequence when the length argument is a Variable. I used the .data.numpy() of the variable and it worked without this error. This is confusing since the documentation says the lengths should be a variable. http://pytorch.org/docs/master/nn.html#torch.nn.utils.rnn.pack_padded_sequence 145