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.
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.
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.
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.