microsoft / onnxruntime

ONNX Runtime: cross-platform, high performance ML inferencing and training accelerator
https://onnxruntime.ai
MIT License
14.24k stars 2.87k forks source link

DirectML Resize Node error. #18613

Open leepenkman opened 10 months ago

leepenkman commented 10 months ago

Describe the issue

DirectML Resize Node error.

To reproduce

Running the onnx model for MODNet in windows C# DirectML, getting this error about one of the operators , works fine on CPU.

2023-11-29 19:12:30.2123483 [E:onnxruntime:, sequential_executor.cc:514 onnxruntime::ExecuteKernel] Non-zero status code returned while running Resize node. Name:'Resize_190' Status Message: D:\a\_work\1\s\onnxruntime\core\providers\dml\DmlExecutionProvider\src\MLOperatorAuthorImpl.cpp(2449)\onnxruntime.DLL!00007FFD48C1ADD5: (caller: 00007FFD48C1A468) Exception(3) tid(dce8) 80070057 The parameter is incorrect.

Unhandled exception. Microsoft.ML.OnnxRuntime.OnnxRuntimeException: [ErrorCode:RuntimeException] Non-zero status code returned while running Resize node. Name:'Resize_190' Status Message: D:\a\_work\1\s\onnxruntime\core\providers\dml\DmlExecutionProvider\src\MLOperatorAuthorImpl.cpp(2449)\onnxruntime.DLL!00007FFD48C1ADD5: (caller: 00007FFD48C1A468) Exception(3) tid(dce8) 80070057 The parameter is incorrect.

   at Microsoft.ML.OnnxRuntime.InferenceSession.RunImpl(RunOptions options, IntPtr[] inputNames, IntPtr[] inputValues, IntPtr[] outputNames)
   at Microsoft.ML.OnnxRuntime.InferenceSession.Run(IReadOnlyCollection`1 inputs, IReadOnlyCollection`1 outputNames, RunOptions options)
   at Microsoft.ML.OnnxRuntime.InferenceSession.Run(IReadOnlyCollection`1 inputs, IReadOnlyCollection`1 outputNames)
   at Microsoft.ML.OnnxRuntime.InferenceSession.Run(IReadOnlyCollection`1 inputs)
   at ONNX.FastNeuralStyleTransfer.Matting.Process(Mat original, String model) in D:\work\StyleTransfer\src\Matting.cs:line 68
   at Program.<>c__DisplayClass0_0.<<Main>$>b__0(Mat image, Int32 i) in D:\work\StyleTransfer\src\Program.cs:line 54
   at System.Linq.Enumerable.SelectIterator[TSource,TResult](IEnumerable`1 source, Func`3 selector)+MoveNext()
   at System.Linq.Enumerable.EnumerablePartition`1.MoveNext()
   at System.Linq.Enumerable.SelectIPartitionIterator`2.MoveNext()
   at FFMpegCore.Pipes.RawVideoPipeSource.GetStreamArguments()
   at FFMpegCore.Arguments.InputPipeArgument.get_Text()
   at FFMpegCore.FFMpegArguments.<>c__DisplayClass4_0.<GetText>b__0(IArgument arg)
   at System.Linq.Enumerable.SelectArrayIterator`2.MoveNext()
   at System.String.Join(String separator, IEnumerable`1 values)
   at FFMpegCore.FFMpegArguments.GetText()
   at FFMpegCore.FFMpegArguments.get_Text()
   at FFMpegCore.FFMpegArgumentProcessor.PrepareProcessArguments(FFOptions ffOptions, CancellationTokenSource& cancellationTokenSource)
   at FFMpegCore.FFMpegArgumentProcessor.ProcessSynchronously(Boolean throwOnError, FFOptions ffMpegOptions)
   at VideoUtils.<>c__DisplayClass1_0.<WriteVideo>b__0() in D:\work\StyleTransfer\src\VideoUtils.cs:line 229
   at ImageUtils.TimeAction(String name, Action blockingAction) in D:\work\StyleTransfer\src\ImageUtils.cs:line 49
   at VideoUtils.WriteVideo(IEnumerable`1 images, String outputFileName) in D:\work\StyleTransfer\src\VideoUtils.cs:line 152
   at Program.<Main>$(String[] args) in D:\work\StyleTransfer\src\Program.cs:line 64
INF took 16013.6384 ms

Urgency

Working on background removal - Important AI related product work at Microsoft Clipchamp.

Platform

Windows

OS Version

Windows 11

ONNX Runtime Installation

Released Package

ONNX Runtime Version or Commit ID

1.16.3 from NuGet

ONNX Runtime API

C#

Architecture

X64

Execution Provider

DirectML

Execution Provider Library Version

1.16.3 from NuGet

fdwr commented 10 months ago

Can you get any more info via dxcpl.exe and enabling the D3D/DML debug layer to view messages (either in Visual Studio's output window or SysInternals DebugView)? See my comment here: https://github.com/microsoft/onnxruntime/issues/13330#issuecomment-1284817983

edward0802 commented 7 months ago

@leepenkman did you resolve this issue?

edward0802 commented 6 months ago

I resolved this issue on Windows 10/11 when I added a specific RuntimeIdentifier (RID) to the project that contains Microsoft.ML.OnnxRuntime.DirectML -v 1.16.3 package:

<PropertyGroup>
    <RuntimeIdentifier>win-x64</RuntimeIdentifier>
    <TargetFramework>net7.0</TargetFramework>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>disable</Nullable>
</PropertyGroup>

It seems like it requires some platform-specific packages and provided RID used by NuGet to restore packages containing platform-specific parts

Also, it can be resolved by changing the architecture from 'Any CPU' to 'x-64' in sln configuration