Pytorch Vs Onnx: Pytorch is faster and provides different output
See original GitHub issueEnvironment info
transformers
version: 3.5.0- Platform: Linux-4.19.112±x86_64-with-Ubuntu-18.04-bionic
- Python version: 3.6.9
- PyTorch version (GPU?): 1.7.0+cu101 (True)
- Tensorflow version (GPU?): 2.3.0 (True)
- Using GPU in script?: Yes
- Using distributed or parallel set-up in script?: No
Who can help
albert, bert, GPT2, XLM: @LysandreJik Onnx: @mfuntowicz
Information
Model I am using (Bert, XLNet …):
The problem arises when using:
- the official example scripts: (give details below)
- my own modified scripts: (give details below)
The tasks I am working on is:
- an official GLUE/SQUaD task: (give the name)
- my own task or dataset: (give details below)
To reproduce
Steps to reproduce the behavior:
https://colab.research.google.com/drive/1UwgWgUF4k_GPJ5TcziHo4eH_rRFQeNVL?usp=sharing
Expected behavior
I have followed the the onnx export tutorial: https://github.com/huggingface/transformers/blob/master/notebooks/04-onnx-export.ipynb However, I have found 2 issues:
- Pytorch is faster than Onnx.
- Onnx produce different embedding output than Pytorch.
Could anyone help me to figure out the issue ?
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:7 (3 by maintainers)
Top Results From Across the Web
Scaling-up PyTorch inference: Serving billions of daily NLP ...
The ONNX Runtime model was slightly faster, but not significant. Throughput comparison for different batch sizes on a Tesla T4. The results in ......
Read more >Inference speed of PyTorch vs exported ONNX model ... - Reddit
I'm curious if anyone has any comprehensive statistics about the speed of predictions of converting a PyTorch model to ONNX versus just ...
Read more >Inference result is different between Pytorch and ONNX model
Hi,. I converted Pytorch model to ONNX model. However, output is different between two models like below. inference_result. inference environment. Pytorch.
Read more >An empirical approach to speedup your BERT inference with ...
First we'll take a quick look at how to export a Pytorch model to the ... Using Torchscript or ONNX does provide significant...
Read more >Operationalizing PyTorch Models Using ONNX and ... - NVIDIA
Train models with various frameworks or services ... PyTorch has native support for ONNX export ... ONNX W[iofc] (input, output, forget, cell) vs....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I have figured out the problem, but I don’t have the solution. When you use a single sample per batch it works correctly, but when you use more than one sample per batch, the results are totally different.
This issue has been automatically marked as stale and been closed because it has not had recent activity. Thank you for your contributions.
If you think this still needs to be addressed please comment on this thread.