cffi.error.VerificationError: LinkError: command 'gcc' failed with exit status 1

运行 https://github.com/roytseng-tw/Detectron.pytorch mask-rcnn的时候

会出现这样一个问题

cffi.error.VerificationError: LinkError: command 'gcc' failed with exit status 1_第1张图片

还伴随着其他的一些错误,比如

gcc: error: /home/zhangdong/zhangdong/pytorch/mask-rcnn.pytorch/lib/model/roi_pooling/src/roi_pooling.cu.o: No such file or directory

gcc: error: /home/zhangdong/zhangdong/pytorch/mask-rcnn.pytorch/lib/modeling/roi_xfrom/roi_align/src/roi_align_kernel.cu.o: No such file or directory

gcc: error: /home/zhangdong/zhangdong/pytorch/mask-rcnn.pytorch/lib/model/nms/src/nms_cuda_kernel.cu.o: No such file or directory

Traceback (most recent call last):
  File "build.py", line 36, in
    ffi.build()
  File "/home/zhangdong/anaconda2/lib/python2.7/site-packages/torch/utils/ffi/__init__.py", line 184, in build
    _build_extension(ffi, cffi_wrapper_name, target_dir, verbose)
  File "/home/zhangdong/anaconda2/lib/python2.7/site-packages/torch/utils/ffi/__init__.py", line 108, in _build_extension
    outfile = ffi.compile(tmpdir=tmpdir, verbose=verbose, target=libname)
  File "/home/zhangdong/anaconda2/lib/python2.7/site-packages/cffi/api.py", line 697, in compile
    compiler_verbose=verbose, debug=debug, **kwds)
  File "/home/zhangdong/anaconda2/lib/python2.7/site-packages/cffi/recompiler.py", line 1520, in recompile
    compiler_verbose, debug)
  File "/home/zhangdong/anaconda2/lib/python2.7/site-packages/cffi/ffiplatform.py", line 22, in compile
    outputfilename = _build(tmpdir, ext, compiler_verbose, debug)
  File "/home/zhangdong/anaconda2/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
 

解决方案:

通过修改make.sh的头文件,在前面加上

export CUDA_PATH=/usr/local/cuda/
export CXXFLAGS="-std=c++11"
export CFLAGS="-std=c99"

export PATH=/usr/local/cuda-8.0/bin${PATH:+:${PATH}}
export CPATH=/usr/local/cuda-8.0/include${CPATH:+:${CPATH}}
export LD_LIBRARY_PATH=/usr/local/cuda-8.0/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}

这个问题就解决了

不要问我为什么,我也母鸡啊...

你可能感兴趣的:(【Python】,mask-rcnn)