编译py-faster-rcnn lib报错:g++: error: unrecognized command line option ‘-R’

感谢:

https://blog.csdn.net/xiamentingtao/article/details/78266153

想要编译py-faster-rcnn然后测自己的数据集,但是在Cython时却报错了:

g++ -pthread -shared -B /home/ard/yes/compiler_compat -L/home/ard/yes/lib -Wl,-rpath=/home/ard/yes/lib,--no-as-needed build/temp.linux-x86_64-2.7/nms/nms_kernel.o build/temp.linux-x86_64-2.7/nms/gpu_nms.o -L/usr/local/cuda/lib64 -L/home/ard/yes/lib -R/usr/local/cuda/lib64 -lcudart -lpython2.7 -o /home/ard/py-faster-rcnn/lib/nms/gpu_nms.so
g++: error: unrecognized command line option ‘-R’
error: command 'g++' failed with exit status 1
Makefile:2: recipe for target 'all' failed
make: *** [all] Error 1

解决办法:先将报错的nms.gpu_nms模块注释后重新make,打开setup.py,注释掉nms.gpu_nms模块:

#    Extension('nms.gpu_nms',
#        ['nms/nms_kernel.cu', 'nms/gpu_nms.pyx'],
#        library_dirs=[CUDA['lib64']],
#        libraries=['cudart'],
#        language='c++',
#        runtime_library_dirs=[CUDA['lib64']],
#         # this syntax is specific to this build system
#         # we're only going to use certain compiler args with nvcc and not with
#         # gcc the implementation of this trick is in customize_compiler() below
#        extra_compile_args={'gcc': ["-Wno-unused-function"],
#                            'nvcc': ['-arch=sm_35',
#                                     '--ptxas-options=-v',
#                                     '-c',
#                                     '--compiler-options',
#                                     "'-fPIC'"]},
#        include_dirs = [numpy_include, CUDA['include']]
#    ),

也就是先编译utils/bbox.c和nms/cpu_nms.c及’pycocotools/_mask.c。然后再去掉上面的注释后,将报错的命令中含“-R"的一句替换为“-WI,rpath=”

 -R/usr/local/cuda/lib64 -lcudart -lpython2.7 -o /home/ard/py-faster-rcnn/lib/nms/gpu_nms.so

换为:

 -WI,rpath=/usr/local/cuda/lib64 -lcudart -lpython2.7 -o /home/ard/py-faster-rcnn/lib/nms/gpu_nms.so

然后再make一次便可以将gpu_nms模块编译好了,最终结果:

[caiyong.wang@localhost lib]$ make
python setup.py build_ext --inplace
running build_ext
skipping 'utils/bbox.c' Cython extension (up-to-date)
skipping 'nms/cpu_nms.c' Cython extension (up-to-date)
skipping 'nms/gpu_nms.cpp' Cython extension (up-to-date)
skipping 'pycocotools/_mask.c' Cython extension (up-to-date)
rm -rf build
  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值