Skip to content

System.DllNotFoundException: Unable to load DLL 'CpuMathNative' #333

Closed

Description

@prisar

System information

  • OS version/distro: Windows Server 2016 Standard
  • .NET Version (eg., dotnet --info): Core 2.0

Issue

  • What did you do?
    When trying to load model from a file var model = PredictionModel.ReadAsync<IrisData, IrisPrediction>(modelPath).Result; gives DllNotFoundException while running in windows container.
  • What happened?
    Internal Server Error
  • What did you expect?
    Model should be loaded in model variable.

Source code / logs

System.DllNotFoundException: Unable to load DLL 'CpuMathNative': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
   at Microsoft.ML.Runtime.Internal.CpuMath.Thunk.DotU(Single* pa, Single* pb, Int32 c)
   at Microsoft.ML.Runtime.Internal
1000
.CpuMath.SseUtils.DotProductDense(Single[] a, Single[] b, Int32 count)
   at Microsoft.ML.Runtime.Learners.MulticlassLogisticRegressionPredictor.PredictCore(VBuffer`1& src, Single[]& dst)
   at Microsoft.ML.Runtime.Learners.MulticlassLogisticRegressionPredictor.<GetMapper>b__30_0[TSrc,TDst](VBuffer`1& src, VBuffer`1& dst)
   at Microsoft.ML.Runtime.Data.PredictedLabelScorerBase.EnsureCachedPosition[TScore](Int64& cachedPosition, TScore& score, IRow boundRow, ValueGetter`1 scoreGetter)
   at Microsoft.ML.Runtime.Data.MultiClassClassifierScorer.<>c__DisplayClass14_0.<GetPredictedLabelGetter>b__0(UInt32& dst)
   at Microsoft.ML.Runtime.Data.KeyToValueTransform.KeyToValueMap`2.<>c__DisplayClass7_0.<GetMappingGetter>b__0(TValue& dst)
   at Microsoft.ML.Runtime.Data.DataViewUtils.Splitter.Consolidator.<>c__DisplayClass4_1.<ConsolidateCore>b__2()

```Please paste or attach the code or logs or traces that would be helpful to diagnose the issue you are reporting.

Activity

  1. jusso-dev commented on Jun 10, 2018

    @jusso-dev

    Change your project to compile to 64x, CpuMathNative is a 64x run time dependant library

  2. chrismckelt commented on Jun 22, 2018

    @chrismckelt

    Did you run build.cmd before running it? I got this issue & needed to pull the solution down again & rerun build.cmd to be able to correctly build the solution

  3. jusso-dev commented on Jun 23, 2018

    @jusso-dev

    That's probably solving the same issue. If building the project outside of a 64x runtime it won't work, point blank.

  4. chrismckelt commented on Jun 25, 2018

    @chrismckelt

    An AnyCPU assembly will JIT to 64 bit code when loaded into a 64 bit process and 32 bit when loaded into a 32 bit process so no need to change I think - I had this on Windows Server 2016 Standard & reinstalled the tools & all was good

  5. PaulDMendoza commented on Aug 29, 2018

    @PaulDMendoza

    I'm getting something similar with .NET Core 2.1 when trying to run unit tests but changing the project force x64 doesn't seem to work. See stack trace below.

    I'm using "dotnet test" to run this.

    Environment

    C:\BuildAgent\work\50915b32e326b397\Testing\DragnetTech.EmailParsing.Tests>dotnet --info
    .NET Core SDK (reflecting any global.json):
     Version:   2.1.300
     Commit:    adab45bf0c
    
    Runtime Environment:
     OS Name:     Windows
     OS Version:  10.0.14393
     OS Platform: Windows
     RID:         win10-x64
     Base Path:   C:\Program Files\dotnet\sdk\2.1.300\
    
    Host (useful for support):
      Version: 2.1.0
      Commit:  caa7b7e2ba
    
    .NET Core SDKs installed:
      2.1.101 [C:\Program Files\dotnet\sdk]
      2.1.300 [C:\Program Files\dotnet\sdk]
    
    .NET Core runtimes installed:
      Microsoft.AspNetCore.All 2.1.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
      Microsoft.AspNetCore.App 2.1.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
      Microsoft.NETCore.App 2.0.6 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
      Microsoft.NETCore.App 2.1.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
    
    To install additional .NET Core runtimes or SDKs:
      https://aka.ms/dotnet-download
    

    Here is the stack trace.

     Test method DragnetTech.EmailParsing.Tests.EmailProcessingTests.MineEmail_GoToMeeting3 threw exception:
    System.InvalidOperationException: Splitter/consolidator worker encountered exception while consuming source data ---> System.DllNotFoundException: Unable to load DLL 'CpuMathNative' or one of its dependencies: The specified module could not be found. (Exception from HRESULT: 0x8007007E)
    Stack Trace:
        at Microsoft.ML.Runtime.Internal.CpuMath.Thunk.SumSqU(Single* ps, Int32 c)
       at Microsoft.ML.Runtime.Data.LpNormNormalizerTransform.<>c__DisplayClass27_0.<GetGetterCore>b__5(VBuffer`1& dst)
       at Microsoft.ML.Runtime.Data.ConcatTransform.<>c__DisplayClass36_0`1.<MakeGetter>b__0(VBuffer`1& dst)
       at Microsoft.ML.Runtime.Data.SchemaBindablePredictorWrapperBase.<>c__DisplayClass16_0`2.<GetValueGetter>b__0(TDst& dst)
       at Microsoft.ML.Runtime.Data.DataViewUtils.Splitter.Consolidator.<>c__DisplayClass4_1.<ConsolidateCore>b__2()
    --- End of inner exception stack trace ---
        at Microsoft.ML.Runtime.Data.DataViewUtils.Splitter.Batch.SetAll(OutPipe[] pipes)
       at Microsoft.ML.Runtime.Data.DataViewUtils.Splitter.Cursor.MoveNextCore()
       at Microsoft.ML.Runtime.Data.RootCursorBase.MoveNext()
       at Microsoft.ML.Runtime.Api.PipeEngine`1.RunPipe(Boolean reuseRowObject)+MoveNext()
       at Microsoft.ML.PredictionModel`2.Predict(TInput input)
       at DragnetTech.EmailParsing.ML.Predictors.PredictLanguageName(String text) in C:\BuildAgent\work\50915b32e326b397\Functions\DragnetTech.EmailParsing\ML\Predictors.cs:line 45
       at DragnetTech.EmailParsing.EmailParser.<>c__DisplayClass2_3.<ProcessEmailBodySections>b__9(ILanguage l) in C:\BuildAgent\work\50915b32e326b397\Functions\DragnetTech.EmailParsing\EmailParser.cs:line 233
    
    
  6. PaulDMendoza commented on Aug 29, 2018

    @PaulDMendoza

    Actually, this issue/comment resolved my problem. Had to install the Visual Studio C++ update.

    #605 (comment)

  7. Ivanidzo4ka commented on Oct 18, 2018

    @Ivanidzo4ka
    Contributor

    DRI RESPONSE: This issue looks like answered. I'm planning to close it within few days, if no one object to that.

  8. Finansnet commented on Nov 18, 2018

    @Finansnet

    In my case problem was on some particular machines. The same application was working fine on development ones, but did not work on production environment. Problem was solved by installing Visual C++ Redistributable 2017 on production server.

    Marek

  9. added a commit that references this issue on Aug 22, 2019
  10. samcode22 commented on Nov 16, 2019

    @samcode22

    Exception thrown: 'System.DllNotFoundException' in Microsoft.ML.CpuMath.dll
    An exception of type 'System.DllNotFoundException' occurred in Microsoft.ML.CpuMath.dll but was not handled in user code
    Unable to load DLL 'CpuMathNative': The specified module could not be found. (Exception from HRESULT: 0x8007007E)

    Trying to implement sentimental analysis on comments in ASP.NET MVC Web Application(.NET Framework) although it is seen in solution explorer..and have kept solution platform as AnyCPU.Also tried x86 and x64 but no change.
    The error is pointing at this line:
    ModelOutput result = predEngine.Predict(input);

  11. ArnieBerg commented on Mar 14, 2020

    @ArnieBerg

    See #4870.

  12. ghost locked as resolved and limited conversation to collaborators on Mar 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions