首页 > 解决方案 > 无法加载 DLL 'tensorflow' 或其依赖项之一 (ML.NET)

问题描述

我有一个用于图像分类的 .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#tensorflowdllasp.net-core-3.0ml.net

解决方案


安装了“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" />

推荐阅读