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' #109

Open
glenn-jocher opened this issue Dec 22, 2020 · 6 comments

Comments

@glenn-jocher
Copy link

glenn-jocher commented Dec 22, 2020

Unable to import onnxsim after pip install onnx-simplifier with Python 3.8.0. We are attempting to integrate it into our YOLOv5 ONNX export workflow ultralytics/yolov5#1597

Input:

import onnxsim

Output:

/Users/glennjocher/PycharmProjects/yolov5-export/venv/lib/python3.8/site-packages/onnxruntime/capi/_pybind_state.py:14: UserWarning: Cannot load onnxruntime.capi. Error: 'dlopen(/Users/glennjocher/PycharmProjects/yolov5-export/venv/lib/python3.8/site-packages/onnxruntime/capi/onnxruntime_pybind11_state.so, 2): Library not loaded: /usr/local/opt/libomp/lib/libomp.dylib
  Referenced from: /Users/glennjocher/PycharmProjects/yolov5-export/venv/lib/python3.8/site-packages/onnxruntime/capi/onnxruntime_pybind11_state.so
  Reason: image not found'.
  warnings.warn("Cannot load onnxruntime.capi. Error: '{0}'.".format(str(e)))
Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "/Users/glennjocher/Library/Application Support/JetBrains/Toolbox/apps/PyCharm-C/ch-0/203.5981.165/PyCharm CE.app/Contents/plugins/python-ce/helpers/pydev/_pydev_bundle/pydev_import_hook.py", line 21, in do_import
    module = self._system_import(name, *args, **kwargs)
  File "/Users/glennjocher/PycharmProjects/yolov5-export/venv/lib/python3.8/site-packages/onnxsim/__init__.py", line 1, in <module>
    from onnxsim.onnx_simplifier import simplify
  File "/Users/glennjocher/Library/Application Support/JetBrains/Toolbox/apps/PyCharm-C/ch-0/203.5981.165/PyCharm CE.app/Contents/plugins/python-ce/helpers/pydev/_pydev_bundle/pydev_import_hook.py", line 21, in do_import
    module = self._system_import(name, *args, **kwargs)
  File "/Users/glennjocher/PycharmProjects/yolov5-export/venv/lib/python3.8/site-packages/onnxsim/onnx_simplifier.py", line 10, in <module>
    import onnxruntime as rt  # type: ignore
  File "/Users/glennjocher/Library/Application Support/JetBrains/Toolbox/apps/PyCharm-C/ch-0/203.5981.165/PyCharm CE.app/Contents/plugins/python-ce/helpers/pydev/_pydev_bundle/pydev_import_hook.py", line 21, in do_import
    module = self._system_import(name, *args, **kwargs)
  File "/Users/glennjocher/PycharmProjects/yolov5-export/venv/lib/python3.8/site-packages/onnxruntime/__init__.py", line 13, in <module>
    from onnxruntime.capi._pybind_state import get_all_providers, get_available_providers, get_device, set_seed, \
ImportError: cannot import name 'get_all_providers' from 'onnxruntime.capi._pybind_state' (/Users/glennjocher/PycharmProjects/yolov5-export/venv/lib/python3.8/site-packages/onnxruntime/capi/_pybind_state.py)

Screen Shot 2020-12-22 at 3 23 20 PM

@daquexian
Copy link
Owner

Thanks for your issue!

It looks like openmp is missing: "Library not loaded: /usr/local/opt/libomp/lib/libomp.dylib". After googling I find it is a prerequisite of onnxruntime on macos: https://www.onnxruntime.ai/docs/get-started/install.html.

Could you please run brew install libomp and try again?

Thanks!

@daquexian
Copy link
Owner

The latest onnx-simplifier depends on onnxruntime-noopenmp instead of onnxruntime so that openmp is not needed anymore :D

@daquexian
Copy link
Owner

It's so bad that onnxruntime-noopenmp doesn't have a macos version :| Reverted

@daquexian daquexian reopened this Feb 2, 2021
@glenn-jocher
Copy link
Author

@daquexian can we raise an issue on the onnxruntime-noopenmp repo for macos support?

@daquexian
Copy link
Owner

@daquexian can we raise an issue on the onnxruntime-noopenmp repo for macos support?

@glenn-jocher according to microsoft/onnxruntime#6511, there will be a macos version in the next release

@glenn-jocher
Copy link
Author

@daquexian oh, perfect! Let's wait a bit then and revisit when macos support arrives :)

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

2 participants