AIDajiangtang/Segment-Anything-CSharp

Non-zero status code returned while running Add node.

R4mR4m opened this issue · 8 comments

I have this error message:

'[ErrorCode:RuntimeException] Non-zero status code returned while running Add node. Name:'/blocks.7/attn/Add_2' Status Message: bad allocation'

while running:

var results = this.mEncoder.Run(inputs);

Have you experienced that?

The exception was thrown due to an incorrect version of OnnxRuntime during the model conversion

The model conversion environment should use the same OnnxRuntime version as the visual studio project Nuget package.

My environment had onnxruntime 1.14.1 while the project uses 1.15.0.

I updated my environment onnxruntime package to 1.15.0, converted the model again and it worked with no problem.

I was getting this error every single time I tried to run the application. Then looked at my PC resource usage and realized that it was not the memory shortage of my computer, so there had to be another problem.

After converting the model using onnxruntime 1.15.0 I was able to run the application.

R4mR4m commented

for better memory management add session options to both the encoder and decoder:

var options = new SessionOptions();
options.EnableMemoryPattern = false;
options.EnableCpuMemArena = false;

this.mEncoder = new InferenceSession(modelEncoder, options);
this.mDecoder = new InferenceSession(modelDecoder, options);

options.EnableMemoryPattern = false;
options.EnableCpuMemArena = false;

thanks for that