Thanks to visit codestin.com Credit goes to github.com
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I have this exception in a multi thread application:
Apparently different threads tries to modify this Dictionary:
TensorFlow.NET/src/TensorFlowNET.Core/Device/DeviceSpec.cs
Line 10 in cd64ea9
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()); }
I can bypass this issue using a ConcurrentDictionary, but I don't know if that's an ideal solution.
Tensorflow.NET v0.100.5 .NET 6.0
The text was updated successfully, but these errors were encountered:
ConcurrentDictionary is the good approach. @AsakusaRinne
ConcurrentDictionary
Sorry, something went wrong.
AsakusaRinne
Successfully merging a pull request may close this issue.
Description
I have this exception in a multi thread application:

Apparently different threads tries to modify this Dictionary:
TensorFlow.NET/src/TensorFlowNET.Core/Device/DeviceSpec.cs
Line 10 in cd64ea9
Reproduction Steps
Create more than one thread with a new instance of Session per thread:
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
The text was updated successfully, but these errors were encountered: