microsoft / microsoft/onnxruntime

UnicodeDecodeError instead of actual error message when DlirectML fails on non-English Windows

Open
#32,082 1 comment 0 reactions 0 assignees View on GitHub
ep:DML platform:windows
Dominant language
C++
Stars
21.9k
Forks
4.2k
Avg merge
4d 11h
Merged PRs (30d)
184

Description

### Describe the issue

When creating an InferenceSession with DmlExecutionProvider fails (e.g. an invalid device_id), a UnicodeDecodeError is raised instead of the actual error message on a Japanese-locale Windows system. The real cause of the failure is completely masked.

```
Traceback (most recent call last):
File "D:\src\test_directml\test_dml.py", line 4, in
ort.InferenceSession(
~~~~~~~~~~~~~~~~~~~~^
get_example("sigmoid.onnx"),
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
providers=[("DmlExecutionProvider", {"device_id": 99})], # invalid device_id
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
enable_fallback=False,
^^^^^^^^^^^^^^^^^^^^^^
)
^
File "...\Lib\site-packages\onnxruntime\capi\onnxruntime_inference_collection.py", line 519, in __init__
raise e
File "...\Lib\site-packages\onnxruntime\capi\onnxruntime_inference_collection.py", line 504, in __init__
self._create_inference_session(providers, provider_options, disabled_optimizers)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "...\Lib\site-packages\onnxruntime\capi\onnxruntime_inference_collection.py", line 610, in
_create_inference_session
sess.initialize_session(providers, provider_options, disabled_optimizers)
~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x83 in position 181: invalid start byte
```

### To reproduce

```
import onnxruntime as ort
from onnxruntime.datasets import get_example

ort.InferenceSession(
get_example("sigmoid.onnx"),
providers=[("DmlExecutionProvider", {"device_id": 99})], # invalid device_id
enable_fallback=False,
)
```

### Urgency

Low

### Platform

Windows

### OS Version

Windows 11 (Japanese locale)

### ONNX Runtime Installation

Released Package

### ONNX Runtime Version or Commit ID

onnxruntime-directml 1.24.4

### ONNX Runtime API

Python

### Architecture

X64

### Execution Provider

DirectML

### Execution Provider Library Version

_No response_

Contributor guide

Open the contributing guide

Research direction

Start with the Python InferenceSession reproduction using DmlExecutionProvider and an invalid device_id on Japanese-locale Windows. Trace how the DirectML initialization error reaches the Python API and identify where the message is decoded. Done means the original DirectML error is shown instead of UnicodeDecodeError, while the reproduction remains covered by an appropriate test.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, python
Domain
machine-learning, operating-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.