ys7yoo / claf

CLaF: Open-Source Clova Language Framework
https://naver.github.io/claf/
MIT License
0 stars 0 forks source link

RuntimeError: 'lengths' argument should be a 1D CPU int64 tensor, but got 1D cuda:0 Long tensor #5

Closed ys7yoo closed 3 years ago

ys7yoo commented 3 years ago
2021-04-23 23:13:16,422 (initializer.py:28): [INFO] - Initializing Linear Layer
2021-04-23 23:13:16,422 (initializer.py:28): [INFO] - Initializing Linear Layer
2021-04-23 23:13:16,431 (initializer.py:28): [INFO] - Initializing Linear Layer
2021-04-23 23:13:16,432 (initializer.py:28): [INFO] - Initializing Linear Layer
2021-04-23 23:13:16,433 (initializer.py:28): [INFO] - Initializing Linear Layer
2021-04-23 23:13:16,436 (initializer.py:32): [INFO] - Initializing GRU Layer
2021-04-23 23:13:16,437 (initializer.py:32): [INFO] - Initializing GRU Layer
2021-04-23 23:13:16,437 (initializer.py:32): [INFO] - Initializing GRU Layer
2021-04-23 23:13:16,438 (initializer.py:28): [INFO] - Initializing Linear Layer
2021-04-23 23:13:16,438 (initializer.py:32): [INFO] - Initializing GRU Layer
2021-04-23 23:13:16,438 (initializer.py:28): [INFO] - Initializing Linear Layer
2021-04-23 23:13:16,439 (initializer.py:32): [INFO] - Initializing GRU Layer
2021-04-23 23:13:16,439 (initializer.py:28): [INFO] - Initializing Linear Layer
2021-04-23 23:13:18,911 (experiment.py:327): [INFO] - use_gpu: True num_gpu: 1, distributed training: False, 16-bits training: False
2021-04-23 23:13:18,939 (trainer.py:356): [INFO] - # Train Mode.
Traceback (most recent call last):
  File "/home/yyoo/src_remote/claf/train.py", line 10, in <module>
    experiment()
  File "/home/yyoo/src_remote/claf/claf/learn/experiment.py", line 142, in __call__
    self.trainer.train_and_evaluate(train_loader, valid_loader, optimizer)
  File "/home/yyoo/src_remote/claf/claf/learn/trainer.py", line 137, in train_and_evaluate
    eval_and_save_step_count=self.eval_and_save_step_count,
  File "/home/yyoo/src_remote/claf/claf/learn/trainer.py", line 376, in _run_epoch
    output_dict = self.model(**inputs)
  File "/home/yyoo/torch/lib/python3.6/site-packages/torch/nn/modules/module.py", line 889, in _call_impl
    result = self.forward(*input, **kwargs)
  File "/home/yyoo/src_remote/claf/claf/model/reading_comprehension/docqa.py", line 187, in forward
    self.context_preprocess_rnn, context_embed, context_seq_config
  File "/home/yyoo/src_remote/claf/claf/modules/functional.py", line 112, in forward_rnn_with_pack
    packed_input = pack_padded_sequence(sorted_tensor, seq_config["seq_lengths"], batch_first=True)
  File "/home/yyoo/torch/lib/python3.6/site-packages/torch/nn/utils/rnn.py", line 245, 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
ys7yoo commented 3 years ago

https://github.com/pytorch/pytorch/issues/43227

ys7yoo commented 3 years ago

https://github.com/pytorch/pytorch/issues/43227#issuecomment-731338612 This does the trick!