fluid.io.load_inference_model 载入多个模型的时候会报错 -- [paddlepaddle]

将多个模型部署到同一个服务时,会出现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
posted @   龚细军  阅读(1003)  评论(0编辑  收藏  举报
编辑推荐:
· [.NET]调用本地 Deepseek 模型
· 一个费力不讨好的项目,让我损失了近一半的绩效!
· .NET Core 托管堆内存泄露/CPU异常的常见思路
· PostgreSQL 和 SQL Server 在统计信息维护中的关键差异
· C++代码改造为UTF-8编码问题的总结
阅读排行:
· 一个费力不讨好的项目,让我损失了近一半的绩效!
· 清华大学推出第四讲使用 DeepSeek + DeepResearch 让科研像聊天一样简单!
· 实操Deepseek接入个人知识库
· CSnakes vs Python.NET:高效嵌入与灵活互通的跨语言方案对比
· Plotly.NET 一个为 .NET 打造的强大开源交互式图表库
历史上的今天:
2016-06-11 Redis入门学习笔记一
2014-06-11 nyoj-----284坦克大战(带权值的图搜索)
点击右上角即可分享
微信分享提示