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

Created on 11 Jun 2020  路  6Comments  路  Source: microsoft/onnxruntime

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.

Most helpful comment

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

All 6 comments

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)

@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?

@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

@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?

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.

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

Was this page helpful?
0 / 5 - 0 ratings