Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when testing BertAbs model #234

Open
tetsu9923 opened this issue May 25, 2022 · 2 comments
Open

Error when testing BertAbs model #234

tetsu9923 opened this issue May 25, 2022 · 2 comments

Comments

@tetsu9923
Copy link

Hi, thank you for your great work!

I encountered the following error in predictor.py` when trying to test BertAbs model.

python train.py -task abs -mode test -test_from ../models/abs/model_step_8000.pt -batch_size 3000 -test_batch_size 500 -bert_data_path ../bert_data/bert.pt_data -log_file ../logs/test_abs -model_path ../models/abs -sep_optim true -use_interval true -visible_gpus 0 -max_pos 512 -max_length 200 -alpha 0.95 -min_length 50 -result_path ../logs/abs

Traceback (most recent call last):
File "train.py", line 135, in
test_abs(args, device_id, cp, step)
File "/home/t-kasanishi/PreSumm/src/train_abstractive.py", line 225, in test_abs
predictor.translate(test_iter, step)
File "/home/t-kasanishi/PreSumm/src/models/predictor.py", line 149, in translate
batch_data = self.translate_batch(batch)
File "/home/t-kasanishi/PreSumm/src/models/predictor.py", line 218, in translate_batch
min_length=self.min_length)
File "/home/t-kasanishi/PreSumm/src/models/predictor.py", line 333, in _fast_translate_batch
[alive_seq.index_select(0, select_indices),
RuntimeError: "index_select_out_cuda_impl" not implemented for 'Float'

Below is a shape and contents of select_indices and alive_seq.
FloatTensor cannot be used for the argument of .index_select() (only IntTensor or LongTensor is suitable).
How should I fix it?
Thank you!

select_indices.shape: torch.Size([30])
select_indices: tensor([ 0.0654, 0.0655, 0.0657, 0.0340, 0.0674, 5.0654, 5.0655, 5.0657,
5.0340, 5.0674, 10.0654, 10.0657, 10.0655, 10.0340, 10.0657, 15.0654,
15.0655, 15.0657, 15.0340, 15.0674, 20.0654, 20.0655, 20.0657, 20.0340,
20.0657, 25.0654, 25.0655, 25.0657, 25.0340, 25.0674], device='cuda:0')
alive_seq.shape: torch.Size([30, 1])
alive_seq: tensor([[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1]], device='cuda:0')

@wbchief
Copy link

wbchief commented Jun 5, 2022

Hi, thank you for your great work!

I encountered the following error in predictor.py` when trying to test BertAbs model.

python train.py -task abs -mode test -test_from ../models/abs/model_step_8000.pt -batch_size 3000 -test_batch_size 500 -bert_data_path ../bert_data/bert.pt_data -log_file ../logs/test_abs -model_path ../models/abs -sep_optim true -use_interval true -visible_gpus 0 -max_pos 512 -max_length 200 -alpha 0.95 -min_length 50 -result_path ../logs/abs

Traceback (most recent call last):
File "train.py", line 135, in
test_abs(args, device_id, cp, step)
File "/home/t-kasanishi/PreSumm/src/train_abstractive.py", line 225, in test_abs
predictor.translate(test_iter, step)
File "/home/t-kasanishi/PreSumm/src/models/predictor.py", line 149, in translate
batch_data = self.translate_batch(batch)
File "/home/t-kasanishi/PreSumm/src/models/predictor.py", line 218, in translate_batch
min_length=self.min_length)
File "/home/t-kasanishi/PreSumm/src/models/predictor.py", line 333, in _fast_translate_batch
[alive_seq.index_select(0, select_indices),
RuntimeError: "index_select_out_cuda_impl" not implemented for 'Float'

Below is a shape and contents of select_indices and alive_seq. FloatTensor cannot be used for the argument of .index_select() (only IntTensor or LongTensor is suitable). How should I fix it? Thank you!

select_indices.shape: torch.Size([30])
select_indices: tensor([ 0.0654, 0.0655, 0.0657, 0.0340, 0.0674, 5.0654, 5.0655, 5.0657,
5.0340, 5.0674, 10.0654, 10.0657, 10.0655, 10.0340, 10.0657, 15.0654,
15.0655, 15.0657, 15.0340, 15.0674, 20.0654, 20.0655, 20.0657, 20.0340,
20.0657, 25.0654, 25.0655, 25.0657, 25.0340, 25.0674], device='cuda:0')
alive_seq.shape: torch.Size([30, 1])
alive_seq: tensor([[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1]], device='cuda:0')

topk_beam_index = topk_ids.div(vocab_size)

        topk_beam_index = topk_ids // vocab_size

@Dengguty
Copy link

请问解决了吗?我也遇到了这个问题

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants