I created a YOLO v11 DL model using a given dataset and both the train and prediction modules work fine in PyCharm.
However, after exporting the model file to ONNX format and running the prediction session in a C# environment, the CUDA device does not work. When I create the SessionOptions() class or assign a CUDA index, the session always fails.
First, I checked the ONNX Runtime version. Here is the package version list:
CUDA toolkit: 12.8
CUDNN: 9.15.1
Microsoft.ML.OnnxRuntime.Gpu
Microsoft.ML.OnnxRuntime.Gpu.Windows
Microsoft.ML.OnnxRuntime.Managed: 1.23.1
Microsoft.ML.OnnxRuntime.Extensions: 0.14.0
Even though I followed the tutorial and checked the code, there are still errors.
using var gpuSessionOptions = SessionOptions.MakeSessionOptionWithCudaProvider(0);
using var session = new InferenceSession(modelPath, gpuSessionOptions);
Compiling with these lines works, but the initialization of SessionOptions always reports: Failed to load shared library.
After importing the onnxruntime.dll into Dependencies.exe, I found the ortextensions module is missing, even though I copied it into the output directory. I have no idea, can someone explain?


