LoginSignup
0
0

More than 5 years have passed since last update.

Faster R-CNN + cudnn5.1.5 が動かない場合の対処法

Posted at

症状

2016/12/25現在, Faster R-CNNをコンパイルし,動かす際に,以下の問題が生じる.

  1. caffe-fast-rcnnのコンパイル時に下記のエラーがでてコンパイルできない

    type "int" is incompatible with parameter of type "cudnnNanPropagation_t"

  2. 上記エラーになんとか対処しても、実行時に下記のエラーがでて停止する

    File "/mnt/mqs02/home/ahashimoto/py-faster-rcnn/tools/../lib/rpn/proposal_target_layer.py", line 167, in _sample_rois
    fg_inds = npr.choice(fg_inds, size=fg_rois_per_this_image, replace=False)
    File "mtrand.pyx", line 1070, in mtrand.RandomState.choice (numpy/random/mtrand/mtrand.c:8044)
    TypeError: 'numpy.float64' object cannot be interpreted as an index
    

症状1の原因

  • おそらく,まだfast-rcnnが最新のcudnn (cudnn5.1.5)に対応していないため,型の不一致によるエラーが起きている.

症状1への対処方法

  • 最新のcaffeは対応しているので,それをマージする.
  • 参考にしたページ: https://github.com/rbgirshick/py-faster-rcnn/issues/237

  • 手順(faster-rcnnのルートディレクトリで実行)
     1. 最新のpy-faster-rcnnのリポジトリで以下を実行し,最新のcaffeとfast-rcnnをマージする. 

     cd caffe-fast-rcnn  
     git remote add caffe https://github.com/BVLC/caffe.git  
     git fetch caffe  
     git merge caffe/master
    

     2. include/caffe/layers/python_layer.hppを開き,下記の記述を消去

    self_.attr("phase") = static_cast<int>(this->phase_)

 3. caffe-fast-rcnnをコンパイルする.

症状2の原因

同じタイミングでnumpyのバージョンアップにも対応が必要になっている??

症状2への対処方法

  • エラーを起こしているpythonのコードを手動で修正する
  • 参考にしたページ:https://github.com/rbgirshick/py-faster-rcnn/issues/13

  • 手順(faster-rcnnのルートディレクトリで実行)

    1. 該当ファイルを開く vim lib/rpn/proposal_target_layer.py
    2. 1箇所目(167行目付近)の修正する.

      • 変更前

        if fg_inds.size > 0:
                        fg_inds = npr.choice(fg_inds, size=fg_rois_per_this_image, replace=False)
        
      • 変更後

        if fg_inds.size > 0:
                        fg_inds = [int(v) for v in fg_inds]
                        fg_inds = npr.choice(fg_inds, size=int(fg_rois_per_this_image), replace=False)
        
    3. 2箇所目(178行目付近)の修正する.

      • 変更前

        if bg_inds.size > 0:
                        bg_inds = npr.choice(bg_inds, size=bg_rois_per_this_image, replace=False)
        
      • 変更後

        if bg_inds.size > 0:
                        bg_inds = [int(v) for v in bg_inds]
                        bg_inds = npr.choice(bg_inds, size=int(bg_rois_per_this_image), replace=False)
        
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0