PyTorch is already built with _GLIBCXX_USE_CXX11_ABI=0
. So you have to also set this flag when compiling the C++ extension. In PyTorch 1.0 this should already be done for you, see https://github.com/pytorch/pytorch/blob/master/torch/utils/cpp_extension.py#L390.
The best way to solve this problem in any case is to compile Pytorch from source and use that same compiler for the extension. Then all problems go away.