I'm using Keras with Tensorflow as backend.
I am trying to save a model in my main process and then load/run (i.e. call model.predict
) within another process.
I'm currently just trying the naive approach from the docs to save/load the model: https://keras.io/getting-started/faq/#how-can-i-save-a-keras-model.
So basically:
model.save()
in main processmodel = load_model()
in child processmodel.predict()
in child process
However, it simply hangs on the load_model
call.
Searching around I've discovered this potentially related answer suggesting that Keras can only be utilized in one process: using multiprocessing with theano but am unsure if this is true (can't seem to find much on this).
Is there a way to accomplish my goal? A high level description or short example is greatly appreciated.
Note: I've attempted approaches along the lines of passing a graph to the process but failed since it seems tensorflow graphs aren't pickable (related SO post for that here: Tensorflow: Passing a session to a python multiprocess). If there is indeed a way to pass the tensorflow graph/model to the child process then I am open to that as well.
Thanks!