將多個模型部署到同一個服務時,會出現stack錯誤. 原因是program為全局.
改成這樣,可以解決.
solved by myself. for those who need it:
use a new scope for every model
scope = fluid.Scope() with fluid.scope_guard(scope): place = fluid.CPUPlace() exe = fluid.Executor(place) [inference_program, _, fetch_targets] = ( fluid.io.load_inference_model(dirname=model_path[0], executor=exe, model_filename=model_path[1], params_filename=params_path[1]))
and for prediction:
with fluid.scope_guard(scope): results = exe.run(inference_program, feed=inputs, fetch_list=fetch_targets)
參考鏈接: https://github.com/PaddlePaddle/models/issues/1164