microsoft / microsoft/onnxruntime

[Performance] slower inference after upgrade from 1.19.2 to 1.20.1

Open
#23,006 8 comments 0 reactions 1 assignee Claimed by @tianleiwu View on GitHub
ep:CUDA performance
Dominant language
C++
Stars
21.9k
Forks
4.2k
Avg merge
4d 11h
Merged PRs (30d)
184

Description

### Describe the issue

x15 slower inference after upgrade from 1.19.2 to 1.20.1

The problem arises in the interleaving of input tensor resolutions, for example in pyramid images for object detection.

CUDA : x15 slower
CPU : x2-3 slower

### To reproduce

```
import numpy as np
import onnxruntime as rt
import time

class timeit:
def __init__(self, msg : str = None):
self._msg = msg if msg is not None else ''
def __enter__(self):
self.t = time.perf_counter()
def __exit__(self, a,b,c):
print(f'Time of {self._msg}: {time.perf_counter()-self.t}')

sess = rt.InferenceSession('YoloV7Face.onnx',
providers=[ ('CUDAExecutionProvider', {'device_id':0}) ])

input_name = sess.get_inputs()[0].name

# Various resolution image (for example pyramid images)
imgs = [np.zeros((1,3,256+i*32,256+i*32), np.uint8) for i in range(5)]

while True:
with timeit():
for img in imgs:
sess.run(None, {input_name: img})

# 1.19.2 ~30ms
# 1.20.1 ~500ms
```

### Urgency

Not urgent. Will stay on 1.19.2

### Platform

Windows

### OS Version

10

### ONNX Runtime Installation

Released Package

### ONNX Runtime Version or Commit ID

1.20.1

### ONNX Runtime API

Python

### Architecture

X64

### Execution Provider

CUDA, CPU

### Execution Provider Library Version

CUDA 12.4

### Model File

[YoloV7Face.zip](https://github.com/user-attachments/files/18010726/YoloV7Face.zip)

### Is this a quantized model?

No

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.