Import tvm returns Runtime error (can't find libtvm.so) when using docker demo-cpu image

First attempt to try out TVM. I’ve followed tutorials to install TVM from docker (demo-cpu) here https://docs.tvm.ai/install/docker.html#docker-images

Installed docker engine based on https://docs.docker.com/install/linux/docker-ce/centos/ (my host system is CentOS 7).

Then pulled the docker image:

docker pull tvmai/demo-cpu

and launched it. Then i tried to import tvm:

root@wlab3:~# python3
Python 3.6.8 (default, May  7 2019, 14:58:50) 
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tvm
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/workspace/python/tvm/__init__.py", line 27, in <module>
    from . import tensor
  File "/workspace/python/tvm/tensor.py", line 20, in <module>
    from ._ffi.node import NodeBase, NodeGeneric, register_node, convert_to_node
  File "/workspace/python/tvm/_ffi/node.py", line 24, in <module>
    from .object import Object, register_object, _set_class_node
  File "/workspace/python/tvm/_ffi/object.py", line 23, in <module>
    from .base import _FFI_MODE, _RUNTIME_ONLY, check_call, _LIB, c_str
  File "/workspace/python/tvm/_ffi/base.py", line 60, in <module>
    _LIB, _LIB_NAME = _load_lib()
  File "/workspace/python/tvm/_ffi/base.py", line 51, in _load_lib
    lib_path = libinfo.find_lib_path()
  File "/workspace/python/tvm/_ffi/libinfo.py", line 132, in find_lib_path
    raise RuntimeError(message)
RuntimeError: Cannot find the files.
List of candidates:
/opt/sgxsdk/lib64/libtvm.so
/workspace/libtvm.so
...

Relevant env vars are:

declare -x HOME="/workspace"
declare -x LD_LIBRARY_PATH="/opt/sgxsdk/lib64:"
declare -x PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/rust/bin:/usr/lib/go-1.10/bin"
declare -x PWD="/workspace"
declare -x PYTHONPATH="python:topi/python"

Shouldn’t .so libraries come pre-built/pre-installed with demo-cpu docker image?

Adding

root@wlab3:~# export TVM_HOME=/workspace
root@wlab3:~# export PYTHONPATH=$TVM_HOME/python:$TVM_HOME/topi/python:$TVM_HOME/nnvm/python:${PYTHONPATH}

didn’t help.

Any advise is welcome.

Well, I guess the documentation is not up to date… https://docs.tvm.ai/install/docker.html says to clone the repo. Say, i’ve cloned it to /<my_path>/tvm. When i run the docker image from the above tvm directory it gets mapped to /workspace. And there is no pre-built libraries in it (obviously).

However, the docker image already comes with the tvm source and libtvm.so - just in a different location: /usr/tvm. Although, that’s an older snapshot of the sources (27-Sep-2019 as of writing this comment).

Remapping TVM_HOME and PYTHONPATH

export TVM_HOME=/usr/tvm  
export PYTHONPATH=$TVM_HOME/python:$TVM_HOME/topi/python:$TVM_HOME/nnvm/python

solved the original issue, but a new one showed up: exactly the one discussed in Tvm build issue in docker container

Who needs to be notified to update the documentation and/or update the default docker/bash.sh?

1 Like

Hi @emezh, I faced the same problem, did you solve it?

The original problem was solved as I’ve described above. In the end, I gave up using docker container and just built TVM from source following the tutorial https://docs.tvm.ai/install/from_source.html

@emezh Thanks, I will try it.