【问题标题】:ASP.NET Core Load an Onnx file inside a Docker containerASP.NET Core 在 Docker 容器中加载 Onnx 文件
【发布时间】:2020-04-24 11:15:48
【问题描述】:

我正在尝试构建一个使用 Onnx 机器学习模型文件的 ASP.NET Core api。我是这样加载的:

OnnxScoringEstimator pipeline = _mlContext.Transforms.ApplyOnnxModel(_config.GetSection("ModelPath").Value);

这意味着它从 appsettings.json 文件中获取路径,如下所示:

appsettings.Development.json

"ModelPath": "C:\\Users\\name\\dev\\solution\\project\\model.onnx"

还有我的 appsettings.Production.json

"ModelPath": "./model.onnx"

在我的机器上调试项目时它确实可以工作,但当我在 docker 容器中构建它时就不行。然后它给出以下错误:

Connection id "0HLV880PG88DT", Request id "0HLV880PG88DT:00000002": An unhandled exception was thrown by the application.

System.DllNotFoundException: Unable to load shared library 'onnxruntime' or one of its dependencies. In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable: libonnxruntime: cannot open shared object file: No such file or directory

因为它说No such file or directory 我会说这与我的模型路径错误有关,但我不确定。

我希望有人可以提供帮助。谢谢

【问题讨论】:

    标签: docker asp.net-core


    【解决方案1】:

    我也遇到了这个问题,经过一番头疼后,我在 Github 问题中找到了一个对我有用的解决方案,该问题指向 ONNX 运行时系统要求文档:https://github.com/Microsoft/onnxruntime#system-requirements

    重点:

    对于 Linux,系统必须有 libgomp.so.1,可以使用 apt-get install libgomp1 安装。

    将以下命令添加到 Dockerfile 后,我的应用程序按预期运行:

    RUN apt-get update && apt-get install -y libgomp1
    

    【讨论】:

      猜你喜欢
      • 2018-11-17
      • 1970-01-01
      • 2019-08-02
      • 1970-01-01
      • 1970-01-01
      • 2016-06-30
      • 1970-01-01
      • 1970-01-01
      • 2022-10-08
      相关资源
      最近更新 更多