apache / tvm

Open deep learning compiler stack for cpu, gpu and specialized accelerators
https://tvm.apache.org/
Apache License 2.0
11.82k stars 3.48k forks source link

[Docs] What versions of LLVM exactly to use? #16708

Open jchia opened 8 months ago

jchia commented 8 months ago

Install from Source

The page at https://tvm.apache.org/docs/install/from_source.html says this about LLVM:

We highly recommend to build with LLVM to enable all the features.

Additions/Changes Requested

But I cannot figure out which versions of LLVM are acceptable. On Ubuntu 20.04, I have clang-12 and llvm-12-dev installed from the official Ubuntu focal-updates repo, as well as clang-19 and libpolly-19-dev installed from http://apt.llvm.org/focal/ llvm-toolchain-focal main.

In my config.cmake, I tried setting USE_LLVM to /usr/lib/llvm-12/bin/llvm-config and /usr/lib/llvm-19/bin/llvm-config for ninja builds. Neither worked.

With 12:

/home/jchia/gh/tvm/src/target/llvm/llvm_module.cc:502:38: error: ‘x86’ is not a namespace-name
  502 |   using namespace llvm::sys::detail::x86;

With 19:

FAILED: CMakeFiles/tvm_objs.dir/src/target/llvm/llvm_instance.cc.o 
ccache /usr/bin/c++ -DDMLC_USE_FOPEN64=0 -DDMLC_USE_LOGGING_LIBRARY="<tvm/runtime/logging.h>" -DNDEBUG -DNDEBUG=1 -DTVM_GRAPH_EXECUTOR_TENSORRT -DTVM_INDEX_DEFAULT_I64=1 -DTVM_KALLOC_ALIGNMENT=64 -DTVM_LLVM_VERSION=190 -DTVM_THREADPOOL_USE_OPENMP=0 -DTVM_USE_LIBBACKTRACE=1 -DUSE_FALLBACK_STL_MAP=0 -DUSE_MICRO_STANDALONE_RUNTIME=1 -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -DDMLC_ENABLE_RTTI=0 -I/home/jchia/gh/tvm/include -I/home/jchia/gh/tvm/build/libbacktrace/include -I/home/jchia/gh/tvm/3rdparty/libcrc/include -isystem /home/jchia/gh/tvm/3rdparty/dlpack/include -isystem /home/jchia/gh/tvm/3rdparty/dmlc-core/include -isystem /home/jchia/gh/tvm/3rdparty/rang/include -isystem /home/jchia/gh/tvm/3rdparty/compiler-rt -isystem /home/jchia/gh/tvm/3rdparty/picojson -isystem /home/jchia/gh/tvm/build/crt_config -isystem /usr/local/cuda/include -isystem /usr/lib/llvm-19/include -std=c++17 -faligned-new -O2 -Wall -fPIC  -fno-rtti -MD -MT CMakeFiles/tvm_objs.dir/src/target/llvm/llvm_instance.cc.o -MF CMakeFiles/tvm_objs.dir/src/target/llvm/llvm_instance.cc.o.d -o CMakeFiles/tvm_objs.dir/src/target/llvm/llvm_instance.cc.o -c /home/jchia/gh/tvm/src/target/llvm/llvm_instance.cc
/home/jchia/gh/tvm/src/target/llvm/llvm_instance.cc:45:10: fatal error: llvm/Support/Host.h: No such file or directory
   45 | #include <llvm/Support/Host.h>

Could you clarify:

Triage

jchia commented 8 months ago

From the llvm github repo, it appears that llvm-17 has llvm/Support/Host.h but llvm-18 and llvm-19 do not.

chensterliu commented 3 weeks ago

I met the same error for combination of (TVM v0.15.0, llvm-18). Upgrade tvm and compile TVM v0.18.0 with llvm-18 works fine for me.