According to the source code pack_padded_sequence converts the lengths list to a Variable containing a LongTensor.
if isinstance(lengths, list):
    lengths = Variable(torch.LongTensor(lengths))

so you could just do that to your lengths list before using pack_padded_sequence.