Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using Azure Functions - Throws "Unable to load DLL 'CpuMathNative' or one of its dependencies: The specified module could not be found. (Exception from HRESULT: 0x8007007E)" exception. #274

Closed
athenasofty opened this issue Feb 23, 2019 · 9 comments

Comments

@athenasofty
Copy link

@athenasofty athenasofty commented Feb 23, 2019

No description provided.

@DevLob-zz

This comment has been minimized.

Copy link

@DevLob-zz DevLob-zz commented Feb 23, 2019

Please Open the package folder on your solution

and browse

\packages\Microsoft.ML.CpuMath.0.10.0\runtimes\win-x86\native

you will find it copy it to your bin folder should work

@CESARDELATORRE

This comment has been minimized.

Copy link
Contributor

@CESARDELATORRE CESARDELATORRE commented Mar 5, 2019

@athenasofty - Was your issue solved?

@prathyusha12345

This comment has been minimized.

Copy link
Contributor

@prathyusha12345 prathyusha12345 commented Mar 11, 2019

Closing since it is stale. Please, re-open if needed, ok?

@davidgristwood

This comment has been minimized.

Copy link

@davidgristwood davidgristwood commented Nov 15, 2019

I have this same issue. I am working through tutorial https://docs.microsoft.com/en-us/dotnet/machine-learning/how-to-guides/serve-model-serverless-azure-functions-ml-net

using netcoreapp2.1 and the Microsoft.ML.CpuMath.dll is in the bin directory

[15/11/2019 17:32:20] Executing HTTP request: {
[15/11/2019 17:32:20] "requestId": "06e71a6e-4386-4ff4-b334-ead4b50092ce",
[15/11/2019 17:32:20] "method": "POST",
[15/11/2019 17:32:20] "uri": "/api/AnalyzeSentiment"
[15/11/2019 17:32:20] }
[15/11/2019 17:32:21] Executing 'AnalyzeSentiment' (Reason='This function was programmatically called via the host APIs.', Id=626a9094-44f8-4584-a1bd-57f9a85c0e77)
[15/11/2019 17:32:21] C# HTTP trigger function processed a request.
[15/11/2019 17:32:22] Executed 'AnalyzeSentiment' (Failed, Id=626a9094-44f8-4584-a1bd-57f9a85c0e77)
[15/11/2019 17:32:22] System.Private.CoreLib: Exception while executing function: AnalyzeSentiment. Microsoft.ML.CpuMath: Unable to load DLL 'CpuMathNative' or one of its dependencies: The specified module could not be found. (Exception from HRESULT: 0x8007007E).
[15/11/2019 17:32:22] Executed HTTP request: {
[15/11/2019 17:32:22] "requestId": "06e71a6e-4386-4ff4-b334-ead4b50092ce",
[15/11/2019 17:32:22] "method": "POST",
[15/11/2019 17:32:22] "uri": "/api/AnalyzeSentiment",
[15/11/2019 17:32:22] "identities": [
[15/11/2019 17:32:22] {
[15/11/2019 17:32:22] "type": "WebJobsAuthLevel",
[15/11/2019 17:32:22] "level": "Admin"
[15/11/2019 17:32:22] }
[15/11/2019 17:32:22] ],
[15/11/2019 17:32:22] "status": 500,
[15/11/2019 17:32:22] "duration": 2019
[15/11/2019 17:32:22] }

any clues?

@CESARDELATORRE

This comment has been minimized.

Copy link
Contributor

@CESARDELATORRE CESARDELATORRE commented Nov 18, 2019

Azure Functions have an issue with the new improved implementation in ML.NET 1.4 GA. Until that bug is fixed in future Azure Functions (probably next release in Azure Functions), you need to use ML.NET 1.3.1 if you want to deploy the ML model in an AZURE FUNCTION.

Related issue in Azure Functions:
Azure/azure-functions-host#5187

If you are using 2.1, you need to publish a deps.json file. See the “PostBuild” stuff from Fabio below.

Note: you can work around this by using 3.0.

Here are the details:

Between ML.NET 1.3. and 1.4 we’ve updated our “CpuMath” package in order to support .NET Core 3.0. We are now taking advantage of the new C# Hardware Intrinsics (SIMD) APIs in .NET Core 3.0. In order to make that change, we had to refactor our NuGet package a bit, and that refactoring seems to break Azure Functions.

In 1.4, our native assembly has moved inside the NuGet package.

Before
runtimes\win-x64\native\CpuMathNative.dll
After
runtimes\win-x64\nativeassets\netstandard2.0\CpuMathNative.dll

This change was needed because we don’t need the native assembly when running on netcoreapp3.0. So taking advantage of the runtimes\{RID}\nativeassets\{TFM} functionality in NuGet allowed us to not ship an unnecessary native binary in the customer’s app. For more information on this support in NuGet, see NuGet/Home#2782.

When running an Azure Functions app, it isn’t handling the nativeassets folder correctly. Thus, the CpuMathNative assembly isn’t loaded, and the Azure Function fails.

This is currently blocking the new version of ML.NET (1.4 GA) from running in an Azure Function.


This additional issue could be related:
dotnet/machinelearning#4483

@CESARDELATORRE CESARDELATORRE changed the title On adding ML.NET package in my project and while running it throws "Unable to load DLL 'CpuMathNative' or one of its dependencies: The specified module could not be found. (Exception from HRESULT: 0x8007007E)" exception. Using Azure Functions - Throws "Unable to load DLL 'CpuMathNative' or one of its dependencies: The specified module could not be found. (Exception from HRESULT: 0x8007007E)" exception. Nov 18, 2019
@CESARDELATORRE

This comment has been minimized.

Copy link
Contributor

@CESARDELATORRE CESARDELATORRE commented Nov 18, 2019

Re-opening, although it is a different issue than the original, so I renamed it to the issue with Azure Functions.

@sustinel

This comment has been minimized.

Copy link

@sustinel sustinel commented Dec 4, 2019

It seems that the runtimes folder is in the root instead of being inside de bin folder. I moved it with kudu and it works perfectly.

@Veroni4ka

This comment has been minimized.

Copy link

@Veroni4ka Veroni4ka commented Jan 22, 2020

Any updates regarding this issue?

@luisquintanilla

This comment has been minimized.

Copy link
Contributor

@luisquintanilla luisquintanilla commented Mar 11, 2020

For Azure Functions, when working with .NET Core SDK 2.1, make sure to upgrade to the latest version (1.0.31+) of the Microsoft.NET.Sdk.Functions NuGet package. The issue should not occur when working with .NET Core SDK 3.1. If you run into the issue again, please feel free to open an issue again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

8 participants
You can’t perform that action at this time.