I followed the steps on the 'Get Started' page (https://www.microsoft.com/net/learn/apps/machine-learning-and-ai/ml-dotnet/get-started/windows). But I created a .NET 4.7 console app.
When I run the application the following exception is thrown on line 70 of Program.cs
I have located the missing DLL in the packages folder. If I manually copy the file into the output folder of my project the application runs as expected.
============== Exception Information ==============
System.Reflection.TargetInvocationException
HResult=0x80131604
Message=Exception has been thrown by the target of an invocation.
Source=mscorlib
StackTrace:
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at Microsoft.ML.Runtime.EntryPoints.EntryPointNode.Run()
at Microsoft.ML.Runtime.EntryPoints.EntryPointGraph.RunNode(EntryPointNode node)
at Microsoft.ML.Runtime.EntryPoints.JsonUtils.GraphRunner.RunAllNonMacros()
at Microsoft.ML.Runtime.EntryPoints.JsonUtils.GraphRunner.RunAll()
at Microsoft.ML.LearningPipeline.TrainTInput,TOutput
at myApp.Program.Main(String[] args) in C:UsersDaveDocumentsVisual Studio 2017ProjectsMLTestsIrisProgram.cs:line 70
Inner Exception 1:
TargetInvocationException: Exception has been thrown by the target of an invocation.
Inner Exception 2:
DllNotFoundException: Unable to load DLL 'CpuMathNative': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
I followed some of the suggetions from this page and got it to work with that tutorial
https://github.com/dotnet/machinelearning/issues/93
@pareion I'm getting the same problem, what specifically do you think fixed the problem.
I can confirm this issue. Besides the mentioned workaround (manually copying the missing file) it also works to switch the "TargetFramework" property from "net47" to "netcoreapp2.0". Therefore it seems to be related with using .NET Framework.
I've seen 2 cases where this error happens:
<PackageReference> in your .csproj. This issue is tracked by #93, and a fix should be made soon to the daily builds.Any CPU. ML.NET only supports x64, so if you are using the desktop/full .NET Framework, ensure you change Any CPU to x64, since there are only x64 native assemblies.@aklcraigc I manually changed the .csproj file by adding the line
<PackageReference Include="Microsoft.ML" Version="0.1.0" />
And then changed the targeting to x64
@pareion Thanks, that did the trick.
@DaisyDave, did the suggestions in this issue work for you? If so, we can close the issue :)
@markusweimer Sorry for the lack of updates. The suggestions solved that error but there was a minor issue with the solutiion, I'm not sure whether this was because I didn't start from scratch and still had things in my packages folder. Below are the steps I took.
There was one minor issue, it did not add any of the dependancies it had during the initial attempt. I ended up having to manual add the json package to get the app to run. As I said at the top I'm not sure if this was because I didn't start totally from scratch.
You can close this issue for me but if you are not going to or can't fix the package.config issue perhaps adding something to the getting started page would be an idea.
I just tried the aforementioned"PackageReference" workaround but I still getting the error. I had to switch to
@claudiobottari - are you using VS 2015 or VS 2017? Would it be possible to share your .csproj so I can take a look?
VS 2017
csproj attached
Sample.zip
@claudiobottari - the issue is that ML.NET only supports x64, and you are attempting to use AnyCPU. You can change the following:
<RuntimeIdentifier>AnyCPU</RuntimeIdentifier>
||
V
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
And remove the line
<PlatformTarget>AnyCPU</PlatformTarget>
That should fix your project. When fixing #93, I am also adding a build error message to help people in this situation know that they need to target x64.
Thank you, my project works now
My issue seems to be solved too. I already used "PackageReference" and x64. But I was setting x64 as PlatformTarget. Tried it with RuntimeIdentifier and finally the CpuMathNative.dll exists in the output folder of my project. Everything seems to work now.
I have retested by setting up a new project and then adding Microsoft.ML using NuGet using Visual Studio set to manage packages via PackageReference. There were no errors.
I'm going to close my issue.
Adding, <PackageReference Include="Microsoft.ML" Version="0.1.0" /> inside the <ItemGroup> of *.csproj worked for me.
I had to copy the file from the reference location in the ML download to the bin directory after the build to get this to work... bother.