-
Notifications
You must be signed in to change notification settings - Fork 539
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Description
I have this exception in a multi thread application:
Apparently different threads tries to modify this Dictionary:
private static Dictionary<string, Components> _STRING_TO_COMPONENTS_CACHE = new(); |
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
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working