【问题标题】:Unable to load DLL 'tensorflow' on Windows 2012 R2 Server无法在 Windows 2012 R2 服务器上加载 DLL 'tensorflow'
【发布时间】:2020-01-16 10:02:46
【问题描述】:

我在 Windows 10 的 Visual Studio 中使用 ML.Net Model Builer 创建了一个图像分类器。它已编译到控制台应用程序中。这在开发机器和其他 Windows 10 机器上运行良好。 我需要将它部署到 Windows 2012 R2 服务器,但是当我启动应用程序时,我收到以下错误消息:

System.Reflection.TargetInvocationException: Exception has been thrown by the ta
rget of an invocation. ---> System.Reflection.TargetInvocationException: Excepti
on has been thrown by the target of an invocation. ---> System.Reflection.Target
InvocationException: Exception has been thrown by the target of an invocation. -
--> System.Reflection.TargetInvocationException: Exception has been thrown by th
e target of an invocation. ---> System.DllNotFoundException: Unable to load DLL
'tensorflow': A dynamic link library (DLL) initialization routine failed. (Excep
tion from HRESULT: 0x8007045A)
   at Tensorflow.c_api.TF_NewGraph()
   at Tensorflow.Graph..ctor()
   at Microsoft.ML.TensorFlow.TensorFlowUtils.LoadTFSession(IExceptionContext ec
tx, Byte[] modelBytes, String modelFile)
   at Microsoft.ML.Vision.ImageClassificationModelParameters..ctor(IHostEnvironm
ent env, ModelLoadContext ctx)
   --- End of inner exception stack trace ---
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments,
 Signature sig, Boolean constructor)
   at System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, B
inder binder, Object[] parameters, CultureInfo culture)
   at Microsoft.ML.Runtime.ComponentCatalog.LoadableClassInfo.CreateInstanceCore
(Object[] ctorArgs)
   at Microsoft.ML.Runtime.ComponentCatalog.TryCreateInstance[TRes](IHostEnviron
ment env, Type signatureType, TRes& result, String name, String options, Object[
] extra)
   at Microsoft.ML.Runtime.ComponentCatalog.TryCreateInstance[TRes,TSig](IHostEn
vironment env, TRes& result, String name, String options, Object[] extra)
   at Microsoft.ML.ModelLoadContext.TryLoadModelCore[TRes,TSig](IHostEnvironment
 env, TRes& result, Object[] extra)
   at Microsoft.ML.ModelLoadContext.TryLoadModel[TRes,TSig](IHostEnvironment env
, TRes& result, RepositoryReader rep, Entry ent, String dir, Object[] extra)
   at Microsoft.ML.ModelLoadContext.LoadModel[TRes,TSig](IHostEnvironment env, T
Res& result, RepositoryReader rep, Entry ent, String dir, Object[] extra)
   at Microsoft.ML.ModelLoadContext.LoadModelOrNull[TRes,TSig](IHostEnvironment
env, TRes& result, RepositoryReader rep, String dir, Object[] extra)
   at Microsoft.ML.ModelLoadContext.LoadModel[TRes,TSig](IHostEnvironment env, T
Res& result, String name, Object[] extra)
   at Microsoft.ML.Data.MulticlassPredictionTransformer.Create(IHostEnvironment
env, ModelLoadContext ctx)
   --- End of inner exception stack trace ---
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments,
 Signature sig, Boolean constructor)
   at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Objec
t[] parameters, Object[] arguments)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invoke
Attr, Binder binder, Object[] parameters, CultureInfo culture)
   at Microsoft.ML.Runtime.ComponentCatalog.LoadableClassInfo.CreateInstanceCore
(Object[] ctorArgs)
   at Microsoft.ML.Runtime.ComponentCatalog.TryCreateInstance[TRes](IHostEnviron
ment env, Type signatureType, TRes& result, String name, String options, Object[
] extra)
   at Microsoft.ML.Runtime.ComponentCatalog.TryCreateInstance[TRes,TSig](IHostEn
vironment env, TRes& result, String name, String options, Object[] extra)
   at Microsoft.ML.ModelLoadContext.TryLoadModelCore[TRes,TSig](IHostEnvironment
 env, TRes& result, Object[] extra)
   at Microsoft.ML.ModelLoadContext.TryLoadModel[TRes,TSig](IHostEnvironment env
, TRes& result, RepositoryReader rep, Entry ent, String dir, Object[] extra)
   at Microsoft.ML.ModelLoadContext.LoadModel[TRes,TSig](IHostEnvironment env, T
Res& result, RepositoryReader rep, Entry ent, String dir, Object[] extra)
   at Microsoft.ML.ModelLoadContext.LoadModelOrNull[TRes,TSig](IHostEnvironment
env, TRes& result, RepositoryReader rep, String dir, Object[] extra)
   at Microsoft.ML.ModelLoadContext.LoadModel[TRes,TSig](IHostEnvironment env, T
Res& result, String name, Object[] extra)
   at Microsoft.ML.Data.TransformerChain`1..ctor(IHostEnvironment env, ModelLoad
Context ctx)
   at Microsoft.ML.Data.TransformerChain.Create(IHostEnvironment env, ModelLoadC
ontext ctx)
   --- End of inner exception stack trace ---
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments,
 Signature sig, Boolean constructor)
   at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Objec
t[] parameters, Object[] arguments)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invoke
Attr, Binder binder, Object[] parameters, CultureInfo culture)
   at Microsoft.ML.Runtime.ComponentCatalog.LoadableClassInfo.CreateInstanceCore
(Object[] ctorArgs)
   at Microsoft.ML.Runtime.ComponentCatalog.TryCreateInstance[TRes](IHostEnviron
ment env, Type signatureType, TRes& result, String name, String options, Object[
] extra)
   at Microsoft.ML.Runtime.ComponentCatalog.TryCreateInstance[TRes,TSig](IHostEn
vironment env, TRes& result, String name, String options, Object[] extra)
   at Microsoft.ML.ModelLoadContext.TryLoadModelCore[TRes,TSig](IHostEnvironment
 env, TRes& result, Object[] extra)
   at Microsoft.ML.ModelLoadContext.TryLoadModel[TRes,TSig](IHostEnvironment env
, TRes& result, RepositoryReader rep, Entry ent, String dir, Object[] extra)
   at Microsoft.ML.ModelLoadContext.LoadModel[TRes,TSig](IHostEnvironment env, T
Res& result, RepositoryReader rep, Entry ent, String dir, Object[] extra)
   at Microsoft.ML.ModelLoadContext.LoadModelOrNull[TRes,TSig](IHostEnvironment
env, TRes& result, RepositoryReader rep, String dir, Object[] extra)
   at Microsoft.ML.ModelLoadContext.LoadModel[TRes,TSig](IHostEnvironment env, T
Res& result, String name, Object[] extra)
   at Microsoft.ML.Data.TransformerChain`1..ctor(IHostEnvironment env, ModelLoad
Context ctx)
   at Microsoft.ML.Data.TransformerChain.Create(IHostEnvironment env, ModelLoadC
ontext ctx)
   --- End of inner exception stack trace ---
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments,
 Signature sig, Boolean constructor)
   at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Objec
t[] parameters, Object[] arguments)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invoke
Attr, Binder binder, Object[] parameters, CultureInfo culture)
   at Microsoft.ML.Runtime.ComponentCatalog.LoadableClassInfo.CreateInstanceCore
(Object[] ctorArgs)
   at Microsoft.ML.Runtime.ComponentCatalog.TryCreateInstance[TRes](IHostEnviron
ment env, Type signatureType, TRes& result, String name, String options, Object[
] extra)
   at Microsoft.ML.Runtime.ComponentCatalog.TryCreateInstance[TRes,TSig](IHostEn
vironment env, TRes& result, String name, String options, Object[] extra)
   at Microsoft.ML.ModelLoadContext.TryLoadModelCore[TRes,TSig](IHostEnvironment
 env, TRes& result, Object[] extra)
   at Microsoft.ML.ModelLoadContext.TryLoadModel[TRes,TSig](IHostEnvironment env
, TRes& result, RepositoryReader rep, Entry ent, String dir, Object[] extra)
   at Microsoft.ML.ModelLoadContext.LoadModel[TRes,TSig](IHostEnvironment env, T
Res& result, RepositoryReader rep, Entry ent, String dir, Object[] extra)
   at Microsoft.ML.ModelLoadContext.LoadModelOrNull[TRes,TSig](IHostEnvironment
env, TRes& result, RepositoryReader rep, String dir, Object[] extra)
   at Microsoft.ML.ModelLoadContext.LoadModel[TRes,TSig](IHostEnvironment env, T
Res& result, RepositoryReader rep, String dir, Object[] extra)
   at Microsoft.ML.ModelOperationsCatalog.Load(Stream stream, DataViewSchema& in
putSchema)
   at Microsoft.ML.ModelOperationsCatalog.Load(String filePath, DataViewSchema&
inputSchema)
   at Gatehouse.AI.KeyClassification.KeyClassifierModel..ctor()
   at delmedelme.Proxy.IsKey() in C:\xxxxxxxx.cs:line 18

谁能建议我如何解决这个问题?

谢谢

【问题讨论】:

    标签: c# tensorflow machine-learning ml.net


    【解决方案1】:

    我遇到了同样的问题。

    解决方案是添加功能“桌面体验”,W2012 安装中默认不包含该功能。

    希望对你有帮助!

    【讨论】:

    • 不幸的是,它似乎没有什么不同。感谢您的建议。
    • 我们仍未明确确定问题所在。然而,在多台机器上进行测试后——似乎与操作系统无关,而更多的是处理器是否支持 AVX。在 AVX 之前的 e6540 Xeon 上运行时发现了原始问题。该代码在 Windows 2012 R2 上运行良好,带有支持 AVX 的更高版本的处理器。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-04-28
    • 1970-01-01
    • 2019-04-30
    • 2010-09-25
    • 2016-08-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多