| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Tensorflow.NET is thread-safe, our multithreading model is thread-wide Session and Graph; meaning tf.get_default_graph/session() are unique to the thread they are executed in.
We chose this model because a dominant portion of our api does not accept Graph as a parameter, instead
it accesses tf.get_default_graph() to initialize an Operation in it.
This allows cleaner and similar code to Python and still having complete isolation between threads.
Due to lack of documentation in Tensorflow regarding their c_api, we don't know which of their API is threadsafe therefore some issues such as access violation or other types of memory corruption might occur. Let us know about it and we'll work to get it fixed. In most cases wrapping code with lock (Locks.ProcessWide) solves the problem.
lock (Locks.ProcessWide)
{
var status = new Status();
c_api.someapicall();
status.Check(true);
}Task.Factory.StartNew(() => { ... }, TaskCreationOptions.LongRunning);Call tf.enforce_singlethreading() in the begginging of your notebook.
It was created specially for specific cases like Jupyter notebook where different threads can call your code chunks.
This will cause the library to always behave as if it is run on a single thread but does not use any locking calls.
Simply put to words: makes the library forcefully singlethreaded but unsafe multithreaded calls.
| Back | FazBrowse Home | New Git URL |