question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Pytorch Vs Onnx: Pytorch is faster and provides different output

See original GitHub issue

Environment 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:

  1. Pytorch is faster than Onnx.
  2. Onnx produce different embedding output than Pytorch.

Could anyone help me to figure out the issue ?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
agemagiciancommented, Nov 19, 2020

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.

0reactions
github-actions[bot]commented, Mar 6, 2021

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found