【问题标题】:Unable to load DLL 'tensorflow' or one of its dependencies (ML.NET)无法加载 DLL 'tensorflow' 或其依赖项之一 (ML.NET)
【发布时间】:2019-10-24 21:51:50
【问题描述】:

我有一个用于图像分类的 .NET Core 3 应用,使用 Microsoft 的 ML.NET 框架。

在我的开发机器上,我可以运行代码并且一切正常。

但是,当我将它部署到临时服务器时,我在运行时收到此错误:

System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
     System.DllNotFoundException: Unable to load DLL 'tensorflow' or one of its dependencies: The specified module could not be found. (0x8007007E)
     at Tensorflow.c_api.TF_NewGraph()
     at Tensorflow.Graph..ctor()
     at Microsoft.ML.Transforms.Dnn.DnnUtils.LoadTFSession(IExceptionContext ectx, Byte[] modelBytes, String modelFile)
...

我尝试在部署期间将 tensorflow.dll 复制到 bin 文件夹中;我尝试构建为 x64、x86 或 AnyCPU。我已验证包含 SciSharp.TensorFlow.Redist 和 Microsoft.ML.Tensorflow.Redist NuGet 包。到目前为止没有任何效果。

知道为什么它找不到 DLL 文件,或者我怎样才能让它工作?

【问题讨论】:

标签: c# tensorflow dll asp.net-core-3.0 ml.net


【解决方案1】:

已安装“SciSharp.TensorFlow.Redist”版本 1.14.0,此问题现已消失。

我的包引用如下:

<PackageReference Include="Microsoft.ML" Version="1.4.0" />
<PackageReference Include="Microsoft.ML.ImageAnalytics" Version="1.4.0" />
<PackageReference Include="Microsoft.ML.Vision" Version="1.4.0" />
<PackageReference Include="SciSharp.TensorFlow.Redist" Version="1.14.0" />

【讨论】:

  • 添加 SciSharp.TensorFlow.Redist 后,我​​的问题就得到了解决。就我而言,v2.1 也可以。
【解决方案2】:

我已经找到了根本原因。

原因 1: Microsoft.ML 仅适用于 x64

原因 2: 以下软件包的最新稳定版本(1.4.0)抛出错误。 以下 v1.3.1 软件包运行良好。

  • Microsoft.ML v1.3.1
  • Microsoft.ML.ImageAnalytics v1.3.1
  • Microsoft.ML.TensorFlow v1.3.1

原因 3: ML.NET 和张量流只能在 .NET CORE 中正常工作,而不能在 .NET 框架中工作。

希望这对你也有用!快乐编码!

【讨论】:

    【解决方案3】:

    在 C# 桌面应用程序中的 tensorflow 神经网络在开发环境中运行正常但在其他机器上失败时面临同样的问题。已解决在客户端机器上安装Microsoft Visual C++ redistributable

    【讨论】:

    • 这对我有用。我的设置是 Microsoft.ML = 1.5.2,Microsoft.ML.ImageAnalytics=1.5.2,Microsoft.ML.TensorFlow=1.5.2,SciSharp.TensorFlow.Redist=2.3.1。加载由 tensorflow 2.1.x 创建并在 Windows 8 x64 上运行的模型
    【解决方案4】:

    我在使用 ML 库时遇到了一些问题:

    OQ 中提到的特定的。错误:Unable to load DLL 'tensorflow' or one of its dependencies: The specified module could not be found. (0x8007007E),确实通过更新到最新的 VC++ x64 Redistributable 得到解决。对我来说,那个链接是here

    出现错误时:Unable to find an entry point named 'TF_StringEncodedSize' in DLL 'tensorflow' 我需要将 SciSharp.TensorFlow.Redist 库从 2.4.x 降级到 2.3.x。

    收到Check whether your GraphDef-interpreting binary is up to date with your GraphDef-generating binary 错误时,我注意到安装 Microsoft.ML.TensorFlow.Redist 是一个错误,需要删除。

    【讨论】:

      【解决方案5】:

      安装最新的 VC_redist 就可以了!

      【讨论】:

        【解决方案6】:

        安装 vc_redist.x64.exe 帮助了我

        【讨论】:

          【解决方案7】:

          如果您添加对 Microsoft.ML.TensorFlow.Redist 的引用,这可能会有所帮助。它为我解决了。

          【讨论】:

            【解决方案8】:
            1. 首先,确保您的硬件能够处理最新的软件技术,例如 CPU 架构或主板兼容性。我遇到了这个问题,因为我使用的是 10 多年前的旧系统。
            2. 安装最新的兼容 vc_redist_64x 发行版。
            3. 安装为 x64 系统安装框架兼容性包的 Windows 更新。

            当我执行以下所有操作时,它对我有用。

            【讨论】:

              猜你喜欢
              • 1970-01-01
              • 1970-01-01
              • 2019-12-02
              • 2021-08-05
              • 2011-05-23
              • 2012-09-15
              • 2018-08-21
              • 1970-01-01
              相关资源
              最近更新 更多