microsoft / microsoft/onnxruntime

[Performance] DirectML EP uses ~32 GB VRAM and ~167 s to run HT-Demucs ONNX model (7.8 s input) on RTX 5090

Open
#31,482 4 comments 0 reactions 0 assignees View on GitHub
ep:DML performance stale
Dominant language
C++
Stars
21.9k
Forks
4.2k
Avg merge
4d 11h
Merged PRs (30d)
184

Description

### Describe the issue

When running the publicly available HT-Demucs ONNX model with the DirectML Execution Provider, nearly all available VRAM (~32 GB) is allocated during inference, despite the model processing only a fixed 7.8 second stereo input.

The model executes successfully and produces the expected output, however:

- GPU memory usage reaches approximately 31.8 GB on an RTX 5090 (32 GB)
- GPU utilization remains at 100%
- Inference takes approximately 167 seconds
- ONNX Runtime profiling reports relatively small activation/output sizes

The same behavior was observed with both:

- onnxruntime-directml 1.23.0
- onnxruntime-directml 1.24.4

I also simplified the ONNX model using `onnxsim`, reducing the graph substantially, but VRAM usage and runtime remained essentially unchanged.

From the generated ONNX Runtime profile, the model is executed as a single `DmlFusedNode_0_0`.

I am unsure whether this is expected behavior for DirectML, a limitation of the execution provider, or a potential performance issue.

Hardware:

- NVIDIA GeForce RTX 5090 (32 GB)
- Driver 591.86
- Windows 11

### To reproduce

Model:

https://huggingface.co/StemSplitio/htdemucs-onnx

Download `htdemucs.onnx` and place it next to the script.

Install:

```bash
pip install numpy onnxruntime-directml==1.23.0
```

Run:

```python
import time
import numpy as np
import onnxruntime as ort

MODEL = "htdemucs.onnx"

so = ort.SessionOptions()
so.enable_mem_pattern = False
so.execution_mode = ort.ExecutionMode.ORT_SEQUENTIAL

session = ort.InferenceSession(
MODEL,
sess_options=so,
providers=[
"DmlExecutionProvider",
"CPUExecutionProvider",
],
)

x = np.zeros((1, 2, 343980), dtype=np.float32)

start = time.time()

y = session.run(
["stems"],
{"mix": x},
)[0]

print("Output shape:", y.shape)
print("Elapsed:", time.time() - start)
```

Monitor GPU memory during inference:

```bash
nvidia-smi -l 1
```

Observed:

- VRAM: ~31.8 GB / 32.6 GB
- GPU utilization: 100%
- Runtime: ~167 seconds

The model input is fixed:

```
mix: [1, 2, 343980]
```

Output:

```
stems: [1, 4, 2, 343980]
```

I can also provide the ONNX Runtime profiling JSON if helpful.

### Urgency

This is primarily a performance investigation. The model executes correctly, but the observed VRAM usage and runtime seem unexpectedly high for the model and input size.

### Platform

Windows

### OS Version

11

### ONNX Runtime Installation

Built from Source

### ONNX Runtime Version or Commit ID

1.23.0 (also reproduced with 1.24.4)

### ONNX Runtime API

Python

### Architecture

X64

### Execution Provider

DirectML

### Execution Provider Library Version

DirectML (Windows), NVIDIA Driver 591.86

### Model File

Public model:

https://huggingface.co/StemSplitio/htdemucs-onnx

Model:

`htdemucs.onnx`

Input:

```
mix
shape: [1, 2, 343980]
```

Output:

```
stems
shape: [1, 4, 2, 343980]
```

Additional information:

- Opset: 17
- Original graph: ~24,917 nodes
- Simplified graph (`onnxsim`): substantially reduced node count, but no noticeable improvement in VRAM usage or runtime.

### Is this a quantized model?

No

Contributor guide

Open the contributing guide

Research direction

Start with the provided Python reproduction using ht demucs.onnx, onnxruntime-directml, and the fixed input shape, while monitoring VRAM and collecting the ONNX Runtime profiling JSON. Investigate the DirectML execution of the reported DmlFusedNode_0_0 and compare the original and onnxsim models. Done means determining whether the allocation and runtime are expected or identifying a specific DirectML issue with actionable evidence.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.