Faster RCNN CPU安裝記錄

參考博客:Faster-RCNN+ZF用自己的數據集訓練模型(Python版本)

目前執行了2中的(1)(2),由於在make時遇到了錯誤(無GPU的原因),搜索了下面的博客進行安裝

參考博客:Faster R-CNN算法的Caffe實現

  遇到的問題與相關不同:

1、cython編譯出錯

python setup.py build_ext --inplace
Traceback (most recent call last):
  File "setup.py", line 56, in <module>
    CUDA = locate_cuda()
  File "setup.py", line 44, in locate_cuda
    raise EnvironmentError('The nvcc binary could not be '
EnvironmentError: The nvcc binary could not be located in your $PATH. Either add it to your path, or set $CUDAHOME
Makefile:2: recipe for target 'all' failed
make: *** [all] Error 1
解決方案:

        1)註釋掉setup.py中的CUDA = locate_cuda()

      報錯:

python setup.py build_ext --inplace
Traceback (most recent call last):
  File "setup.py", line 125, in <module>
    library_dirs=[CUDA['lib64']],
NameError: name 'CUDA' is not defined
Makefile:2: recipe for target 'all' failed
make: *** [all] Error 1

      2)尋找setup中所有與gpu有關的代碼 註釋掉

#    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']]
#    ),
提示:(這應該是成功了吧)
python setup.py build_ext --inplace
running build_ext
cythoning utils/bbox.pyx to utils/bbox.c
building 'utils.cython_bbox' extension
creating build
creating build/temp.linux-x86_64-2.7
creating build/temp.linux-x86_64-2.7/utils
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/home/lys/.local/lib/python2.7/site-packages/numpy/core/include -I/usr/include/python2.7 -c utils/bbox.c -o build/temp.linux-x86_64-2.7/utils/bbox.o -Wno-cpp -Wno-unused-function
x86_64-linux-gnu-gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -Wl,-z,relro -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wl,-Bsymbolic-functions -Wl,-z,relro -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security build/temp.linux-x86_64-2.7/utils/bbox.o -o /home/lys/py-faster-rcnn/lib/utils/cython_bbox.so
cythoning nms/cpu_nms.pyx to nms/cpu_nms.c
building 'nms.cpu_nms' extension
creating build/temp.linux-x86_64-2.7/nms
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/home/lys/.local/lib/python2.7/site-packages/numpy/core/include -I/usr/include/python2.7 -c nms/cpu_nms.c -o build/temp.linux-x86_64-2.7/nms/cpu_nms.o -Wno-cpp -Wno-unused-function
x86_64-linux-gnu-gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -Wl,-z,relro -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wl,-Bsymbolic-functions -Wl,-z,relro -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security build/temp.linux-x86_64-2.7/nms/cpu_nms.o -o /home/lys/py-faster-rcnn/lib/nms/cpu_nms.so
cythoning pycocotools/_mask.pyx to pycocotools/_mask.c
building 'pycocotools._mask' extension
creating build/temp.linux-x86_64-2.7/pycocotools
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/home/lys/.local/lib/python2.7/site-packages/numpy/core/include -Ipycocotools -I/usr/include/python2.7 -c pycocotools/maskApi.c -o build/temp.linux-x86_64-2.7/pycocotools/maskApi.o -Wno-cpp -Wno-unused-function -std=c99
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/home/lys/.local/lib/python2.7/site-packages/numpy/core/include -Ipycocotools -I/usr/include/python2.7 -c pycocotools/_mask.c -o build/temp.linux-x86_64-2.7/pycocotools/_mask.o -Wno-cpp -Wno-unused-function -std=c99
x86_64-linux-gnu-gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -Wl,-z,relro -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wl,-Bsymbolic-functions -Wl,-z,relro -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security build/temp.linux-x86_64-2.7/pycocotools/maskApi.o build/temp.linux-x86_64-2.7/pycocotools/_mask.o -o /home/lys/py-faster-rcnn/lib/pycocotools/_mask.so
rm -rf build


2、Makefile.config 中的 CPU_ONLY=1的註釋去掉

# CPU-only switch (uncomment to build without GPU support).
CPU_ONLY := 1
參考博客:Faster R-CNN CPU環境搭建

遇到的問題與相關不同

1、caffe、opencv之前安裝完成,未執行1; caffe-fast-rcnn上一步make完成,未執行2

2、運行./fetch_faster_rcnn_models.sh 時連接超時

   解決:1)使用第一篇博客在評論中提供的下載地址下載py-faster-rcnn faster_rcnn_models.tgz。網址點擊Download下載下來一個種子,使用百度雲或者迅雷下載數據:

http://academictorrents.com/details/cca56021739c8a75af3b58f536d4930266c25d5e/tech

等待下載之餘運行了一下demo.py出現了以下錯誤:缺少matplotlib,使用

sudo apt-get install python-matplotlib#安裝matplotlib

Traceback (most recent call last):
  File "./demo.py", line 21, in <module>
    import matplotlib.pyplot as plt
  File "/home/lys/.local/lib/python2.7/site-packages/matplotlib/pyplot.py", line 115, in <module>
    _backend_mod, new_figure_manager, draw_if_interactive, _show = pylab_setup()
  File "/home/lys/.local/lib/python2.7/site-packages/matplotlib/backends/__init__.py", line 32, in pylab_setup
    globals(),locals(),[backend_name],0)
  File "/home/lys/.local/lib/python2.7/site-packages/matplotlib/backends/backend_tkagg.py", line 6, in <module>
    from six.moves import tkinter as Tk
  File "/home/lys/.local/lib/python2.7/site-packages/six.py", line 203, in load_module
    mod = mod._resolve()
  File "/home/lys/.local/lib/python2.7/site-packages/six.py", line 115, in _resolve
    return _import_module(self.mod)
  File "/home/lys/.local/lib/python2.7/site-packages/six.py", line 82, in _import_module
    __import__(name)
  File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 42, in <module>
    raise ImportError, str(msg) + ', please install the python-tk package'
ImportError: No module named _tkinter, please install the python-tk package

安裝之後果然就是model還沒下載的錯誤啦,安心等着下載完。。。。。。希望不會再出錯,祈禱


下載完成後將壓縮包解壓到.../py-faster-rcnn/data/faster_rcnn_models,在.../py-faster-rcnn/tools/下運行 python demo.py --cpu

出現如下錯誤:

Traceback (most recent call last):
  File "/home/lys/py-faster-rcnn/tools/../lib/rpn/proposal_layer.py", line 10, in <module>
    import yaml
ImportError: No module named yaml
Traceback (most recent call last):
  File "demo.py", line 135, in <module>
    net = caffe.Net(prototxt, caffemodel, caffe.TEST)
SystemError: NULL result without error in PyObject_Call

使用sudo apt-get install python-yaml進行安裝yaml(YAML是一種直觀的能夠被電腦識別的的數據序列化格式,容易被人類閱讀,並且容易和腳本語言交互。YAML類似於XML,但是語法比XML簡單得多,對於轉化成數組或可以hash的數據時是很簡單有效的.yaml在python中的使用 )

再次執行demo.py,運行成功。

複製一張博客的結果圖,不知道結果存哪去了,好像並沒有存

1

發佈了32 篇原創文章 · 獲贊 16 · 訪問量 7萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章