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

TVM forcing compilation with USE_MICRO ON #9617

Closed
philatoctoml opened this issue Dec 1, 2021 · 5 comments
Closed

TVM forcing compilation with USE_MICRO ON #9617

philatoctoml opened this issue Dec 1, 2021 · 5 comments

Comments

@philatoctoml
Copy link

philatoctoml commented Dec 1, 2021

@areusch

TVM is forcing compilation with USE_MICRO ON since a recent commit even though I have no reason to compile with it.

I am using the following to compile in this environment:

RUN sed -i "s|set(USE_CUDA OFF)|set(USE_CUDA ON)|g" /home/ubuntu/tvm/build/config.cmake && sed -i "s|set(USE_LLVM OFF)|set(USE_LLVM ON)|g" /home/ubuntu/tvm/build/config.cmake && sed -i "s|set(USE_CUDNN OFF)|set(USE_CUDNN ON)|g" /home/ubuntu/tvm/build/config.cmake && sed -i "s|set(USE_CUBLAS OFF)|set(USE_CUBLAS ON)|g" /home/ubuntu/tvm/build/config.cmake && sed -i "s|set(USE_GRAPH_EXECUTOR_CUDA_GRAPH OFF)|set(USE_GRAPH_EXECUTOR_CUDA_GRAPH ON)|g" /home/ubuntu/tvm/build/config.cmake && sed -i "s|set(USE_OPENMP none)|set(USE_OPENMP gnu)|g" /home/ubuntu/tvm/build/config.cmake

Traceback:

ubuntu@3c2bc3dd6016:/external$ python3.8 tvmcompile.py
Traceback (most recent call last):
  File "/home/ubuntu/tvm/python/tvm/micro/session.py", line 35, in <module>
    from .base import _rpc_connect
ImportError: cannot import name '_rpc_connect' from 'tvm.micro.base' (/home/ubuntu/tvm/python/tvm/micro/base.py)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "tvmcompile.py", line 1, in <module>
    from tvm.driver import tvmc
  File "/home/ubuntu/tvm/python/tvm/driver/tvmc/__init__.py", line 22, in <module>
    from . import micro
  File "/home/ubuntu/tvm/python/tvm/driver/tvmc/micro.py", line 26, in <module>
    import tvm.micro.project as project
  File "/home/ubuntu/tvm/python/tvm/micro/__init__.py", line 28, in <module>
    from .session import (
  File "/home/ubuntu/tvm/python/tvm/micro/session.py", line 37, in <module>
    raise ImportError("micro tvm is not enabled. Set USE_MICRO to ON in config.cmake")
ImportError: micro tvm is not enabled. Set USE_MICRO to ON in config.cmake
@ZQPei
Copy link
Contributor

ZQPei commented Dec 1, 2021

Can't reproduce your error.
If you didn't compile with USE_MICRO=ON, then don't from tvm import micro.
Would you mind to provide your tvmcompile.py code?

@philatoctoml
Copy link
Author

@ZQPei thanks! Of course not. I just did this based on a model I had already tuned:

from tvm.driver import tvmc

model = tvmc.load('model.onnx')

log_file = "mymodel.json"
target = "cuda"

#tvmc.tune(
#    model,
#    target=target,
#    tuning_records=log_file,
#)

package = tvmc.compile(model, target=target, tuning_records=log_file)

result = tvmc.run(package, device='cuda')
print(result)

@ZQPei
Copy link
Contributor

ZQPei commented Dec 1, 2021

from tvm.driver import tvmc

I think I have found the root cause of your problem.
As we can see in

from . import micro

and
import tvm.micro.project as project
from tvm.micro.project import TemplateProjectError
from tvm.micro.project_api.client import ProjectAPIServerNotFoundError

tvm.micro is imported in any case without a detection of USE_MICRO macro.
This bug was mistakenly introduced by #9229.

Thank you so much for reporting this bug. I will try to fix it as soon as possiable.

@ZQPei
Copy link
Contributor

ZQPei commented Dec 3, 2021

Thank you @philatoctoml. The bug has been fixed by #9632.

@leandron
Copy link
Contributor

leandron commented Dec 4, 2021

Thanks @ZQPei @philatoctoml and @gromero for fixing the issue!

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

No branches or pull requests

3 participants