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

ImportError: cannot import name 'get_all_providers' from 'onnxruntime.capi._pybind_state' #4196

Closed
alex96295 opened this issue Jun 10, 2020 · 8 comments

Comments

@alex96295
Copy link

alex96295 commented Jun 10, 2020

Describe the bug
A clear and concise description of what the bug is.

I can't import onnxruntime; I had a look at the opened issues up to now, some were similar but I preferred to open a new one.

Urgency
If there are particular important use cases blocked by this or strict project-related timelines, please share more information and dates. If there are no hard deadlines, please specify none.

Quite urgent

System information

  • OS Platform and Distribution (e.g., Linux Ubuntu 16.04): Windows 10
  • ONNX Runtime installed from (source or binary): difference between source and binary?
  • ONNX Runtime version: 1.3.0
  • Python version: 3.7.6
  • Visual Studio version (if applicable): 2015-2019 Redistributable (x64 and x86)
  • GCC/Compiler version (if compiling from source):
  • CUDA/cuDNN version: don't have GPU, should I install CUDA the same?
  • GPU model and memory: don't have

To Reproduce

  • Describe steps/code to reproduce the behavior.
  • Attach the ONNX model to the issue (where applicable) to expedite investigation.

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

Error logs:

C:\Users\Alessandro\Anaconda3\envs\ale96\lib\site-packages\onnxruntime\capi\_pybind_state.py:13: UserWarning: Cannot load onnxruntime.capi. Error: 'DLL load failed: Impossibile trovare il modulo specificato.'
  warnings.warn("Cannot load onnxruntime.capi. Error: '{0}'".format(str(e)))
Traceback (most recent call last):
  File "C:/Users/Alessandro/PycharmProjects/mobilenetv2_squeezedet_lattice/test_clean_onnx_sample.py", line 57, in <module>
    import onnxruntime
  File "C:\Users\Alessandro\Anaconda3\envs\ale96\lib\site-packages\onnxruntime\__init__.py", line 12, in <module>
    from onnxruntime.capi._pybind_state import get_all_providers, get_available_providers, get_device, set_seed, RunOptions, SessionOptions, set_default_logger_severity, NodeArg, ModelMetadata, GraphOptimizationLevel, ExecutionMode, OrtDevice, SessionIOBinding
ImportError: cannot import name 'get_all_providers' from 'onnxruntime.capi._pybind_state' (C:\Users\Alessandro\Anaconda3\envs\ale96\lib\site-packages\onnxruntime\capi\_pybind_state.py)

Additional context
Add any other context about the problem here. If the issue is about a particular model, please share the model details as well to facilitate debugging.

@hariharans29
Copy link
Member

Which platform are you on ? Do you have the GPU package installed ? Have you installed CUDA/CuDNN (please see system requirements) ?

P.S. Filling out the GitHub issue template completely would help (it is missing important details like system info)

@alex96295
Copy link
Author

@hariharans29 thank you for the reply

I have edited the comment, putting the system information. What do you mean by source/binary? I used the pip command to install it
Moreover, I installed Visual Studio redistributable as indicated
And also changed the locale, but I didn't understand what I have to do about the language, do you mean the system languange has to be switched to English?

And about Cuda, I don't have a GPU, so should I install it the same?

@tianleiwu
Copy link
Contributor

tianleiwu commented Jun 12, 2020

@alex96295, please run the following commands for CPU only version:
pip uninstall --yes ort_nightly
pip uninstall --yes ort_gpu_nightly
pip uninstall --yes onnxruntime
pip uninstall --yes onnxruntime-gpu
pip install onnxruntime

Install latest VC 2019 Runtime here: https://support.microsoft.com/en-us/help/2977003/the-latest-supported-visual-c-downloads

@alex96295
Copy link
Author

@tianleiwu ok I did it, now onnx is imported correctly also on Windows. On Linux, it worked immediately since there are GPUs in the server of the University that I use, I think that I shouldn't have installed onnxruntime-gpu not having one on Windows, right?

@hariharans29
Copy link
Member

Glad it worked.

You probably had onnxruntime_gpu installed first (it would expect CUDA dlls which were probably missing) or probably you had onnxruntime installed but the VCRuntime was missing. Please just use onnxruntime (and not onnxruntime_gpu) on any hardware that doesn't support using CUDA.

@yaochx
Copy link

yaochx commented Nov 1, 2020

macos users can try
brew install libomp
linux users can try
sudo apt install libgomp1

@iperov
Copy link
Contributor

iperov commented Mar 8, 2021

OS Platform and Distribution (e.g., Linux Ubuntu 16.04): Windows 10

use microsoft process monitor
add filter python.exe and .dll files
run your program
check what DLL's were requested by python and not loaded

@sitting-duck
Copy link

sitting-duck commented Mar 27, 2021

Here is a link to a tutorial I wrote for how I fixed this on Windows 10 with Python 3.7.
I basically installed the Cuda toolkit and the CuDNN libraries to fix this issue.

The onnx runtime website shows how to install with pip install onnxruntime for CPU and pip install onnxruntime-gpu for CUDA support, but I think a lot of people fall into a gotcha because the OnnxRuntime site assumes you have all CUDA prereqs installed already and doesn't clearly list these on their website.

The tutorial is in written form with screencaps and also links to a video to show proof of fix as well.
Please feel free to leave comments here or on my medium if the solution does not work for you as I do check back and make fixes based on feedback. Thanks.
https://ashley-tharp.medium.com/install-onnxruntime-on-windows-2ad5ed8f4a50

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

6 participants