Skip to content

[Performance] ONNX runtime is not able to load on machines running lower VC runtime libraries #26599

@savellan

Description

@savellan

Describe the issue

I have spent several hours trying to figure why the ONNX runtime does not load the dlls while creating Inference session.
It turned out that the msvcp and vc runtime dlls I have been packaging are slightly older (14.22) while what ONNX runs successfully is 14.40.
What is the minimal vc runtime library that ONNX requires?

Also, it would be helpful to know that these are incompatible since the errors I have seen were not clear enough to understand what is causing the dll to not load.

To reproduce

Run ONNX Inference session creation with lower versions of msvcp and vc runtime. It would say ONNX dll load is failing.
It would throw below exception:msvcp140!mtx_do_lock+0x74 [d:\agent_work\2\s\src\vctools\crt\crtw32\stdcpp\thr\mutex.c @ 102]
onnxruntime+0x5cd1
onnxruntime+0x105c1
onnxruntime+0x10636
ucrtbase!_initterm+0x2d [minkernel\crts\ucrt\src\appcrt\startup\initterm.cpp @ 16]
onnxruntime+0x95761a
onnxruntime+0x957787
ntdll!LdrpCallInitRoutine+0x6b [minkernel\ntdll\ldr.c @ 225]
ntdll!LdrpInitializeNode+0x1ca [minkernel\ntdll\ldrsnap.c @ 1445]
ntdll!LdrpInitializeGraphRecurse+0x42 [minkernel\ntdll\ldrddag.c @ 1758]
ntdll!LdrpInitializeGraph+0x19 [minkernel\ntdll\ldrddag.c @ 1777]
ntdll!LdrpPrepareModuleForExecution+0xbf [minkernel\ntdll\ldrsnap.c @ 2626]
ntdll!LdrpLoadDllInternal+0x2f1 [minkernel\ntdll\ldrapi.c @ 1149]
ntdll!LdrpLoadDll+0xb0 [minkernel\ntdll\ldrapi.c @ 1403]
ntdll!LdrLoadDll+0x106 [minkernel\ntdll\ldrapi.c @ 626]
KERNELBASE!LoadLibraryExW+0x172 [minkernel\kernelbase\module.c @ 1235]
clr!CLRLoadLibraryExWorker+0x54 [f:\dd\ndp\clr\src\vm\util.cpp @ 2771]
clr!CLRLoadLibraryEx+0x51 [f:\dd\ndp\clr\src\vm\util.cpp @ 2791]
clr!LocalLoadLibraryHelper+0x31 [f:\dd\ndp\clr\src\vm\dllimport.cpp @ 6613]
clr!NDirect::LoadLibraryModule+0x404 [f:\dd\ndp\clr\src\vm\dllimport.cpp @ 7000]
clr!NDirect::NDirectLink+0x80 [f:\dd\ndp\clr\src\vm\dllimport.cpp @ 7176]
clr!NDirect::GetStubForILStub+0x4b [f:\dd\ndp\clr\src\vm\dllimport.cpp @ 5888]
clr!GetStubForInteropMethod+0x65 [f:\dd\ndp\clr\src\vm\dllimport.cpp @ 6019]
clr!MethodDesc::DoPrestub+0xc0d [f:\dd\ndp\clr\src\vm\prestub.cpp @ 1522]
clr!PreStubWorker+0x3cc [f:\dd\ndp\clr\src\vm\prestub.cpp @ 1020]
clr!ThePreStub+0x55 [f:\dd\ndp\clr\src\vm\amd64\ThePreStubAMD64.asm @ 18]
Microsoft_ML_OnnxRuntime!Microsoft.ML.OnnxRuntime.NativeMethods..cctor+0x2e
clr!CallDescrWorkerInternal+0x83 [f:\dd\ndp\clr\src\vm\amd64\CallDescrWorkerAMD64.asm @ 97]
clr!CallDescrWorkerWithHandler+0x4e [f:\dd\ndp\clr\src\vm\callhelpers.cpp @ 89]
clr!DispatchCallDebuggerWrapper+0x1f [f:\dd\ndp\clr\src\vm\callhelpers.cpp @ 183]
clr!DispatchCallSimple+0x93 [f:\dd\ndp\clr\src\vm\callhelpers.cpp @ 238]
clr!MethodTable::RunClassInitEx+0x111 [f:\dd\ndp\clr\src\vm\methodtable.cpp @ 3269]
clr!MethodTable::DoRunClassInitThrowing+0x353 [f:\dd\ndp\clr\src\vm\methodtable.cpp @ 3501]
clr!MethodTable::CheckRunClassInitThrowing+0xb0 [f:\dd\ndp\clr\src\vm\methodtable.cpp @ 3659]
clr!JIT_GetSharedNonGCStaticBase_Helper+0xcd [f:\dd\ndp\clr\src\vm\jithelpers.cpp @ 1551]
Microsoft_ML_OnnxRuntime!Microsoft.ML.OnnxRuntime.SessionOptions..ctor+0x89

Urgency

No response

Platform

Windows

OS Version

N/A

ONNX Runtime Installation

Built from Source

ONNX Runtime Version or Commit ID

1.22.1

ONNX Runtime API

C#

Architecture

X64

Execution Provider

TensorRT

Execution Provider Library Version

9.0.0

Model File

No response

Is this a quantized model?

Yes

Metadata

Metadata

Assignees

No one assigned

    Labels

    api:CSharpissues related to the C# APIperformanceissues related to performance regressions

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions