Skip to content

Microsoft.ML NuGet package doesn't work with packages.config #93

Closed

Description

@guivo

Original Title

Impossible to run Iris classification test

System information

  • OS version/distro:
    Windows 10.0.17134
  • .NET Version (eg., dotnet --info):
    Product Information:
    Version: 2.1.200
    Commit SHA-1 hash: 2edba8d7f1

Issue

  • What did you do?
    Try Iris tutorial

  • What happened?
    Runtime error:

System.Reflection.TargetInvocationException
HResult=0x80131604
Message=Eccezione generata dalla destinazione di una chiamata.
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 IrsiExample.Program.Main(String[] args) in C:\Users\gvolpi\source\repos\MLNetTest1\IrsiExample\Program.cs:line 69

Inner Exception 1:
TargetInvocationException: Eccezione generata dalla destinazione di una chiamata.

Inner Exception 2:
DllNotFoundException: Impossibile caricare la DLL 'CpuMathNative': Impossibile trovare il modulo specificato. (Eccezione da HRESULT: 0x8007007E).

  • What did you expect?

Source code / logs

Code copy/pasted from github

Activity

  1. eerhardt commented on May 9, 2018

    @eerhardt
    Member

    Hi @guivo,

    Can you give some more insight in how you referenced ML.NET? Did you use a <PackageReference Include="Microsoft.ML" Version="0.1.0" /> in your .csproj?

    Are you on the desktop .NET Framework? If so, you need to switch your project to be built for x64 architecture. Currently, ML.NET only supports x64 processes since we have some C++ native code (the "CpuMathNative" assembly from above) and are only building it for x64 currently.

  2. removed
    bugSomething isn't working
    on May 9, 2018
  3. guivo commented on May 9, 2018

    @guivo
    Author

    Hi @eerhardt , I have done the test creating a desktop C# project for a CLI application. I have then inluded Microsoft.ML using NuGet and the csproj is slightly different but I am not sure this is relevant:

    <Reference Include="Microsoft.ML, Version=1.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL"> <HintPath>..\packages\Microsoft.ML.0.1.0\lib\netstandard2.0\Microsoft.ML.dll</HintPath> </Reference>

    More lines are there, to refence other ML modules (Api, Core, CpuMath....)

    I can confirm that I am targeting x64 (visual studio fails if try a different architecture).

  4. glebuk commented on May 9, 2018

    @glebuk
    Contributor

    @guivo, Thanks for checking. Looks like the process fails to find the cpuMathNative.dll. Can you check that the file is in the same location as other managed DLLs and the exe? If it is not in the target directory, then it's likely a problem with our NuGet definition. To unblock yourself, you can copy that file there manually for now.

    Regards.

  5. eerhardt commented on May 9, 2018

    @eerhardt
    Member

    @guivo - I get your issue now. The problem is that you are using packages.config. Can you switch it to use <PackageReference> instead? This blog shows how easy it is to switch:

    https://blog.nuget.org/20180409/migrate-packages-config-to-package-reference.html

    You can also make PackageReference your default experience in VS following this blog.

  6. changed the title [-]Impossible to run Iris classification test[/-] [+]Microsoft.ML NuGet package doesn't work with packages.config[/+] on May 9, 2018
  7. eerhardt commented on May 9, 2018

    @eerhardt
    Member

    Renaming the issue to best reflect the problem.

    Guidance from the NuGet team is:

    Packages.config doesn’t support native assets in runtimes\RID,
    folks typically write targets to deal with this.
    For an example look at https://www.nuget.org/packages/Microsoft.DiaSymReader.Native/1.7.0.

  8. guivo commented on May 11, 2018

    @guivo
    Author

    @eerhardt migrating to PackageReference fixed the issue, thanks!

    Should I however expect a more flexible approach in the next release of the package?

  9. eerhardt commented on May 11, 2018

    @eerhardt
    Member

    I haven't tried getting it to work, but it seems simple enough to fix Microsoft.ML to work with packages.config. So I'd hope we can fix it in the next release.

  10. self-assigned this
    on May 14, 2018
  11. added a commit that references this issue on May 15, 2018
    eef01a9
  12. guivo commented on May 16, 2018

    @guivo
    Author

    With regard to this thread, I would to mention that in the case a solution with 3 projects, the recipe I have used (Migrating to PackageReference) didn't have positive effect in the last project. Where the migration seemed successful but the runtime error about not finding CpuMathNative appears.

    Same code, in a solution with only that project, everything worked.

  13. eerhardt commented on May 16, 2018

    @eerhardt
    Member

    @guivo - if you could share a .zip (or push to a repo) of a solution that reproduces the issue, I can take a look.

    BTW - #165 will fix this issue and allow ML.NET to work with packages.config. So the next release won't require PackageReference.

  14. 6 remaining items

  15. added a commit that references this issue on Nov 11, 2019
    0ef7654
  16. added a commit that references this issue on Nov 13, 2019
    5e83e23
  17. added a commit that references this issue on Nov 14, 2019
    f0a9163
  18. samcode22 commented on Nov 17, 2019

    @samcode22

    The 1st Workaround was not alllowed so tried 2nd adding the code in .csproj but no effect.In Packages folder CpuMathNative.dll is seen but still the error continues.Dont know why it is not able to find.

  19. added 2 commits that reference this issue on Dec 2, 2019
    0d49e9c
    d9584cf
  20. coderdipti commented on Dec 19, 2019

    @coderdipti

    I am getting the same error but on different scenario. I have 2 input fields one is string and one is int/float. If I am setting only text attribute to my model it is working fine, but when I set int its giving that Microsoft.ML.CpuMathNatiive.dll not loaded error. I am running on x64 mode using ML 1.4.0
    Please suggest and provide sample code.

    I am trying to consume this model in a service and getting this error.

  21. coderdipti commented on Dec 19, 2019

    @coderdipti

    @samcode22 Is your issue solved?

  22. eerhardt commented on Jan 2, 2020

    @eerhardt
    Member

    @coderdipti - can you try with the latest pre-release version of ML.NET? https://www.nuget.org/packages/Microsoft.ML/1.5.0-preview. If that doesn't fix your issue, please open a new issue to track it with full repro steps - https://github.com/dotnet/machinelearning/issues/new

  23. hamdidamar commented on Apr 19, 2020

    @hamdidamar

    I think the problem will be solved in the next version, temporarily type
    --" Install-Package Microsoft.ML -Version 1.5.0-preview "--
    and run it in the package manager

  24. cemilsavtekin commented on Oct 2, 2020

    @cemilsavtekin

    Hi everyone
    I get this error when publish to iis but it works in debug on vs.
    I used CpuMathNative 1.5.2
    @eerhardt

  25. eerhardt commented on Oct 2, 2020

    @eerhardt
    Member

    @cemilsavtekin - this issue is quite old. Could you open an new issue with as much information as you can? Useful information would be:

    • A link to your project, or your .csproj
    • The steps you took to encounter the error
    • The error message
  26. ghost locked as resolved and limited conversation to collaborators on Mar 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions