0

我是 Apache TVM 的新手。

我尝试构建并启动一个命名tvm.ci_cpu:latest为教程https://tvm.apache.org/docs/install/docker.html#docker-source中描述的 docker 镜像。

我尝试按照教程https://tvm.apache.org/docs/tutorial/tvmc_command_line_driver.html#using-tvmctvmc中所述在 docker 容器中使用 python 应用程序。

然后我收到以下错误:

$ tvmc --help

bash: tvmc: command not found

我尝试使用上面文章中提到的其他方法,但出现以下新错误:

$ python3 -m tvm.driver.tvmc --help

Traceback (most recent call last):
  File "/usr/lib/python3.6/runpy.py", line 183, in _run_module_as_main
    mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
  File "/usr/lib/python3.6/runpy.py", line 109, in _get_module_details
    __import__(pkg_name)
  File "/opt/share0/bob/project/tvm/python/tvm/__init__.py", line 26, in <module>
    from ._ffi.base import TVMError, __version__, _RUNTIME_ONLY
  File "/opt/share0/bob/project/tvm/python/tvm/_ffi/__init__.py", line 28, in <module>
    from .base import register_error
  File "/opt/share0/bob/project/tvm/python/tvm/_ffi/base.py", line 71, in <module>
    _LIB, _LIB_NAME = _load_lib()
  File "/opt/share0/bob/project/tvm/python/tvm/_ffi/base.py", line 51, in _load_lib
    lib_path = libinfo.find_lib_path()
  File "/opt/share0/bob/project/tvm/python/tvm/_ffi/libinfo.py", line 146, in find_lib_path
    raise RuntimeError(message)
RuntimeError: Cannot find libraries: ['libtvm.so', 'libtvm_runtime.so']
List of candidates:
/opt/sgxsdk/lib64/libtvm.so
/opt/share0/bob/project/tvm/libtvm.so
/usr/local/sbin/libtvm.so
/usr/local/bin/libtvm.so
/usr/sbin/libtvm.so
/usr/bin/libtvm.so
/sbin/libtvm.so
/bin/libtvm.so
/opt/rust/bin/libtvm.so
/usr/lib/go-1.10/bin/libtvm.so
/opt/share0/bob/project/tvm/python/tvm/libtvm.so
/opt/share0/bob/project/libtvm.so
/opt/sgxsdk/lib64/libtvm_runtime.so
/opt/share0/bob/project/tvm/libtvm_runtime.so
/usr/local/sbin/libtvm_runtime.so
/usr/local/bin/libtvm_runtime.so
/usr/sbin/libtvm_runtime.so
/usr/bin/libtvm_runtime.so
/sbin/libtvm_runtime.so
/bin/libtvm_runtime.so
/opt/rust/bin/libtvm_runtime.so
/usr/lib/go-1.10/bin/libtvm_runtime.so
/opt/share0/bob/project/tvm/python/tvm/libtvm_runtime.so
/opt/share0/bob/project/libtvm_runtime.so

我尝试拉取并使用以下第三方 docker 镜像,而不是我自己构建的镜像:

但是,我仍然遇到与以前相同的问题。

WHY? I had no idea at all.

Any suggestion? Thanks.

4

1 回答 1

0

I found pingsutw's answer in https://discuss.tvm.apache.org/t/import-tvm-returns-runtime-error-cant-find-libtvm-so-when-using-docker-demo-cpu-image/5110. After referring to his advice, I tried rebuilding tvm in a container launched from the image tvm.ci_cpu:latest which built by myself.

pushd path/to/tvm && \
    chmod +x 3rdparty/libbacktrace/configure && \
    mkdir -p cmake-build && \
    cmake -H. -Bcmake-build -DUSE_LLVM=ON && \
    cmake --build cmake-build --target all -- -j 4 && \
    mv cmake-build build && \
    popd

After the above, I tried typing the command python3 -m tvm.driver.tvmc --help and got the following output.

usage: tvmc [-v] [--version] [-h] {run,tune,compile} ...

TVM compiler driver

optional arguments:
  -v, --verbose       increase verbosity
  --version           print the version and exit
  -h, --help          show this help message and exit.

commands:
  {run,tune,compile}
    run               run a compiled module
    tune              auto-tune a model
    compile           compile a model.

TVMC - TVM driver command-line interface

As you can see it works now.

Surprisingly, libtvm.so and libtvm_runtime.so are not pre-built in the tvm docker image. Maybe the third-party tvm docker image is broken. Maybe the Dockerfile for building tvm docker image should be updated. Maybe it is designed to be flexibly compiled to meet various needs.

于 2022-02-10T07:11:18.187 回答