Hi, in solving my issues in importing/compiling an extension i’ve been searching around for any clue possible.
I came across ldd checking the compiled .so file as maybe some libraries were missing, and lo and behold:
Pytorch somehow does not agree with me…
ldd /usr/local/lib/python3.10/dist-packages/install_test1-0.0.0-py3.10-linux-x86_64.egg/install_test1.cpython-310-x86_64-linux-gnu.so
linux-vdso.so.1 (0x00007ffe012bd000)
libc10.so => not found
libtorch_cpu.so => not found
libtorch_python.so => not found
libstdc++.so.6 => /lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007fe6cbfc1000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007fe6cbfa1000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fe6cbd76000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fe6cbc8f000)
/lib64/ld-linux-x86-64.so.2 (0x00007fe6cc22a000)
this was done with both JIT and setuptools methods of importing the extension, files shown below:
setup.py
from setuptools import setup, Extension
from torch.utils import cpp_extension
setup(name='install_test1',
ext_modules=[cpp_extension.CppExtension('install_test1', ['ConvolutionMM2d_.cpp'])],
cmdclass={'build_ext': cpp_extension.BuildExtension})
and test.py
import torch
import torch.nn as nn
import torch.functional as F
from torch.utils.cpp_extension import load
perf = load(name="install_test1", sources=["ConvolutionMM2d_.cpp"], verbose=True)
and the setuptools version:
import torch
import install_test1
both of which result in an exception of the missing symbol as per the linked post.
This was done both with pip-install and building pytorch from source - the same version.
(yes i tried a virtual environment as well, same thing happened)
I can only ask how can i convince the extension files to recognise the pytorch c libraries?