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

[Build] TVM EP Build #20665

Open
mattam301 opened this issue May 13, 2024 · 1 comment
Open

[Build] TVM EP Build #20665

mattam301 opened this issue May 13, 2024 · 1 comment
Labels
build build issues; typically submitted using template ep:tvm issues related to TVM execution provider

Comments

@mattam301
Copy link

Describe the issue

I am trying building TVM Execution Provider from this document:

https://onnxruntime.ai/docs/execution-providers/community-maintained/TVM-ExecutionProvider.html

however, after the step of build Python API:


##Package for TVM:
cd <path_to_onnx_runtime>
python3 -m pip uninstall tvm -y
whl_path=$(find ./build/<OS_NAME>/Release/_deps/tvm-src/python/dist -name "*.whl")
python3 -m pip install $whl_path

##Package for TVM EP:

cd <path_to_onnx_runtime>
python3 -m pip uninstall onnxruntime onnxruntime-tvm -y
whl_path=$(find ./build/<OS_NAME>/Release/dist -name "*.whl")
python3 -m pip install $whl_path

I got an error of "undefined symbols" importing onnxruntime

>>> import onnxruntime
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/root/miniconda3/envs/quant/lib/python3.10/site-packages/onnxruntime/__init__.py", line 57, in <module>
    raise import_capi_exception
  File "/root/miniconda3/envs/quant/lib/python3.10/site-packages/onnxruntime/__init__.py", line 23, in <module>
    from onnxruntime.capi._pybind_state import ExecutionMode  # noqa: F401
  File "/root/miniconda3/envs/quant/lib/python3.10/site-packages/onnxruntime/capi/_pybind_state.py", line 32, in <module>
    from .onnxruntime_pybind11_state import *  # noqa
ImportError: /root/miniconda3/envs/quant/lib/python3.10/site-packages/onnxruntime/capi/onnxruntime_pybind11_state.so: undefined symbol: _ZN3tvm7runtime6Module12LoadFromFileERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES9_
image

What am i supposed to do?

Urgency

No response

Target platform

Ubuntu.20.04

Build script

Just import onnxruntime

Error / output

import onnxruntime
Traceback (most recent call last):
File "", line 1, in
File "/root/miniconda3/envs/quant/lib/python3.10/site-packages/onnxruntime/init.py", line 57, in
raise import_capi_exception
File "/root/miniconda3/envs/quant/lib/python3.10/site-packages/onnxruntime/init.py", line 23, in
from onnxruntime.capi._pybind_state import ExecutionMode # noqa: F401
File "/root/miniconda3/envs/quant/lib/python3.10/site-packages/onnxruntime/capi/_pybind_state.py", line 32, in
from .onnxruntime_pybind11_state import * # noqa
ImportError: /root/miniconda3/envs/quant/lib/python3.10/site-packages/onnxruntime/capi/onnxruntime_pybind11_state.so: undefined symbol: ZN3tvm7runtime6Module12LoadFromFileERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES9

Visual Studio Version

No response

GCC / Compiler Version

No response

@mattam301 mattam301 added the build build issues; typically submitted using template label May 13, 2024
@github-actions github-actions bot added the ep:tvm issues related to TVM execution provider label May 13, 2024
@mattam301
Copy link
Author

After exporting PYTHONPATH like this:

export PYTHONPATH=onnxruntime/build/Linux/Release:${PYTHONPATH}
export PYTHONPATH=onnxruntime/build/Linux/Release/_deps/tvm-src/python:${PYTHONPATH}

I ran into another error:

>>> import onnxruntime
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/onnxruntime/build/Linux/Release/onnxruntime/__init__.py", line 57, in <module>
    raise import_capi_exception
  File "/onnxruntime/build/Linux/Release/onnxruntime/__init__.py", line 23, in <module>
    from onnxruntime.capi._pybind_state import ExecutionMode  # noqa: F401
  File "/onnxruntime/build/Linux/Release/onnxruntime/capi/_pybind_state.py", line 12, in <module>
    from . import _ld_preload  # noqa: F401
  File "/onnxruntime/build/Linux/Release/onnxruntime/capi/_ld_preload.py", line 13, in <module>
    import tvm
  File "/onnxruntime/build/Linux/Release/_deps/tvm-src/python/tvm/__init__.py", line 55, in <module>
    from . import tir
  File "/onnxruntime/build/Linux/Release/_deps/tvm-src/python/tvm/tir/__init__.py", line 24, in <module>
    from .expr import Var, SizeVar, Reduce, FloatImm, IntImm, StringImm, Cast
  File "/onnxruntime/build/Linux/Release/_deps/tvm-src/python/tvm/tir/expr.py", line 1014, in <module>
    class Load(PrimExprWithOp):
  File "/onnxruntime/build/Linux/Release/_deps/tvm-src/python/tvm/_ffi/registry.py", line 69, in register
    check_call(_LIB.TVMObjectTypeKey2Index(c_str(object_name), ctypes.byref(tidx)))
  File "/onnxruntime/build/Linux/Release/_deps/tvm-src/python/tvm/_ffi/base.py", line 348, in check_call
    raise get_last_ffi_error()
tvm.error.InternalError: Traceback (most recent call last):
  4: 0xffffffffffffffff
  3: 0x000000000058852d
  2: ffi_call
  1: TVMObjectTypeKey2Index
  0: tvm::runtime::Object::TypeKey2Index(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)
  File "/tvm/src/runtime/object.cc", line 165
InternalError: Check failed: (it != type_key2index_.end()) is false: Cannot find type tir.Load. Did you forget to register the node by TVM_REGISTER_NODE_TYPE ?
TVM hint: You hit an internal error. Please open a thread on https://discuss.tvm.apache.org/ to report it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build build issues; typically submitted using template ep:tvm issues related to TVM execution provider
Projects
None yet
Development

No branches or pull requests

1 participant