Closed
Description
Description
I have this exception in a multi thread application:
Apparently different threads tries to modify this Dictionary:
Reproduction Steps
Create more than one thread with a new instance of Session per thread:
private static void TestThreads()
{
List<Thread> threads = new List<Thread>();
const int THREADS_COUNT = 5;
for(int t = 0; t < THREADS_COUNT; t++)
{
Thread thread = new Thread(() =>
{
Graph g = new Graph();
g.Import("model.pb");
Session session = new Session(g);
});
thread.Start();
threads.Add(thread);
}
threads.ForEach(t => t.Join());
}
Known Workarounds
I can bypass this issue using a ConcurrentDictionary, but I don't know if that's an ideal solution.
Configuration and Other Information
Tensorflow.NET v0.100.5
.NET 6.0