CompileError: command 'gcc' failed with exit status 1 #235

When I try to compile c extension by using python bulid.py, it always raise error:

CompileError: command ‘gcc’ failed with exit status 1 #235.

I search in pytorch forums but get no answers.
And I find this link https://github.com/jwyang/faster-rcnn.pytorch/issues/235 discuss the same problem and someone give some solution — switch pytorch to 0.4.0
I want to know is there some better solution, because it’s annoying to install another version.

Hi,

Could you post the compilation log.
This error means that there was an error during the compilation, could you report it here please?

/home/zeal/work/others-projects/3D-CODED/nndistance
generating /tmp/tmpALHKrQ/_my_lib.c
setting the current directory to ‘/tmp/tmpALHKrQ’
running build_ext
building ‘_my_lib’ extension
creating home
creating home/zeal
creating home/zeal/work
creating home/zeal/work/others-projects
creating home/zeal/work/others-projects/3D-CODED
creating home/zeal/work/others-projects/3D-CODED/nndistance
creating home/zeal/work/others-projects/3D-CODED/nndistance/src
gcc -pthread -B /home/zeal/software/anaconda3/envs/py2.7/compiler_compat -Wl,–sysroot=/ -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/home/zeal/software/anaconda3/envs/py2.7/lib/python2.7/site-packages/torch/utils/ffi/…/…/lib/include -I/home/zeal/software/anaconda3/envs/py2.7/lib/python2.7/site-packages/torch/utils/ffi/…/…/lib/include/TH -I/home/zeal/software/anaconda3/envs/py2.7/include/python2.7 -c _my_lib.c -o ./_my_lib.o
gcc -pthread -B /home/zeal/software/anaconda3/envs/py2.7/compiler_compat -Wl,–sysroot=/ -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/home/zeal/software/anaconda3/envs/py2.7/lib/python2.7/site-packages/torch/utils/ffi/…/…/lib/include -I/home/zeal/software/anaconda3/envs/py2.7/lib/python2.7/site-packages/torch/utils/ffi/…/…/lib/include/TH -I/home/zeal/software/anaconda3/envs/py2.7/include/python2.7 -c /home/zeal/work/others-projects/3D-CODED/nndistance/src/my_lib.c -o ./home/zeal/work/others-projects/3D-CODED/nndistance/src/my_lib.o
gcc -pthread -shared -B /home/zeal/software/anaconda3/envs/py2.7/compiler_compat -L/home/zeal/software/anaconda3/envs/py2.7/lib -Wl,-rpath=/home/zeal/software/anaconda3/envs/py2.7/lib -Wl,–no-as-needed -Wl,–sysroot=/ ./_my_lib.o ./home/zeal/work/others-projects/3D-CODED/nndistance/src/my_lib.o /home/zeal/work/others-projects/3D-CODED/nndistance/src/nnd_cuda.cu.o -L/home/zeal/software/anaconda3/envs/py2.7/lib -lpython2.7 -o ./_my_lib.so
gcc: error: /home/zeal/work/others-projects/3D-CODED/nndistance/src/nnd_cuda.cu.o: 没有那个文件或目录
Traceback (most recent call last):
File “build.py”, line 35, in
ffi.build()
File “/home/zeal/software/anaconda3/envs/py2.7/lib/python2.7/site-packages/torch/utils/ffi/init.py”, line 185, in build
_build_extension(ffi, cffi_wrapper_name, target_dir, verbose)
File “/home/zeal/software/anaconda3/envs/py2.7/lib/python2.7/site-packages/torch/utils/ffi/init.py”, line 108, in _build_extension
ffi.compile(tmpdir=tmpdir, verbose=verbose, target=libname)
File “/home/zeal/software/anaconda3/envs/py2.7/lib/python2.7/site-packages/cffi/api.py”, line 697, in compile
compiler_verbose=verbose, debug=debug, **kwds)
File “/home/zeal/software/anaconda3/envs/py2.7/lib/python2.7/site-packages/cffi/recompiler.py”, line 1520, in recompile
compiler_verbose, debug)
File “/home/zeal/software/anaconda3/envs/py2.7/lib/python2.7/site-packages/cffi/ffiplatform.py”, line 22, in compile
outputfilename = _build(tmpdir, ext, compiler_verbose, debug)
File “/home/zeal/software/anaconda3/envs/py2.7/lib/python2.7/site-packages/cffi/ffiplatform.py”, line 58, in _build
raise VerificationError(’%s: %s’ % (e.class.name, e))
cffi.error.VerificationError: LinkError: command ‘gcc’ failed with exit status 1

It looks like it did not compiled nnd_cuda.cu. is it specified properly in your setup.py script? Is your user allow to write files on disk?

Thanks for your help!
I think I may know where something went wrong. I am sorry that I haven’t read the compilation log carefully.
:grinning: