fails: module 'tvm.codegen' has no attribute 'llvm_version_major'

On FreeBSD I am getting this failure:

$ python3.6 input (1, 224, 224, 3) Traceback (most recent call last):

File “”, line 58, in graph, lib, params =, target, params=params)

File “/usr/local/lib/python3.6/site-packages/tvm/relay/”, line 244, in build graph_json, mod, params =, target, target_host, params)

File “/usr/local/lib/python3.6/site-packages/tvm/relay/”, line 109, in build self._build(func, target, target_host)

File “tvm/_ffi/_cython/./function.pxi”, line 304, in

File “tvm/_ffi/_cython/./function.pxi”, line 239, in tvm._ffi._cy3.core.FuncCall

File “tvm/_ffi/_cython/./function.pxi”, line 228, in tvm._ffi._cy3.core.FuncCall3

File “tvm/_ffi/_cython/./base.pxi”, line 160, in tvm._ffi._cy3.core.CALL

AttributeError: Traceback (most recent call last): [bt] (7) 0x80cc17ee1 <tvm::relay::legalize::Legalizer::VisitExpr_(tvm::relay::CallNode const*)+0x31> at /usr/local/lib/ [bt] (6) 0x80cd7074f <tvm::relay::ExprMutator::VisitExpr_(tvm::relay::CallNode const*)+0x21f> at /usr/local/lib/ [bt] (5) 0x80cd6f1bc <tvm::relay::ExprMutator::VisitExpr(tvm::relay::Expr const&)+0x10c> at /usr/local/lib/ [bt] (4) 0x80cbee7b3 <ZN3tvm5relay11ExprFunctorIFNS0_4ExprERKS2_EE9VisitExprES4+0xa3> at /usr/local/lib/ [bt] (3) 0x80cbeeaf8 <tvm::NodeFunctor<tvm::relay::Expr()(tvm::runtime::ObjectRef const&tvm::relay::ExprFunctor<tvm::relay::Expr()(tvm::relay::Expr const&)>)>::operator()(tvm::runtime::ObjectRef const&, tvm::relay::ExprFunctor<tvm::relay::Expr()(tvm::relay::Expr const&)>) const+0x138> at /usr/local/lib/ [bt] (2) 0x80cbf0528 <ZZN3tvm5relay11ExprFunctorIFNS0_4ExprERKS2_EE10InitVTableEvENUlRKNS_7runtime9ObjectRefEPS6_E4_8__invokeESA_SB+0x18> at /usr/local/lib/ [bt] (1) 0x80cc18253 <tvm::relay::legalize::Legalizer::VisitExpr_(tvm::relay::CallNode const*)+0x3a3> at /usr/local/lib/ [bt] (0) 0x80ce2fc0c <TVMCbArgToReturn+0x74c> at /usr/local/lib/ File “tvm/_ffi/_cython/./function.pxi”, line 55, in tvm._ffi._cy3.core.tvm_callback File “/usr/local/lib/python3.6/site-packages/tvm/relay/op/nn/”, line 246, in legalize_conv2d return topi.nn.conv2d_legalize(attrs, inputs, types) File “”, line 2, in conv2d_legalize File “/usr/local/lib/python3.6/site-packages/tvm/”, line 382, in dispatch_func return dispatch_dict[k](*args, **kwargs) File “/usr/local/lib/python3.6/site-packages/topi/x86/”, line 261, in _conv2d_legalize if _is_int8_hw_support(data_dtype, kernel_dtype): File “/usr/local/lib/python3.6/site-packages/topi/x86/”, line 60, in _is_int8_hw_support llvm_version = tvm.codegen.llvm_version_major() AttributeError: module ‘tvm.codegen’ has no attribute ‘llvm_version_major’

This is likely due to the fact that you have not build tvm with LLVM support

Hello tq: I got the same issue, my env is 7700HQ / kabylake, Ubuntu 16.04, python 3.5. I installed llvm 4.0.1, then build tvm 0.7.dev0 on based it. Is there a possibility llvm version not compatible, could you please recommend a llvm+tvm combi ? BR

Check the value of USE_LLVM in your config.cmake.

Hi tq, ramana,

Having the same problem on Ubuntu 16.04.6 when building from source. I tried building with LLVM 9.0 and 4.0, but the problem persisted. I do have set(USE_LLVM ON) in config.cmake and cmake is able to find LLVM:

-- Found LLVM_INCLUDE_DIRS=/usr/lib/llvm-4.0/include
-- Build with LLVM 4.0.0

Building works perfectly, but I get the same runtime error:

AttributeError: module '' has no attribute 'llvm_version_major'
During handling of the above exception, another exception occurred:
RuntimeError: LLVM version is not available, please check if you build with LLVM

Any ideas?