此篇文章用来记录faster-rcnn在CPU下运行成功的详细步骤,一般来说官方给的教程都是ubuntu+caffe+CUDA+cuDNN,基于GPU速度快于CPU,如果你不是显卡有问题或者配置出问题,建议采用GPU的方法运行faster-rcnn。配置方法很多牛人已经给出,可参考这些:
https://github.com/rbgirshick/py-faster-rcnn 官方教程
http://blog.csdn.net/samylee/article/details/50922601 可参考中文教程
——————————————————
下面介绍下cpu的方法,前提:配置caffe并编译成功,pycafffe编译成功,opencv编译成功。
第一步:下载源码和demo模型数据
git clone –recursive https://github.com/rbgirshick/py-faster-rcnn.git
在下载好的py-faster-rcnn的文件夹下运行
./data/scripts/fetch_faster_rcnn_models.sh
模型数据下载。
第二步:编译cpython模块
进入lib文件夹下,首先修改下set.py文件的内容,注释掉
GPU的相关代码。参考如下:(…表示中间又不用注释跳过去的内容)
…
#CUDA = locate_cuda()
…
# self.set_executable(‘compiler_so’, CUDA[‘nvcc’])
…
# 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’]]
# ),</