Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to load DLL 'tensorflow' or one of its dependencies (ML.NET)

I have a .NET Core 3 app for image classification, using Microsoft's ML.NET framework.

On my development machine, I can run the code and it all works fine.

However, when I deploy it to my staging server, I get this error at runtime:

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)
...

I've tried copying tensorflow.dll into the bin folder during deployment; I've tried building as x64, x86, or AnyCPU. I've verified that the SciSharp.TensorFlow.Redist and Microsoft.ML.Tensorflow.Redist NuGet packages are included. Nothing so far has worked.

Any idea why it can't find the DLL file, or how I can get it to work?

like image 853
Kevin Owens Avatar asked Oct 24 '19 21:10

Kevin Owens


2 Answers

Installed "SciSharp.TensorFlow.Redist" version 1.14.0 and this issue is gone now.

My package references are exactly as follows:

<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" />
like image 138
VeteranLK Avatar answered Oct 23 '22 09:10

VeteranLK


Faced the same problem with a tensorflow neural network in a C# desktop application running ok in developement environment but failing in other machines. It was solved installing Microsoft Visual C++ redistributable in client machines

like image 5
Marcelo Esteves Avatar answered Oct 23 '22 09:10

Marcelo Esteves