我是Apache TVM的新手。
我尝试构建并启动一个名为tvm.ci_cpu:latest
的docker映像,如教程中所述https://tvm.apache.org/docs/install/docker.html#docker-来源。
我尝试在docker容器中使用python应用程序tvmc
,如教程中所述https://tvm.apache.org/docs/tutorial/tvmc_command_line_driver.html#using-tvmc。
然后我得到了以下错误:
$ 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图像,而不是我自己构建的图像:
https://hub.docker.com/r/tvmai/ci-cpu
https://hub.docker.com/r/tvmai/demo-cpu
然而,我仍然遇到了和以前一样的问题。
为什么?我一点也不知道。
有什么建议吗?谢谢
我在https://discuss.tvm.apache.org/t/import-tvm-returns-runtime-error-cant-find-libtvm-so-when-using-docker-demo-cpu-image/5110.在参考了他的建议后,我尝试在一个由我自己构建的图像tvm.ci_cpu:latest
启动的容器中重建tvm。
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
完成以上操作后,我尝试键入命令python3 -m tvm.driver.tvmc --help
,并得到以下输出。
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
正如你所看到的,它现在起作用了。
令人惊讶的是,libtvm.so
和libtvm_runtime.so
并没有预先构建在tvm docker映像中。也许第三方tvm docker镜像坏了。也许应该更新用于构建tvm docker映像的Dockerfile。也许它被设计成可以灵活地编译以满足各种需求。