I built a custom C++ extension following the guidelines shown here https://pytorch.org/tutorials/advanced/cpp_extension.html. However, when I import it, I get the following error:
ImportError: /usr/local/miniconda/lib/python3.6/site-packages/zbuffertri-0.0.0-py3.6-linux-x86_64.egg/zbuffertri.cpython-36m-x86_64-linux-gnu.so: undefined symbol: _ZN3c105ErrorC1ENS_14SourceLocationERKSs
I followed the discussion here which says both PyTorch and the C++ extensions should be built using -D_GLIBCXX_USE_CXX11_ABI=1
which is already the case. I get torch._C._GLIBCXX_USE_CXX11_ABI = True
and my compile output does show its using D_GLIBCXX_USE_CXX11_ABI=1
while compiling the C++ extension too.
My setup.py file looks like:
from setuptools import setup
import torch
from torch.utils.cpp_extension import BuildExtension, CppExtension, CUDAExtension
setup(
name="zbuffertri",
ext_modules=[
CUDAExtension(
"zbuffertri",
["zbuffertri.cpp", "zbuffertri_implementation.cu"],
)
],
cmdclass={"build_ext": BuildExtension},
)
My setup is the following:
OS: Ubuntu 18.04
PyTorch: v1.1.0
GCC: v4.9
CUDA: v9.0.176
CuDNN: v7.0
Any help would be much appreciated!