Boost Variadic Template and NVCC has bugs if nvcc != 7.5
Created by: reyoung
It seems that in this file, boost disable variadic template support when nvcc != 7.5. It says that nvcc
has bug to handle C++ variadic template.
But our refactoring code is using boost::variant, which is used the variadic template in C++ 11. If we use boost > 1.61 and nvcc != 7.5, the error will occurred like below:
Undefined symbols for architecture x86_64:
"paddle::platform::is_cpu_place(boost::variant<paddle::platform::GPUPlace, paddle::platform::CPUPlace, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_> const&)", referenced from:
float* paddle::framework::Tensor::mutable_data<float>(boost::variant<paddle::platform::GPUPlace, paddle::platform::CPUPlace, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_>) in libadd_op.a(add_op_generated_add_op.cu.o)
paddle::framework::Tensor::PlaceholderImpl<float, paddle::platform::CPUPlace>::PlaceholderImpl(paddle::platform::CPUPlace, unsigned long) in libadd_op.a(add_op_generated_add_op.cu.o)
paddle::framework::Tensor::PlaceholderImpl<float, paddle::platform::GPUPlace>::PlaceholderImpl(paddle::platform::GPUPlace, unsigned long) in libadd_op.a(add_op_generated_add_op.cu.o)
"paddle::platform::is_gpu_place(boost::variant<paddle::platform::GPUPlace, paddle::platform::CPUPlace, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_> const&)", referenced from:
paddle::framework::OperatorWithKernel::OpKernelHash::operator()(paddle::framework::OperatorWithKernel::OpKernelKey const&) const in libadd_op.a(add_op_generated_add_op.cu.o)
float* paddle::framework::Tensor::mutable_data<float>(boost::variant<paddle::platform::GPUPlace, paddle::platform::CPUPlace, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_>) in libadd_op.a(add_op_generated_add_op.cu.o)
"paddle::platform::places_are_same_class(boost::variant<paddle::platform::GPUPlace, paddle::platform::CPUPlace, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_> const&, boost::variant<paddle::platform::GPUPlace, paddle::platform::CPUPlace, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_> const&)", referenced from:
paddle::framework::OperatorWithKernel::OpKernelKey::operator==(paddle::framework::OperatorWithKernel::OpKernelKey const&) const in libadd_op.a(add_op_generated_add_op.cu.o)
ld: symbol(s) not found for architecture x86_64
There should be two situations.
-
Check boost and nvcc version in CMake, and give a reasonable error. Freeze our boost and nvcc to some version.
-
Always define
BOOST_NO_CXX11_VARIADIC_TEMPLATES
when GPU=ON. To generate same function symbols betweengcc/clang
andnvcc