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

Getting runtime error. #1

Closed
abhinavsp0730 opened this issue Mar 18, 2021 · 4 comments
Closed

Getting runtime error. #1

abhinavsp0730 opened this issue Mar 18, 2021 · 4 comments
Labels
good first issue Good for newcomers

Comments

@abhinavsp0730
Copy link

abhinavsp0730 commented Mar 18, 2021

Hi, @Ki6an it's great work. But while executing below code

from fastT5 import export_and_get_onnx_model
from transformers import AutoTokenizer

model_name = 't5-small'
model = export_and_get_onnx_model(model_name)

tokenizer = AutoTokenizer.from_pretrained(model_name)
t_input = "translate English to French: The universe is a dark forest."
token = tokenizer(t_input, return_tensors='pt')

tokens = model.generate(input_ids=token['input_ids'],
               attention_mask=token['attention_mask'],
               num_beams=2)

output = tokenizer.decode(tokens.squeeze(), skip_special_tokens=True)
print(output)

I'm getting this error.

RuntimeError: output with shape [5, 12, 1, 2] doesn't match the broadcast shape [5, 12, 2, 2]


@Ki6an
Copy link
Owner

Ki6an commented Mar 18, 2021

@abhinavsp0730 thanks, that's a known issue in transformers library while exporting t5 to onnx. the issue can be fixed by following the guide in this notebook.

or you can make the following changes in the modeling_t5.py file of your local transformers library and save it:

image

it's just a two-line simple fix.
I've already created PR for this issue here

@abhinavsp0730
Copy link
Author

@Ki6an thanks for the help. Is this method is supported for GPU or CPU?

@abhinavsp0730
Copy link
Author

@Ki6an thanks for the help. Is this method is supported for GPU or CPU?

I'm guessing it's not using onnxruntime-gpu package.So is fastT5 compatable with Gpu if we install
onnxruntime-gpu in place of onnxruntime?

@Ki6an
Copy link
Owner

Ki6an commented Mar 19, 2021

@abhinavsp0730 currently fastT5 doesn't support GPU, will be working on this in the future.
onnxruntime-gpu doesn't support quantization & for the onnx model to perform better than the PyTorch models on GPU need to implement IObinding.

@Ki6an Ki6an added the good first issue Good for newcomers label Mar 20, 2021
@Ki6an Ki6an closed this as completed Mar 20, 2021
@Ki6an Ki6an pinned this issue Mar 26, 2021
@tobigue tobigue mentioned this issue Mar 29, 2021
@Ki6an Ki6an unpinned this issue May 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants