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

跑测试集predict.py,无法在GPU上跑,大佬能否解答一下 #7

Open
258508 opened this issue Nov 3, 2023 · 1 comment
Open

Comments

@258508
Copy link

258508 commented Nov 3, 2023

Traceback (most recent call last):
File "predict.py", line 91, in
tplinker_predict(eval_config, test_data_path, model_state_path)
File "predict.py", line 81, in tplinker_predict
result = predict(data, data_maker, max_seq_len, batch_size, device, rel_extractor, True,
File "/root/tplinker-ch/utils/util.py", line 236, in predict
batch_tail_rel_shaking_outputs = rel_extractor(batch_input_ids,
File "/root/miniconda3/envs/pfn/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1051, in _call_impl
return forward_call(*input, **kwargs)
File "/root/tplinker-ch/models/tplinker.py", line 378, in forward
context_outputs = self.encoder(input_ids, attention_mask, token_type_ids)
File "/root/miniconda3/envs/pfn/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1051, in _call_impl
return forward_call(*input, **kwargs)
File "/root/miniconda3/envs/pfn/lib/python3.8/site-packages/transformers/models/bert/modeling_bert.py", line 964, in forward
embedding_output = self.embeddings(
File "/root/miniconda3/envs/pfn/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1051, in _call_impl
return forward_call(*input, **kwargs)
File "/root/miniconda3/envs/pfn/lib/python3.8/site-packages/transformers/models/bert/modeling_bert.py", line 201, in forward
inputs_embeds = self.word_embeddings(input_ids)
File "/root/miniconda3/envs/pfn/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1051, in _call_impl
return forward_call(*input, **kwargs)
File "/root/miniconda3/envs/pfn/lib/python3.8/site-packages/torch/nn/modules/sparse.py", line 158, in forward
return F.embedding(
File "/root/miniconda3/envs/pfn/lib/python3.8/site-packages/torch/nn/functional.py", line 2043, in embedding
return torch.embedding(weight, input, padding_idx, scale_grad_by_freq, sparse)
RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cpu and cuda:0! (when checking arugment for argument index in method wrapper_index_select)
(pfn) root@autodl-container-f8

@Mirage7320
Copy link

要检查一下是不是有数据没有统一 .to(device),这里的device如果用GPU是CUDA0

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

2 participants