Closed kyao closed 6 years ago
The Tensorflow library is not thread-safe or fork-safe which is problematic in our system. A workaround for that is to load it only in the workers or modify the primitives to use the fork-safe version.
This problem arose in the context of TA2-TA3 interaction, where I disabled our multi-processing due grpc limitations. As a quick fix to our system, I modified our TA2 to call clear_session(), and that seems to have worked. But, the real fix base based on https://github.com/tensorflow/tensorflow/issues/14356 , is to keep store and use the tensor flow graph.
model = ResNet50(weights="imagenet")
# this is key : save the graph after loading the model
graph = tf.get_default_graph()
with graph.as_default():
preds = model.predict(image)
#... etc
See these two pages for possible solutions:
https://stackoverflow.com/questions/46911596/why-does-tensorflow-say-a-tensor-is-not-an-element-of-this-graph-when-training-a
https://github.com/tensorflow/tensorflow/issues/14356