RuntimeError: Error compiling objects for extension

created at 08-30-2022 views: 11

problem

When I execute python setup.py build develop, the compilation error shows

RuntimeError: Error compiling objects for extension

solution

I found some posts on the Internet, some let me change the pytorch version, and there are other methods. I have tried it all, and changing the pytorch version does work, but this method is too stupid, I still recommend another method. Proceed as follows:

1 Enter the installation directory of cuda

cd /usr/local
> ls

bin   cuda-11.3 etc  games     lib  sbin  src
cuda  cuda-11.6 fftw include  man  share

2 Find the cuda corresponding to your pytorch version. For example, mine has cuda, cuda-11.3, cuda-11.6, but my pytorch corresponds to cuda (I named cuda11.1 as cuda).

3 Execute

vim ~/.bashrc

Add the following at the end:

export CUDA_HOME=/usr/local/cuda

If your cuda version is cuda-11.3, it should add the following:

export CUDA_HOME=/usr/local/cuda-11.3

Then exit vim, if you don't know how to exit, you can do as I said, first press esc, then enter :wq, and finally press enter to exit vim .

4 Execute the following code to make the source just configured take effect.

source ~/.bashrc

5 At this point, execute python setup.py build develop to compile successfully.

created at:08-30-2022
edited at: 08-30-2022: