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 while using onnx runtime #106

Open
Bagherihaali opened this issue Oct 19, 2022 · 0 comments
Open

error while using onnx runtime #106

Bagherihaali opened this issue Oct 19, 2022 · 0 comments

Comments

@Bagherihaali
Copy link

Hi,
i want t use onnx-runtime to speed-up question generation as you suggested here
but i got some errors.

i am on ubuntu 20
installed packages from requirement files
because of onnx dependency errors replaced protobuf with protobuf==3.20.1

my code :


from pipelines import pipeline
nlp = pipeline("question-generation",onnx=True, onnx_path='./onnx')

stack trace :

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In [3], line 1
----> 1 nlp = pipeline("question-generation",onnx=True, onnx_path='./onnx')

File ~/Desktop/virtproj/suraj-onnx-support/pipelines.py:376, in pipeline(task, model, tokenizer, qg_format, ans_model, ans_tokenizer, use_cuda, onnx, onnx_path, **kwargs)
    374     return task_class(model=model, tokenizer=tokenizer, **extra_pipeline_args)
    375 elif task == "question-generation":
--> 376     return task_class(
    377         model=model,
    378         tokenizer=tokenizer,
    379         ans_model=ans_model,
    380         ans_tokenizer=ans_tokenizer,
    381         qg_format=qg_format,
    382         **extra_pipeline_args,
    383     )
    384 else:
    385     return task_class(
    386         model=model,
    387         tokenizer=tokenizer,
   (...)
    391         **extra_pipeline_args,
    392     )

File ~/Desktop/virtproj/suraj-onnx-support/pipelines.py:38, in QGPipeline.__init__(self, model, tokenizer, ans_model, ans_tokenizer, qg_format, use_cuda, onnx, onnx_path)
     35 self.device = "cuda" if torch.cuda.is_available() and use_cuda else "cpu"
     37 if self.onnx:
---> 38     self.model = OnnxT5(model, onnx_path)
     39     self.ans_model = self.model if model == ans_model else OnnxT5(ans_model, onnx_path)
     40 else:

File ~/Desktop/virtproj/suraj-onnx-support/onnx_t5.py:188, in OnnxT5.__init__(self, model_name_or_path, onnx_path)
    185 decoder = T5ForConditionalGeneration.from_pretrained(model_name_or_path).decoder
    186 self.decoder = T5Decoder(decoder, self.config).eval()
--> 188 self._warmup_onnx_graph()

File ~/Desktop/virtproj/suraj-onnx-support/onnx_t5.py:277, in OnnxT5._warmup_onnx_graph(self)
    272 for _ in range(10):
    273     encoder_outputs = self._encoder_forward(
    274         input_ids=input_ids, attention_mask=attention_mask
    275     ).last_hidden_state
--> 277 decoder_output, _ = self.decoder(input_ids, encoder_outputs, attention_mask)
    278 inputs = {"decoder_output": decoder_output.cpu().detach().numpy()}
    279 for _ in range(10):

File ~/Desktop/virtproj/suraj-onnx-support/surajonnx-venv/lib/python3.8/site-packages/torch/nn/modules/module.py:722, in Module._call_impl(self, *input, **kwargs)
    720     result = self._slow_forward(*input, **kwargs)
    721 else:
--> 722     result = self.forward(*input, **kwargs)
    723 for hook in itertools.chain(
    724         _global_forward_hooks.values(),
    725         self._forward_hooks.values()):
    726     hook_result = hook(self, input, result)

File ~/Desktop/virtproj/suraj-onnx-support/onnx_t5.py:146, in T5Decoder.forward(self, input_ids, encoder_hidden_states, attention_mask, past_key_values)
    140 past_arg_key = (
    141     "past_key_value_states"
    142     if "past_key_value_states" in inspect.getargspec(self.decoder.forward)[0]
    143     else past_key_values
    144 )
    145 past_arg = {past_arg_key: past_key_values}
--> 146 decoder_output = self.decoder(
    147     input_ids=input_ids,
    148     encoder_attention_mask=attention_mask,
    149     encoder_hidden_states=encoder_hidden_states,
    150     use_cache=True,
    151     return_dict=True,
    152     **past_arg,
    153 )
    154 past_key_values = decoder_output.past_key_values
    155 sequence_output = decoder_output.last_hidden_state

TypeError: _call_impl() keywords must be strings

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

1 participant