microsoft / microsoft/onnxruntime

[Performance] onnxruntime 3 times slower than pytorch on cpu

Open
#15,738 13 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

regression
Dominant language
C++
Stars
21.9k
Forks
4.2k
Avg merge
4d 11h
Merged PRs (30d)
184

Description

### Describe the issue

I converted a xlnet model to onnx, and the model is 3 times slower compared to pytorch in centos 7. I tried add_session_config_entry("session.set_denormal_as_zero", "1") based on previous issues. But still same performance.

It is interesting that on mac for the same model I am getting 2 times faster compared to pytorch.

### To reproduce

self.sessopts = onnxruntime.SessionOptions()
self.sessopts.graph_optimization_level = (onnxruntime.GraphOptimizationLevel.ORT_ENABLE_ALL )
self.sessopts.add_session_config_entry("session.set_denormal_as_zero", "1")
self.sessopts.intra_op_num_threads=4
self.session = onnxruntime.InferenceSession(model_filename, sess_options =self.sessopts, providers=[available_provider]
)

### Urgency

we have a release soon, we were hoping to deploy onnx model

### Platform

Linux

### OS Version

CentOS Linux 7 (Core)

### ONNX Runtime Installation

Built from Source

### ONNX Runtime Version or Commit ID

1.13.1

### ONNX Runtime API

Python

### Architecture

X86

### Execution Provider

Default CPU

### Execution Provider Library Version

_No response_

### Model File

_No response_

### Is this a quantized model?

No

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the Python reproduction snippet and the reported environment: ONNX Runtime 1.13.1, CentOS 7, x86, and the default CPU provider. The model file and provider library version are not supplied, so first obtain a reproducible XLNet model and benchmark it against PyTorch on the stated platform. Done means identifying the source of the slowdown or documenting the missing conditions needed to investigate it.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, python, pytorch
Domain
backend, machine-learning, performance
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.