c# - 无法加载 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 文件,或者我怎样才能让它工作?
解决方案
安装了“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" />
推荐阅读
- python - 将 2 个 numpy 3d 数组组合成整体形状
- vue.js - VueJS 在不改变“类型”属性的情况下切换密码可见性
- prolog - 如何创建独立的 swi-plog 可执行文件?
- google-apps-script - 获取谷歌表单的实时答案
- javascript - 围绕物体旋转相机
- javascript - 从后端获取数据以在 Javascript 中创建下拉列表
- laravel - Faker 如何用相对日期填充 created_at 字段?
- ajax - 在关注 laravel 上构建一个 AJAX 按钮
- office-js - Office 插件 - context.runtime.load("enableEvents") 在 Window 中不起作用
- python - Python:最小堆交换计数