尝试为DeBERTa运行拥抱脸部的示例时:
from transformers import DebertaTokenizer, DebertaModel
import torch
tokenizer = DebertaTokenizer.from_pretrained('microsoft/deberta-base')
model = DebertaModel.from_pretrained('microsoft/deberta-base')
inputs = tokenizer("Hello, my dog is cute", return_tensors="pt")
outputs = model(**inputs)
last_hidden_states = outputs.last_hidden_state
在DeBERTa中,我们探讨了这个问题:
>>> outputs = model(**inputs)
/home/m/anaconda3/envs/cc35/lib/python3.7/site-packages/transformers/modeling_deberta.py:574: UserWarning: Output 0 of SplitBackward is a view and is being modified inplace. This view is an output of a function that returns multiple views. Inplace operators on such views are being deprecated and will be forbidden starting from version 1.8. Consider using `unsafe_` version of the function that produced this view or don't modify this view inplace. (Triggered internally at /pytorch/torch/csrc/autograd/variable.cpp:491.)
query_layer += self.transpose_for_scores(self.q_bias[None, None, :])
/home/m/anaconda3/envs/cc35/lib/python3.7/site-packages/transformers/modeling_deberta.py:575: UserWarning: Output 2 of SplitBackward is a view and is being modified inplace. This view is an output of a function that returns multiple views. Inplace operators on such views are being deprecated and will be forbidden starting from version 1.8. Consider using `unsafe_` version of the function that produced this view or don't modify this view inplace. (Triggered internally at /pytorch/torch/csrc/autograd/variable.cpp:491.)
value_layer += self.transpose_for_scores(self.v_bias[None, None, :])
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/m/anaconda3/envs/cc35/lib/python3.7/site-packages/torch/nn/modules/module.py", line 727, in _call_impl
result = self.forward(*input, **kwargs)
File "/home/m/anaconda3/envs/cc35/lib/python3.7/site-packages/transformers/modeling_deberta.py", line 896, in forward
return_dict=return_dict,
File "/home/m/anaconda3/envs/cc35/lib/python3.7/site-packages/torch/nn/modules/module.py", line 727, in _call_impl
result = self.forward(*input, **kwargs)
File "/home/m/anaconda3/envs/cc35/lib/python3.7/site-packages/transformers/modeling_deberta.py", line 407, in forward
rel_embeddings=rel_embeddings,
File "/home/m/anaconda3/envs/cc35/lib/python3.7/site-packages/torch/nn/modules/module.py", line 727, in _call_impl
result = self.forward(*input, **kwargs)
File "/home/m/anaconda3/envs/cc35/lib/python3.7/site-packages/transformers/modeling_deberta.py", line 330, in forward
rel_embeddings=rel_embeddings,
File "/home/m/anaconda3/envs/cc35/lib/python3.7/site-packages/torch/nn/modules/module.py", line 727, in _call_impl
result = self.forward(*input, **kwargs)
File "/home/m/anaconda3/envs/cc35/lib/python3.7/site-packages/transformers/modeling_deberta.py", line 263, in forward
rel_embeddings=rel_embeddings,
File "/home/m/anaconda3/envs/cc35/lib/python3.7/site-packages/torch/nn/modules/module.py", line 727, in _call_impl
result = self.forward(*input, **kwargs)
File "/home/m/anaconda3/envs/cc35/lib/python3.7/site-packages/transformers/modeling_deberta.py", line 575, in forward
value_layer += self.transpose_for_scores(self.v_bias[None, None, :])
RuntimeError: diff_view_meta->output_nr_ == 0 INTERNAL ASSERT FAILED at "/pytorch/torch/csrc/autograd/variable.cpp":363, please report a bug to PyTorch.
该环境具有python 3.7和anaconda:
torch 1.7.0
transformer 3.4.0
torchvision 0.8.1
我可以使用2个GPU来运行该示例,因为在搜索了建议后,建议使用一个GPU来运行它,这可能会解决问题,但我尝试使用一个GPU并使用以下命令:CUDA_VISIBLE_DEVICES=0 python sample_DeBERTa.py
,但仍然得到相同的错误
目前没有回答
相关问题 更多 >
编程相关推荐