无法加载 DLL 'tensorflow' 或其依赖项之一 (ML.NET)

Kev*_*ens 5 c# dll tensorflow ml.net asp.net-core-3.0

我有一个用于图像分类的 .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)
...
Run Code Online (Sandbox Code Playgroud)

我试过在部署过程中将 tensorflow.dll 复制到 bin 文件夹中;我试过构建为 x64、x86 或 AnyCPU。我已经验证包含 SciSharp.TensorFlow.Redist 和 Microsoft.ML.Tensorflow.Redist NuGet 包。到目前为止,一切都没有奏效。

知道为什么它找不到 DLL 文件,或者我如何让它工作?

Vet*_*nLK 11

安装了“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" />
Run Code Online (Sandbox Code Playgroud)


Vig*_*aja 5

我已经找出根本原因了。

原因 1: Microsoft.ML 适用于x64

原因 2: 以下软件包的最新稳定版本(1.4.0)抛出错误。以下v1.3.1包工作正常。

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

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

希望这也适合你!快乐编码!


小智 5

在 C# 桌面应用程序中,张量流神经网络在开发环境中运行正常,但在其他机器上运行失败,也遇到了同样的问题。在客户端计算机上安装Microsoft Visual C++ 可再发行组件已解决


Car*_*Bos 5

我在使用 ML 库时遇到了许多问题:

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

收到错误时: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 是一个错误,需要删除。