Git Product home page Git Product logo

Comments (8)

snnn avatar snnn commented on July 21, 2024 1

Very likely. Please see the solution above. You can use Visual Studio debugger to confirm that.

First please install the latest Visual Studio C++ Runtime from https://learn.microsoft.com/en-us/cpp/windows/latest-supported-vc-redist?view=msvc-170#latest-microsoft-visual-c-redistributable-version
Then, if you use conda, please also run

 conda install conda-forge::vs2015_runtime

from onnxruntime.

snnn avatar snnn commented on July 21, 2024

Likely it is because recently you upgrade your Visual Studio to 17.10.

Please tell us if you were using conda. If yes, you need to check if you have installed the "vs2015_runtime" package. If still yes, you need to use the following command to get a newer version from conda-forge.

 conda install conda-forge::vs2015_runtime

CPython(from python.org) does not have this issue.

You also need to install the latest VC++ runtime from https://learn.microsoft.com/en-us/cpp/windows/latest-supported-vc-redist?view=msvc-170. The latest version was released a few weeks ago. If you didn't reinstall it recently, please do so.

from onnxruntime.

snnn avatar snnn commented on July 21, 2024

If a C/C++ program was built by Visual Studio version X, then at runtime it will require VC++ Runtime version >=X, otherwise it may result undefined behavior. Recently Visual Studio introduced an ABI change for std::mutex in the latest 17.10 release, therefore if you run the new binary with old VC runtime it will crash.

VC runtime is a collection of DLLs. Mainly, it has three pieces:

  1. Universal CRT, which is a part of Windows 10. Before that, users need to manually install it. It is no longer a concern because most Windows users have upgraded to Windows 10 or 11.
  2. vcruntime[version].dll, which is the basic Runtime Library for C native code.
  3. msvcp[version].dll, which is the C++ Standard Library for C++ native code.

In order to get a simple C++ hello world program to run, you need all the three pieces. A C program only needs the top two. For example, python.exe itself is written in C. It doesn't contain any C++ code. So, in order to run python.exe, you need the Universal CRT and vcruntime[version].dll. So, if you open the folder where your python.exe lives, you will find a "vcruntime140.dll" there. The DLL was installed there when installing the python. The DLL is certainly old. Even if you have installed the latest VC Runtime, the old DLL will still get used since it has higher preference(because it is in the same dir as the executable: python.exe). However, it won't cause issue here. You will not find a msvcp140.dll there, since python.exe doesn't depend on that. And the C++ std::mutex change we are talking about is in msvcp140.dll, which is not part of python.

However, if your python is Conda and the python version is bigger than 3.8, I believe you will find msvcp140.dll in your conda's installation dir. I think it is brought by the "vs2015_runtime" package. And you can update the package by running:

 conda install conda-forge::vs2015_runtime

Not only python, JDKs usually also have this problem.

from onnxruntime.

snnn avatar snnn commented on July 21, 2024

To verify if the error("A dynamic link library (DLL) initialization routine failed.") you saw was caused by VC runtime version mismatch, you should check which msvcp140.dll was loaded. As you already have Visual Studio, you can get the information by debugging it there. In Visual Studio, you can open python.exe as a project.

image

Then right click the project, setup properties.

image

In the new Windows you can should set "arguments" to the full path of your python script , which should be as simple as just one line: "import onnxruntime".
Then you press "F5" to debug it.
In the debug windows you should be able to see the full path of msvcp140.dll . The log should contain things like:

'python.exe' (Win32): Loaded 'C:\hostedtoolcache\windows\Python\3.12.4\x64\Lib\site-packages\onnxruntime\capi\onnxruntime_pybind11_state.pyd'. 
'python.exe' (Win32): Loaded 'C:\Windows\System32\msvcp140.dll'. 

Then you find the DLL in File Explorer. Right click it, check its properties.

image

If the version number begins with 14.40, it's good. Otherwise, delete the DLL if it is not in system32 folder.

from onnxruntime.

srijanie03 avatar srijanie03 commented on July 21, 2024

Thank you for the detailed comments.

  1. Yes, I was using conda. I have updated the "vs2015_runtime" package.

  2. It seems like I have the latest release of vc++. I tried to re-install it and this is what I get :
    Screenshot 2024-06-19 163153

  3. I checked the msvcp140.dll file and seems like I have the correct one.
    Screenshot 2024-06-19 160613

I ran the build again and this time it didn't give me the error as it did before. It says 'build complete' but I still don't see the wheel file. What am I missing?

image

from onnxruntime.

snnn avatar snnn commented on July 21, 2024

You need to add one more "\RelWithDebInfo" in the path. Like D:\onnxruntime\build\Windows\RelWithDebInfo\RelWithDebInfo\dist

from onnxruntime.

srijanie03 avatar srijanie03 commented on July 21, 2024

Found the wheel file, thank you.

from onnxruntime.

azamet90 avatar azamet90 commented on July 21, 2024

ningDeprecationWarning: pytorch_lightning.utilities.distributed.rank_zero_only has been deprecated in v1.8.1 and will be removed in v2.0.0. You can import it from pytorch_lightning.utilities instead.
rank_zero_deprecation(
Launching Web UI with arguments: --use-zluda --update-check --skip-ort --disable-safe-unpickle
Traceback (most recent call last):
File "D:\yapay zeka\stable-diffusion-webui-amdgpu\launch.py", line 48, in
main()
File "D:\yapay zeka\stable-diffusion-webui-amdgpu\launch.py", line 44, in main
start()
File "D:\yapay zeka\stable-diffusion-webui-amdgpu\modules\launch_utils.py", line 689, in start
import webui
File "D:\yapay zeka\stable-diffusion-webui-amdgpu\webui.py", line 13, in
initialize.imports()
File "D:\yapay zeka\stable-diffusion-webui-amdgpu\modules\initialize.py", line 35, in imports
from modules import shared_init
File "D:\yapay zeka\stable-diffusion-webui-amdgpu\modules\shared_init.py", line 8, in
from modules.zluda import initialize_zluda
File "D:\yapay zeka\stable-diffusion-webui-amdgpu\modules\zluda.py", line 6, in
import onnxruntime as ort
File "D:\yapay zeka\stable-diffusion-webui-amdgpu\venv\lib\site-packages\onnxruntime_init_.py", line 57, in
raise import_capi_exception
File "D:\yapay zeka\stable-diffusion-webui-amdgpu\venv\lib\site-packages\onnxruntime_init_.py", line 23, in
from onnxruntime.capi._pybind_state import ExecutionMode # noqa: F401
File "D:\yapay zeka\stable-diffusion-webui-amdgpu\venv\lib\site-packages\onnxruntime\capi_pybind_state.py", line 32, in
from .onnxruntime_pybind11_state import * # noqa
ImportError: DLL load failed while importing onnxruntime_pybind11_state: A dynamic link library (DLL) initialization routine failed.

is it same on me? what do i have to do?

from onnxruntime.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.