Now we have used TensorFlow to train and export an model. We can implement the inference service with this model just like how tensorflow/serving
does.
I have a question about whether the tf.Session
object is thread-safe or not. If it's true, we may initialize the object after starting and use the singleton object to process the concurrent requests.
As we have seen, the TensorFlow Session object is multithreaded and thread-safe, so multiple threads can easily use the same session and run ops in parallel.
The TensorFlow Session object is multithreaded, so multiple threads can easily use the same session and run ops in parallel.
A session allows to execute graphs or part of graphs. It allocates resources (on one or more machines) for that and holds the actual values of intermediate results and variables.
TensorFlow Session is a session object which encapsulates the environment in which Operation objects are executed, and data objects are evaluated. TensorFlow requires a session to execute an operation and retrieve its calculated value. A session may own several resources, for example, tf. QueueBase, tf.
The tf.Session
object is thread-safe for Session.run()
calls from multiple threads.
Before TensorFlow 0.10 graph modification was not thread-safe. This was fixed in the 0.10 release, so you can add nodes to the graph concurrently with Session.run()
calls, although this is not advised for performance reasons; instead, it is recommended to call sess.graph.finalize()
before using the session from multiple threads, to prevent accidental memory leaks.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With