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

Unable to use any OnnxRuntime packages >1.7 with CMake #11230

Closed
aravindyeduvaka opened this issue Apr 15, 2022 · 17 comments
Closed

Unable to use any OnnxRuntime packages >1.7 with CMake #11230

aravindyeduvaka opened this issue Apr 15, 2022 · 17 comments

Comments

@aravindyeduvaka
Copy link
Member

aravindyeduvaka commented Apr 15, 2022

Describe the bug
I am using the prebuilt binaries from Github release to setup OnnxRuntime with a CMake Project. However, I am unable to use any version higher than 7. I get the following error:
"The given version [8] is not supported, only version 1 to 7 is supported in this build="
Same with any other releases including 9,10 and 11.

System information

  • OS Platform and Distribution (e.g., Linux Ubuntu 16.04): Windows 11
  • ONNX Runtime installed from (source or binary): Prebuilt Binaries
  • ONNX Runtime version: 1.8 to 1.11
  • Python version: -
  • Visual Studio version (if applicable): 16.11.12
  • GCC/Compiler version (if compiling from source):
  • CUDA/cuDNN version:
  • GPU model and memory:

To Reproduce

  • Describe steps/code to reproduce the behavior.
    (I setup a very bare bones CMake project that repros this issues. https://github.com/aravindyeduvaka/OnnxCMake )
    Setup a new CMake Projects that downloads the prebuilt binary and links it to the target executable.
    When running the project, it throws an error complaining about the version
    "The given version [10] is not supported, only version 1 to 7 is supported in this build"
    The sample does work with version 7 so something changed between 7 and 8 that is not supported for CMake projects

  • Attach the ONNX model to the issue (where applicable) to expedite investigation.
    This error is thrown when creating the environment so the actual model that we are loading is irrelevant.

Expected behavior
I would expect this should work since its a very basic setup with prebuilt binaries. Is the support for CMake discontinued since version 8?

@snnn
Copy link
Member

snnn commented Apr 16, 2022

Sorry I can't reproduce the problem. Very likely you loaded a wrong onnxruntime.dll (just my guessing).

To debug it. I recommend using windbg and enable loader snaps. Here is one example: #4009 (comment)

When you get it enabled, you will see where onnxruntime.dll was loaded from. Please check the path. Is it the one which was just downloaded by cmake? I suspect on that.

@aravindyeduvaka
Copy link
Member Author

aravindyeduvaka commented Apr 16, 2022

Thank you for helping with this.
I am pretty sure we are loading the right dll since I manually link the dependency into the CMake project and I do not encounter any issue when I use version 1.7 but only see errors at runtime when using any higher versions.

I setup the CMake dependency using FetchDeclareContent automatically and the links are from the github relelase. Here's the line where this is done. https://github.com/aravindyeduvaka/OnnxCMake/blob/77b85611098dd27cff01da96e039bd637634f9b3/CMakeLists.txt#L16

@snnn
Copy link
Member

snnn commented Apr 16, 2022

Have you tried windbg?

@WilliamVenner
Copy link

I am also getting this. I downloaded version 1.11 of the GPU runtime from https://www.nuget.org/packages/Microsoft.ML.OnnxRuntime.gpu and linked against runtimes/win-x64/native/*.[dll|lib] and included the build/native/include/* headers in my program, yet I get:

The given version [11] is not supported, only version 1 to 7 is supported in this build.

@WilliamVenner
Copy link

Oh my god it's loading 1.7.0 from System32

This must be a Windows 11 thing

image

@snnn
Copy link
Member

snnn commented Apr 18, 2022

That's the problem.

@snnn snnn closed this as completed Apr 18, 2022
@snnn
Copy link
Member

snnn commented Apr 18, 2022

For more information, please read: https://docs.microsoft.com/en-us/windows/win32/dlls/dynamic-link-library-search-order

The Standard Search Order for Desktop Applications starts with the directory from which the application loaded. i.e. where your main executable(*.exe) lives. So, please copy onnxruntime.dll there.

@snnn snnn mentioned this issue Nov 10, 2022
@yuslepukhin
Copy link
Member

Do not load System32 copy of onnxruntime.dll

@tildekarthik
Copy link

I am not an expert in dotnet or CPP but here is what solved the problem - I installed Visual C++ runtime for x64 (Server was Xeon running Windows 2016 server 64 bit)

solved the problem for me

@smaslov-intel
Copy link

@snnn, we are hitting a similar issue now. It's certainly not OK to have a system library to print something if loaded, but not used. Are you going to fix that?

@snnn
Copy link
Member

snnn commented Aug 11, 2023

@smaslov-intel, I'm looking into it.

@smaslov-intel
Copy link

@smaslov-intel, surely. I will fix what is certainly not OK. Feel free to create an issue to tell me what you want me to fix, and assign it to me. I would be happy to help.

This issue is exactly about what is wrong: the system's onnxruntime.dll is printing out the

"The given version [X] is not supported, only version 1 to Y is supported in this build."

Please also consider renaming the system's version to something else than onnxruntime.dll since many users are going to be affected by this due to obscure DLL search rules in Windows.

@wenkaiH
Copy link

wenkaiH commented Oct 13, 2023

@smaslov-intel, surely. I will fix what is certainly not OK. Feel free to create an issue to tell me what you want me to fix, and assign it to me. I would be happy to help.

This issue is exactly about what is wrong: the system's onnxruntime.dll is printing out the

"The given version [X] is not supported, only version 1 to Y is supported in this build."

Please also consider renaming the system's version to something else than onnxruntime.dll since many users are going to be affected by this due to obscure DLL search rules in Windows.

same problem on Linux!!!

@Sencc
Copy link

Sencc commented Jan 12, 2024

@wenkaiH Hi,have you solved it?

@snnn
Copy link
Member

snnn commented Jan 12, 2024

@wenkaiH , which Linux version do you have? Do you have multiple libonnxruntime.so in your system?

@ShubhamSaini01
Copy link

any movement on this?

@smaslov-intel, surely. I will fix what is certainly not OK. Feel free to create an issue to tell me what you want me to fix, and assign it to me. I would be happy to help.

This issue is exactly about what is wrong: the system's onnxruntime.dll is printing out the

"The given version [X] is not supported, only version 1 to Y is supported in this build."

Please also consider renaming the system's version to something else than onnxruntime.dll since many users are going to be affected by this due to obscure DLL search rules in Windows.

any movement on this? I'm using 1.17.1 and facing same problem.

@gabriellanzer
Copy link

gabriellanzer commented Aug 16, 2024

any movement on this? I'm using 1.17.1 and facing same problem.

@ShubhamSaini01 Copying the right DLL to your binary location should fix the problem. I have an xmake project using 1.17.1 and I was facing this issue and all I had to do was to setup a small post-build step to copy the files over. Like so:

    -- Copy the ONNX Runtime DLL to the target directory after build
    after_build(function (target)
	print("Copying ONNX Runtime DLLs to target directory")
        local onnxruntime_dir = path.join(target:pkg("onnxruntime"):installdir(), "bin")
        local dll_files = os.files(path.join(onnxruntime_dir, "*.dll"))
        for _, dll in ipairs(dll_files) do
            os.cp(dll, target:targetdir())
        end
    end)

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

No branches or pull requests

10 participants