[Solved]TVM compile Error on Ubuntu 16.04.10 GCC5

I compiled the TVM source code on Ubuntu 16.04.10 GCC 5, and met the following errors:

root@ubuntu-gloryguohezu:~/tvm/build# cmake …
– The C compiler identification is GNU 5.4.0
– The CXX compiler identification is GNU 5.4.0
– Check for working C compiler: /usr/bin/cc
– Check for working C compiler: /usr/bin/cc – works
– Detecting C compiler ABI info
– Detecting C compiler ABI info - done
– Detecting C compile features
– Detecting C compile features - done
– Check for working CXX compiler: /usr/bin/c++
– Check for working CXX compiler: /usr/bin/c++ – works
– Detecting CXX compiler ABI info
– Detecting CXX compiler ABI info - done
– Detecting CXX compile features
– Detecting CXX compile features - done
– Performing Test SUPPORT_CXX11
– Performing Test SUPPORT_CXX11 - Success
– Build with RPC support…
– Build with Graph runtime support…
– Build VTA runtime with target: sim
– Link with dynamic LLVM library
– Found LLVM_INCLUDE_DIRS=/usr/lib/llvm-4.0/include
– Found LLVM_DEFINITIONS=-D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
– Found TVM_LLVM_VERSION=40
– Build with LLVM 4.0.0
– Set TVM_LLVM_VERSION=40
– Configuring done
– Generating done
– Build files have been written to: /root/tvm/build

root@ubuntu-gloryguohezu:~/tvm/build# make -j4
Scanning dependencies of target vta
Scanning dependencies of target tvm_runtime
Scanning dependencies of target tvm
[ 0%] Building CXX object CMakeFiles/vta.dir/vta/src/device_api.cc.o
[ 1%] Building CXX object CMakeFiles/vta.dir/vta/src/runtime.cc.o
[ 2%] Building CXX object CMakeFiles/tvm_runtime.dir/src/runtime/c_dsl_api.cc.o
[ 2%] Building CXX object CMakeFiles/tvm.dir/src/api/api_ir.cc.o
[ 2%] Building CXX object CMakeFiles/vta.dir/vta/src/sim/sim_driver.cc.o
[ 2%] Building CXX object CMakeFiles/tvm_runtime.dir/src/runtime/builtin_fp16.cc.o
[ 2%] Building CXX object CMakeFiles/tvm_runtime.dir/src/runtime/system_lib_module.cc.o
[ 3%] Building CXX object CMakeFiles/tvm_runtime.dir/src/runtime/module.cc.o
[ 3%] Building CXX object CMakeFiles/tvm_runtime.dir/src/runtime/thread_pool.cc.o
c++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-5/README.Bugs> for instructions.
CMakeFiles/tvm.dir/build.make:62: recipe for target ‘CMakeFiles/tvm.dir/src/api/api_ir.cc.o’ failed
make[2]: *** [CMakeFiles/tvm.dir/src/api/api_ir.cc.o] Error 4
CMakeFiles/Makefile2:67: recipe for target ‘CMakeFiles/tvm.dir/all’ failed
make[1]: *** [CMakeFiles/tvm.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs…
[ 4%] Building CXX object CMakeFiles/tvm_runtime.dir/src/runtime/module_util.cc.o
[ 5%] Linking CXX shared library libvta.so
[ 5%] Built target vta
[ 5%] Building CXX object CMakeFiles/tvm_runtime.dir/src/runtime/dso_module.cc.o
[ 5%] Building CXX object CMakeFiles/tvm_runtime.dir/src/runtime/registry.cc.o
[ 6%] Building CXX object CMakeFiles/tvm_runtime.dir/src/runtime/file_util.cc.o
[ 6%] Building CXX object CMakeFiles/tvm_runtime.dir/src/runtime/threading_backend.cc.o
[ 6%] Building CXX object CMakeFiles/tvm_runtime.dir/src/runtime/ndarray.cc.o
[ 7%] Building CXX object CMakeFiles/tvm_runtime.dir/src/runtime/workspace_pool.cc.o
[ 7%] Building CXX object CMakeFiles/tvm_runtime.dir/src/runtime/cpu_device_api.cc.o
[ 7%] Building CXX object CMakeFiles/tvm_runtime.dir/src/runtime/c_runtime_api.cc.o
[ 8%] Building CXX object CMakeFiles/tvm_runtime.dir/src/runtime/rpc/rpc_module.cc.o
[ 8%] Building CXX object CMakeFiles/tvm_runtime.dir/src/runtime/rpc/rpc_session.cc.o

c++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-5/README.Bugs> for instructions.
CMakeFiles/tvm_runtime.dir/build.make:254: recipe for target ‘CMakeFiles/tvm_runtime.dir/src/runtime/file_util.cc.o’ failed
make[2]: *** [CMakeFiles/tvm_runtime.dir/src/runtime/file_util.cc.o] Error 4
make[2]: *** Waiting for unfinished jobs…
CMakeFiles/Makefile2:178: recipe for target ‘CMakeFiles/tvm_runtime.dir/all’ failed
make[1]: *** [CMakeFiles/tvm_runtime.dir/all] Error 2
Makefile:127: recipe for target ‘all’ failed
make: *** [all] Error 2

Does anyone know how to solve it? Thanks in advance.

c++: internal compiler error: Killed (program cc1plus) means C++ compiler meets some problem. I suggest upgrading compiler and try again.

Thanks.

I upgraded GCC5 to GCC6, and still the same error.
But when I change “make -j4” to “make”, it works fine.
I guess the reason is the machine I’m using is the cloud virtual machine, which only has 1 CPU and 1 thread per core. So the option job 4 caused the error.

root@ubuntu-gloryguohezu:~/tvm/build# lscpu
Architecture: x86_64
CPU op-mode(s): 32-bit, 64-bit
Byte Order: Little Endian
CPU(s): 1
On-line CPU(s) list: 0
Thread(s) per core: 1
Core(s) per socket: 1
Socket(s): 1
NUMA node(s): 1
Vendor ID: GenuineIntel
CPU family: 6
Model: 79
Model name: Intel® Xeon® CPU E5-2650 v4 @ 2.20GHz
Stepping: 1
CPU MHz: 2199.998
BogoMIPS: 4399.99
Virtualization: VT-x
Hypervisor vendor: KVM
Virtualization type: full
L1d cache: 32K
L1i cache: 32K
L2 cache: 256K
L3 cache: 30720K
NUMA node0 CPU(s): 0

just try ‘make’ instead of make -j4, to see what happen;
TVM building indeed have bug when make -j

@Brian seems like you are facing OOM, does your machine have swap space ?

Yes,it seems the cloud virtual machine doesn’t config the swap space. Then how much swap space should I have to avoid the OOM when compiling TVM? Thanks.

KiB Mem : 1016000 total, 142264 free, 79480 used, 794256 buff/cache
KiB Swap: 0 total, 0 free, 0 used. 723360 avail Mem

@Brian, I’m not sure about exact configuration, on my machine I have 8G RAM, 4G swap space and able to build TVM with j8/16/32. BTW, the error reminds me the one when I was running gcc test suites for ARM with THUMB 2 mode, adding swap space solved the problem.
Thanks.