only cpu run fast R-CNN
linux14.04 下安装好了python+opencv+caffe
1.从github上clone项目文件,注意:一定要在clone时加入--recursive参数,避免不必要的麻烦,也不要直接下载:
$git clone --recursive https://github.com/rbgirshick/py-faster-rcnn.git
2.进入py-fast-rcnn文件夹,选择lib文件,使用gedit编辑器打开setup.py文件,对里边的代码进行修改:
$cd py-fast-rcnn
$cd lib
$sudo gedit setup.py
2.1对setup.py进行修改:
...
...
#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']]
# ),
2.2进入fast-rcnn修改nms_wrapper.py
...
#from nms.gpu_nms import gpu_nms
...
def nms(dets, thresh, force_cpu=True):
...
进入tools修改test_net.py和train_net.py
test_net.py中 caffe.set_mode_gpu() 修改为caffe.set_mode_cpu()
train_net.py中caffe.set_mode_gpu() 修改为caffe.set_mode_cpu()
进入py-faster-rcnn/lib然后进行make
$make
3.在py-faster-rcnn/caffe-faster-rcnn中
$cp Makefile.config.example Makefile.config
$sudo gedit Makefile.config
对打开的文件进行修改
CPU_ONLY :=1 取消注释
WITH_PYTHON_LAYER :=1 取消注释
在该目录下执行:make-j8 && make pycaffe
$make -j8
$make pycaffe
4. 下载数据
$cd py-faster-rcnn/data/scripts
$./fetch_faster_rcnn_models.sh
最后执行:$python ./demo.py --cpu
linux14.04 下安装好了python+opencv+caffe
1.从github上clone项目文件,注意:一定要在clone时加入--recursive参数,避免不必要的麻烦,也不要直接下载:
$git clone --recursive https://github.com/rbgirshick/py-faster-rcnn.git
2.进入py-fast-rcnn文件夹,选择lib文件,使用gedit编辑器打开setup.py文件,对里边的代码进行修改:
$cd py-fast-rcnn
$cd lib
$sudo gedit setup.py
2.1对setup.py进行修改:
...
...
#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']]
# ),
2.2进入fast-rcnn修改nms_wrapper.py
...
#from nms.gpu_nms import gpu_nms
...
def nms(dets, thresh, force_cpu=True):
...
进入tools修改test_net.py和train_net.py
test_net.py中 caffe.set_mode_gpu() 修改为caffe.set_mode_cpu()
train_net.py中caffe.set_mode_gpu() 修改为caffe.set_mode_cpu()
进入py-faster-rcnn/lib然后进行make
$make
3.在py-faster-rcnn/caffe-faster-rcnn中
$cp Makefile.config.example Makefile.config
$sudo gedit Makefile.config
对打开的文件进行修改
CPU_ONLY :=1 取消注释
WITH_PYTHON_LAYER :=1 取消注释
在该目录下执行:make-j8 && make pycaffe
$make -j8
$make pycaffe
4. 下载数据
$cd py-faster-rcnn/data/scripts
$./fetch_faster_rcnn_models.sh
最后执行:$python ./demo.py --cpu