Skip to content

"Cannot access a disposed object." with multithreading  #912

@Superpiffer

Description

@Superpiffer

I have an issue with Tensorflow.NET 0.70.1 and a multithreading console application:
image
I have the same problem with CPU or GPU native library, tensorflow 2.7.0.
Here you can find a sample project:
TensorflowMultithreadingTest.zip

Note: I cannot use using for the inference because I need to reuse the same session, I don't think is feasible to create a new Session every time.
Note 2: Using modelSession.Dispose() at the end of the processing or using GC.SuppressFinalize(modelSession) after the declaration solve the problem, but I don't think it's the best solution.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions