[microtvm] cannot import tvm.micro [fixed]

Hi,

My tvm version is bd24133fce184c84539461b3dc19fdcf7ad60a9e (mid june this year). My tvm stack works fine (relay tir te …).

But I cannot import micro TVM in python see below:
import tvm.micro as micro

"… 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 "

However, I have built TVM stack with microtvm active (see this grep): ./tvm/build/config.cmake:set(USE_MICRO ON) ./tvm/build/config.cmake:set(USE_MICRO_STANDALONE_RUNTIME ON)

And I have tvm/python in my PYTHONPATH which should be sufficient as it points to parent folder of micro: python/tvm/micro/.

Any idea how to fix this issue?

Thank you very much for your help. Gilles

Hi Gilles,

I was wondering why would you get this message when building with USE_MICRO ON and it seems micro also expects you to have USE_RPC ON.

Can you check you USE_RPC setting? Hope that helps.

Leandro

Hi Leandro,
Thanks for quick reply. Unfortunatelly it seems enabled: tvm$ find . -type f -name “config.cmake” | xargs grep USE_RPC ./cmake/config.cmake:set(USE_RPC ON) ./build/config.cmake:set(USE_RPC ON) Gilles

So here is another thought: What error you get when running that line from .base import _rpc_connect?

Maybe for a test would be something like:

>>> from tvm.micro.base import _rpc_connect

from tvm.micro.base import _rpc_connect

Traceback (most recent call last): File “”, line 1, in ImportError: cannot import name ‘_rpc_connect’ from ‘tvm.micro.base’ (tvm/python/tvm/micro/base.py)

I’ve just tried it with the upstream package apache-tvm:

$ pip list | grep apache-tvm
apache-tvm        0.12.0 

$ python
Python 3.8.10 (default, May 26 2023, 14:05:08) 
[GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from tvm.micro.base import _rpc_connect
>>> 

So definitely something to do with build flags.

These are the ones we use to generate the package:

I suggest cross-checking these with yours.

Hi Leandro,
Thanks again for your help.
Except Cuda and EthosN, I used your settings but it did not go any better:
set(USE_LLVM “llvm-config --ignore-libllvm --link-static”)
set(HIDE_PRIVATE_SYMBOLS ON)
set(USE_RPC ON)
set(USE_SORT ON)
set(USE_GRAPH_RUNTIME ON)
#set(USE_ETHOSN /opt/arm/ethosn-driver)
set(USE_ARM_COMPUTE_LIB /opt/arm/acl)
set(USE_MICRO ON)
set(USE_MICRO_STANDALONE_RUNTIME ON)
set(USE_ETHOSU ON)
set(USE_CMSISNN ON)

I also tried-out other settings that worked for me in the past (several years ago).

Could there be a link issue that does not prevent from building but prevents microtvm access ? (objects are built but not linked which is not harming as long as we don’t call the .so)

Also this setup is done manually on Ubuntu following install from source w/o Docker.
Can it be an issue ?
(I mean is TVM mainly installed and tested via Docker so manual installation is less tested ?)
Gilles

Reinstalling same tvm commit from scratch worked. No clue what went wrong. Thank you very much for your support Leandro !

1 Like