Skip to content
This repository has been archived by the owner on Apr 1, 2021. It is now read-only.

Trouble Installing TVM Extension #77

Closed
14jyuan opened this issue Jul 31, 2019 · 9 comments
Closed

Trouble Installing TVM Extension #77

14jyuan opened this issue Jul 31, 2019 · 9 comments

Comments

@14jyuan
Copy link

14jyuan commented Jul 31, 2019

When I try running python setup.py install to install the TVM extension, I get a subprocesss.CalledProcess Error:

make: *** No targets specified and no makefile found. Stop.
Traceback (most recent call last):
File "setup.py", line 273, in
url='https://github.com/pytorch/tvm',
File "/home/ubuntu/anaconda3/lib/python3.7/site-packages/setuptools/init.py", line 145, in setup
return distutils.core.setup(**attrs)
File "/home/ubuntu/anaconda3/lib/python3.7/distutils/core.py", line 148, in setup
dist.run_commands()
File "/home/ubuntu/anaconda3/lib/python3.7/distutils/dist.py", line 966, in run_commands
self.run_command(cmd)
File "/home/ubuntu/anaconda3/lib/python3.7/distutils/dist.py", line 985, in run_command
cmd_obj.run()
File "setup.py", line 203, in run
setuptools.command.install.install.run(self)
File "/home/ubuntu/anaconda3/lib/python3.7/site-packages/setuptools/command/install.py", line 65, in run
orig.install.run(self)
File "/home/ubuntu/anaconda3/lib/python3.7/distutils/command/install.py", line 545, in run
self.run_command('build')
File "/home/ubuntu/anaconda3/lib/python3.7/distutils/cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "/home/ubuntu/anaconda3/lib/python3.7/distutils/dist.py", line 985, in run_command
cmd_obj.run()
File "/home/ubuntu/anaconda3/lib/python3.7/distutils/command/build.py", line 135, in run
self.run_command(cmd_name)
File "/home/ubuntu/anaconda3/lib/python3.7/distutils/cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "/home/ubuntu/anaconda3/lib/python3.7/distutils/dist.py", line 985, in run_command
cmd_obj.run()
File "setup.py", line 187, in run
self.run_command('cmake_build')
File "/home/ubuntu/anaconda3/lib/python3.7/distutils/cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "/home/ubuntu/anaconda3/lib/python3.7/distutils/dist.py", line 985, in run_command
cmd_obj.run()
File "setup.py", line 176, in run
self._run_build()
File "setup.py", line 165, in _run_build
subprocess.check_call(build_args)
File "/home/ubuntu/anaconda3/lib/python3.7/subprocess.py", line 347, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['/usr/bin/cmake', '--build', '.', '--', '-j', '4']' returned non-zero exit status 2.

I'm running an 18.04 Ubuntu instance and the latest PyTorch nightly build. I have llvm-8 installed.

@sanjaybharadwaj
Copy link

sanjaybharadwaj commented Aug 1, 2019

I hope you created a symbolic link to llvm-config. By default the llvm-8 installation installs llvm-config-8, so you can create a symbolic link by

ln -s /usr/bin/llvm-config-8 /usr/bin/llvm-config

@14jyuan
Copy link
Author

14jyuan commented Aug 1, 2019

I just tried creating a symbolic link, but I got the same error. I think it might be an issue with cmake rather than llvm?

@bwasti
Copy link
Contributor

bwasti commented Aug 2, 2019

perhaps you need to git submodule update --init --recursive?

if not, after creating that symlink, could you try git clean -xfd and rebuilding with python setup.py install --cmake?

@14jyuan
Copy link
Author

14jyuan commented Aug 2, 2019

It fixed my issue with python setup.py install, but it errors when I try to run python setup.py test:

=========================================================== ERRORS ============================================================
_____________________________________________ ERROR collecting test/test_core.py ______________________________________________
ImportError while importing test module '/home/ubuntu/tvm/test/test_core.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
test/test_core.py:2: in
from test.util import TVMTest
test/util.py:12: in
import torch_tvm
torch_tvm/init.py:9: in
from ._torch_tvm import *
E ImportError: /home/ubuntu/tvm/torch_tvm/_torch_tvm.cpython-37m-x86_64-linux-gnu.so: undefined symbol: ZN5torch3jit16SubgraphRewriter22RegisterRewritePatternERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES9
____________________________________________ ERROR collecting test/test_models.py _____________________________________________
ImportError while importing test module '/home/ubuntu/tvm/test/test_models.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
test/test_models.py:6: in
import torch_tvm
torch_tvm/init.py:9: in
from ._torch_tvm import *
E ImportError: /home/ubuntu/tvm/torch_tvm/_torch_tvm.cpython-37m-x86_64-linux-gnu.so: undefined symbol: ZN5torch3jit16SubgraphRewriter22RegisterRewritePatternERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES9
___________________________________________ ERROR collecting test/test_operators.py ___________________________________________
ImportError while importing test module '/home/ubuntu/tvm/test/test_operators.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
test/test_operators.py:2: in
from test.util import TVMTest
test/util.py:12: in
import torch_tvm
torch_tvm/init.py:9: in
from ._torch_tvm import *
E ImportError: /home/ubuntu/tvm/torch_tvm/_torch_tvm.cpython-37m-x86_64-linux-gnu.so: undefined symbol: ZN5torch3jit16SubgraphRewriter22RegisterRewritePatternERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES9
====================================================== warnings summary =======================================================
/home/ubuntu/anaconda3/lib/python3.7/site-packages/pywt/_utils.py:6
/home/ubuntu/anaconda3/lib/python3.7/site-packages/pywt/_utils.py:6: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated, and in 3.8 it will stop working
from collections import Iterable

-- Docs: https://docs.pytest.org/en/latest/warnings.html
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 3 errors during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
============================================= 1 warnings, 3 error in 1.57 seconds =============================================

@14jyuan
Copy link
Author

14jyuan commented Aug 8, 2019

Could the undefined symbol errors have something to do with the PyTorch version?

@bwasti
Copy link
Contributor

bwasti commented Aug 8, 2019

Yep, it certainly could be the version of PyTorch, but RegisterRewritePattern has been around for a while. If you're willing, I'd recommend building PyTorch locally. Otherwise, a newer nightly might help.

The other issue might be a mismatch caused by the __cxx11 symbol, which might be resolved by adding -D_GLIBCXX_USE_CXX11_ABI=0 to your build command. I'm going off this StackOverflow post: https://stackoverflow.com/questions/33394934/converting-std-cxx11string-to-stdstring.

More concretely that would mean changing https://github.com/pytorch/tvm/blob/master/CMakeLists.txt#L10 to either

SET(CMAKE_CXX_FLAGS  "${CMAKE_CXX_FLAGS} -D_GLIBCXX_USE_CXX11_ABI=0")

or

SET(CMAKE_CXX_FLAGS  "${CMAKE_CXX_FLAGS} -D_GLIBCXX_USE_CXX11_ABI=1")

@14jyuan
Copy link
Author

14jyuan commented Aug 8, 2019

I tried doing rebuilding the nightly version of PyTorch and changing the line in CMakeLists.txt, and I think it fixed my previous errors, but now I have new errors with python setup.py test:

_________________________________________________________ ERROR collecting test/test_core.py __________________________________________________________
test/test_core.py:2: in
from test.util import TVMTest
test/util.py:12: in
import torch_tvm
torch_tvm/init.py:7: in
from tvm import relay # This registers all the schedules
../anaconda3/lib/python3.7/site-packages/tvm-0.6.dev0-py3.7-linux-x86_64.egg/tvm/init.py:23: in
from . import tensor
../anaconda3/lib/python3.7/site-packages/tvm-0.6.dev0-py3.7-linux-x86_64.egg/tvm/tensor.py:20: in
from ._ffi.node import NodeBase, NodeGeneric, register_node, convert_to_node
../anaconda3/lib/python3.7/site-packages/tvm-0.6.dev0-py3.7-linux-x86_64.egg/tvm/_ffi/node.py:24: in
from .node_generic import NodeGeneric, convert_to_node, const
../anaconda3/lib/python3.7/site-packages/tvm-0.6.dev0-py3.7-linux-x86_64.egg/tvm/_ffi/node_generic.py:23: in
from .base import string_types
../anaconda3/lib/python3.7/site-packages/tvm-0.6.dev0-py3.7-linux-x86_64.egg/tvm/_ffi/base.py:60: in
_LIB, _LIB_NAME = _load_lib()
../anaconda3/lib/python3.7/site-packages/tvm-0.6.dev0-py3.7-linux-x86_64.egg/tvm/_ffi/base.py:52: in _load_lib
lib = ctypes.CDLL(lib_path[0], ctypes.RTLD_GLOBAL)
../anaconda3/lib/python3.7/ctypes/init.py:356: in init
self._handle = _dlopen(self._name, mode)
E OSError: /home/ubuntu/anaconda3/lib/python3.7/site-packages/tvm-0.6.dev0-py3.7-linux-x86_64.egg/tvm/libtvm.so: undefined symbol: _ZN4llvm14TargetRegistry12lookupTargetERKSsRSs
________________________________________________________ ERROR collecting test/test_models.py _________________________________________________________
test/test_models.py:6: in
import torch_tvm
torch_tvm/init.py:7: in
from tvm import relay # This registers all the schedules
../anaconda3/lib/python3.7/site-packages/tvm-0.6.dev0-py3.7-linux-x86_64.egg/tvm/init.py:23: in
from . import tensor
../anaconda3/lib/python3.7/site-packages/tvm-0.6.dev0-py3.7-linux-x86_64.egg/tvm/tensor.py:20: in
from ._ffi.node import NodeBase, NodeGeneric, register_node, convert_to_node
../anaconda3/lib/python3.7/site-packages/tvm-0.6.dev0-py3.7-linux-x86_64.egg/tvm/_ffi/node.py:24: in
from .node_generic import NodeGeneric, convert_to_node, const
../anaconda3/lib/python3.7/site-packages/tvm-0.6.dev0-py3.7-linux-x86_64.egg/tvm/_ffi/node_generic.py:23: in
from .base import string_types
../anaconda3/lib/python3.7/site-packages/tvm-0.6.dev0-py3.7-linux-x86_64.egg/tvm/_ffi/base.py:60: in
_LIB, _LIB_NAME = _load_lib()
../anaconda3/lib/python3.7/site-packages/tvm-0.6.dev0-py3.7-linux-x86_64.egg/tvm/_ffi/base.py:52: in _load_lib
lib = ctypes.CDLL(lib_path[0], ctypes.RTLD_GLOBAL)
../anaconda3/lib/python3.7/ctypes/init.py:356: in init
self._handle = _dlopen(self._name, mode)
E OSError: /home/ubuntu/anaconda3/lib/python3.7/site-packages/tvm-0.6.dev0-py3.7-linux-x86_64.egg/tvm/libtvm.so: undefined symbol: _ZN4llvm14TargetRegistry12lookupTargetERKSsRSs
_______________________________________________________ ERROR collecting test/test_operators.py _______________________________________________________
test/test_operators.py:2: in
from test.util import TVMTest
test/util.py:12: in
import torch_tvm
torch_tvm/init.py:7: in
from tvm import relay # This registers all the schedules
../anaconda3/lib/python3.7/site-packages/tvm-0.6.dev0-py3.7-linux-x86_64.egg/tvm/init.py:23: in
from . import tensor
../anaconda3/lib/python3.7/site-packages/tvm-0.6.dev0-py3.7-linux-x86_64.egg/tvm/tensor.py:20: in
from ._ffi.node import NodeBase, NodeGeneric, register_node, convert_to_node
../anaconda3/lib/python3.7/site-packages/tvm-0.6.dev0-py3.7-linux-x86_64.egg/tvm/_ffi/node.py:24: in
from .node_generic import NodeGeneric, convert_to_node, const
../anaconda3/lib/python3.7/site-packages/tvm-0.6.dev0-py3.7-linux-x86_64.egg/tvm/_ffi/node_generic.py:23: in
from .base import string_types
../anaconda3/lib/python3.7/site-packages/tvm-0.6.dev0-py3.7-linux-x86_64.egg/tvm/_ffi/base.py:60: in
_LIB, _LIB_NAME = _load_lib()
../anaconda3/lib/python3.7/site-packages/tvm-0.6.dev0-py3.7-linux-x86_64.egg/tvm/_ffi/base.py:52: in _load_lib
lib = ctypes.CDLL(lib_path[0], ctypes.RTLD_GLOBAL)
../anaconda3/lib/python3.7/ctypes/init.py:356: in init
self._handle = _dlopen(self._name, mode)
E OSError: /home/ubuntu/anaconda3/lib/python3.7/site-packages/tvm-0.6.dev0-py3.7-linux-x86_64.egg/tvm/libtvm.so: undefined symbol: _ZN4llvm14TargetRegistry12lookupTargetERKSsRSs
================================================================== warnings summary ===================================================================
/home/ubuntu/anaconda3/lib/python3.7/site-packages/pywt/_utils.py:6
/home/ubuntu/anaconda3/lib/python3.7/site-packages/pywt/_utils.py:6: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated, and in 3.8 it will stop working
from collections import Iterable

-- Docs: https://docs.pytest.org/en/latest/warnings.html
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 3 errors during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
========================================================= 1 warnings, 3 error in 0.90 seconds =========================================================

This seems kind of similar to this: apache/tvm#521, so I think this has something to do with llvm, but I'm not sure how to fix it. I tried setting the LLVM-CONFIG environmental variable to llvm-config-8.0 and I've checked my gcc version (it's 7.4.0), but that doesn't seem to help. I'm running llvm-8.0 and I've created the symbolic link from llvm-config-8. to llvm-config.

Do you have any ideas what else I could try? Sorry about all the questions.

@14jyuan
Copy link
Author

14jyuan commented Aug 20, 2019

It worked once I built PyTorch from source! I think the nightly build of PyTorch was causing the errors.

@lixiuhong
Copy link

It worked once I built PyTorch from source! I think the nightly build of PyTorch was causing the errors.

Which version it is in your case? I have also built from source, but it failed.

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

No branches or pull requests

4 participants