gpt4 book ai didi

Error on InferenceSession while loading onnxmodel with directML in ML.net(在MLNet中使用DirectML加载onnxModel时,在InferenceSession上出错)

转载 作者:bug小助手 更新时间:2023-10-24 19:37:54 28 4
gpt4 key购买 nike



I'm quite new with pytorch, deep learning and neural network.
I'm trying to fine tuning a fastrcnn model to find holes and tubes in images with a c# application.

我对pytorch、深度学习和神经网络都很陌生。我正在尝试微调fastrcnn模型,以便使用c#应用程序在图像中查找孔洞和管子。


I've fine tuned the model, saved it in onnx format and used it with ml.net and it worked pretty well on CPU.
However it's a little slow (about 1.5 seconds/image) so i'm trying to use the GPU. Unfortunately I don't have any CUDA GPU, but i find DirectML that could help to improve the inference time.
Now the problems start.
I've found some example and they run pretty well, however when i run my project it now fails while loading model.

我已经对模型进行了微调,将其保存为onnx格式,并与ml.net一起使用,它在CPU上运行得很好。然而,它有点慢(大约1.5秒/张),所以我试着使用GPU。不幸的是,我没有任何CUDA图形处理器,但我发现DirectML可以帮助缩短推理时间。现在问题开始了。我已经找到了一些例子,它们运行得很好,然而,当我运行我的项目时,它现在加载模型时失败。


Here is my code:

以下是我的代码:


MLContext mlContext = new MLContext();

IEnumerable<ImageNetData> images = ImageNetData.ReadFromFile(imagesFolder);
IDataView imageDataView = mlContext.Data.LoadFromEnumerable(images);

var sessionOptions = new SessionOptions();
sessionOptions.GraphOptimizationLevel = GraphOptimizationLevel.ORT_ENABLE_ALL;
sessionOptions.ExecutionMode = ExecutionMode.ORT_SEQUENTIAL;
sessionOptions.EnableMemoryPattern = false;
sessionOptions.AppendExecutionProvider_DML(0);

var session = new InferenceSession(modelFilePath, sessionOptions);

The error occur in the last line and it says:

错误出现在最后一行,它说:


Microsoft.ML.OnnxRuntime.OnnxRuntimeException: '[ErrorCode:RuntimeException] Exception during initialization: D:\a_work\1\s\onnxruntime\core\providers\dml\DmlExecutionProvider\src\MLOperatorAuthorImpl.cpp(2352)\onnxruntime.DLL!00007FFA154BBB6B: (caller: 00007FFA154CFAAA) Exception(3) tid(11d0) 80070057 Parameter is incorrect.

初始化期间Microsoft.ML.OnnxRuntime.OnnxRuntimeException:的[错误代码:运行异常]异常:D:\a_work\1\s\onnxruntime\core\providers\dml\DmlExecutionProvider\src\MLOperatorAuthorImpl.cpp(2352)\onnxruntime.DLL!00007FFA154BBB6B:(调用方:00007FFA154CFAAA)异常(3)TID(11d0)80070057参数不正确。


If I comment the line

如果我注释这行


sessionOptions.AppendExecutionProvider_DML(0);

The code work well.
I think I make some mistakes while esporting the model in onnx model, but i can't find the issue.

代码运行良好。我想我在运行onnx模型时犯了一些错误,但我找不到问题所在。


更多回答
优秀答案推荐

I would suggest creating an issue on https://github.com/microsoft/onnxruntime/issues. Further details are required to diagnose the issue such as ONNX Runtime version, Windows version, etc. and that is the best way to provide the information.

我建议在https://github.com/microsoft/onnxruntime/issues.上制造一个问题需要进一步的详细信息来诊断问题,如ONNX Runtime版本、Windows版本等,这是提供信息的最佳方式。


更多回答

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com