1. 程式人生 > >Faster R-cnn和Cudnn5.0衝突解決過程記錄

Faster R-cnn和Cudnn5.0衝突解決過程記錄

執行Faster R-cnn編譯時遇到了如下問題

In file included from ./include/caffe/util/device_alternate.hpp:40:0,  
                 from ./include/caffe/common.hpp:19,  
                 from src/caffe/syncedmem.cpp:1:  
./include/caffe/util/cudnn.hpp: In function ‘void caffe::cudnn::createPoolingDesc(cudnnPoolingStruct**, caffe::PoolingParameter_PoolMethod, cudnnPoolingMode_t*, int, int, int, int, int, int)’:  
./include/caffe/util/cudnn.hpp:127:41: error: too few arguments to function ‘cudnnStatus_t cudnnSetPooling2dDescriptor(cudnnPoolingDescriptor_t, cudnnPoolingMode_t, cudnnNanPropagation_t, int, int, int, int, int, int)’  
         pad_h, pad_w, stride_h, stride_w));  
                                         ^  
./include/caffe/util/cudnn.hpp:15:28: note: in definition of macro ‘CUDNN_CHECK’  
     cudnnStatus_t status = condition; \  
                            ^  
In file included from ./include/caffe/util/cudnn.hpp:5:0,  
                 from ./include/caffe/util/device_alternate.hpp:40,  
                 from ./include/caffe/common.hpp:19,  
                 from src/caffe/syncedmem.cpp:1:  
/usr/include/cudnn.h:803:27: note: declared here  
 cudnnStatus_t CUDNNWINAPI cudnnSetPooling2dDescriptor(  
                           ^  
Makefile:563: recipe for target '.build_release/src/caffe/syncedmem.o' failed  
make: *** [.build_release/src/caffe/syncedmem.o] Error 1  
make: *** Waiting for unfinished jobs....  
In file included from ./include/caffe/util/device_alternate.hpp:40:0,  
                 from ./include/caffe/common.hpp:19,  
                 from ./include/caffe/blob.hpp:8,  
                 from src/caffe/blob.cpp:4:  
./include/caffe/util/cudnn.hpp: In function ‘void caffe::cudnn::createPoolingDesc(cudnnPoolingStruct**, caffe::PoolingParameter_PoolMethod, cudnnPoolingMode_t*, int, int, int, int, int, int)’:  
./include/caffe/util/cudnn.hpp:127:41: error: too few arguments to function ‘cudnnStatus_t cudnnSetPooling2dDescriptor(cudnnPoolingDescriptor_t, cudnnPoolingMode_t, cudnnNanPropagation_t, int, int, int, int, int, int)’  
         pad_h, pad_w, stride_h, stride_w));  

出錯原因應該為Faster R-cnn 和cudnn5.0不相容,解決辦法一是降低更換cudnn的版本,另一種是提高caffe的版本。在下還搜到了大神的一個解決辦法。

http://blog.csdn.net/rzjmpb/article/details/52373012,程式碼貼在下面

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

鄙人愚鈍,對於git合併命令不是很熟悉,一週折騰merge命令還是沒有成功,我把過程附到最後,希望大牛們看到此文章能指點一二。

最後解決辦法還是在csdn上一番苦尋找到的,參考了卜居和阿·甘的部落格,感謝兩位的分享。直接貼連結比較合適,後期我還會給出我的caffe-fast-rcnn版本,裡面改了一些其它的資料,由於沒有詳細記錄,直接貼結果方便大家使用,大家可以直接下載替換faster-rcnn中的caffe

http://blog.csdn.net/kexinmcu/article/details/53178428(阿甘)

http://blog.csdn.net/kkk584520/article/details/51163564(卜居

附:

但在執行最後一步(合併)的時候,又遇到了棘手的問題。

error: Your local changes to the following files would be overwritten by merge:  
    Makefile  
Please, commit your changes or stash them before you can merge.  
error: The following untracked working tree files would be overwritten by merge:  
    .github/ISSUE_TEMPLATE.md  
    cmake/Modules/FindNCCL.cmake  
    docker/README.md  
    docker/cpu/Dockerfile  
    docker/gpu/Dockerfile  
    docs/install_apt_debian.md  
    docs/tutorial/layers/absval.md  
    docs/tutorial/layers/accuracy.md  
    docs/tutorial/layers/argmax.md  
    docs/tutorial/layers/batchnorm.md  
    docs/tutorial/layers/batchreindex.md  
    docs/tutorial/layers/bias.md  
    docs/tutorial/layers/bnll.md  
    docs/tutorial/layers/concat.md  
    docs/tutorial/layers/contrastiveloss.md  
    docs/tutorial/layers/convolution.md  
    docs/tutorial/layers/crop.md  
    docs/tutorial/layers/data.md  
    docs/tutorial/layers/deconvolution.md  
    docs/tutorial/layers/dropout.md  
    docs/tutorial/layers/dummydata.md  
    docs/tutorial/layers/eltwise.md  
    docs/tutorial/layers/elu.md  
    docs/tutorial/layers/embed.md  
    docs/tutorial/layers/euclideanloss.md  
    docs/tutorial/layers/exp.md  
    docs/tutorial/layers/filter.md  
    docs/tutorial/layers/flatten.md  
    docs/tutorial/layers/hdf5data.md  
    docs/tutorial/layers/hdf5output.md  
    docs/tutorial/layers/hingeloss.md  
    docs/tutorial/layers/im2col.md  
    docs/tutorial/layers/imagedata.md  
    docs/tutorial/layers/infogainloss.md  
    docs/tutorial/layers/innerproduct.md  
    docs/tutorial/layers/input.md  
    docs/tutorial/layers/log.md  
    docs/tutorial/layers/lrn.md  
    docs/tutorial/layers/lstm.md  
    docs/tutorial/layers/memorydata.md  
    docs/tutorial/layers/multinomiallogisticloss.md  
    docs/tutorial/layers/mvn.md  
    docs/tutorial/layers/parameter.md  
    docs/tutorial/layers/pooling.md  
    docs/tutorial/layers/power.md  
    docs/tutorial/layers/prelu.md  
    docs/tutorial/layers/python.md  
    docs/tutorial/layers/recurrent.md  
    docs/tutorial/layers/reduction.md  
    docs/tutorial/layers/relu.md  
    docs/tutorial/layers/reshape.md  
    docs/tutorial/layers/rnn.md  
    docs/tutorial/layers/scale.md  
    docs/tutorial/layers/sigmoid.md  
    docs/tutorial/layers/sigmoidcrossentropyloss.md  
    docs/tutorial/layers/silence.md  
    docs/tutorial/layers/slice.md  
    docs/tutorial/layers/softmax.md  
    docs/tutorial/layers/softmaxwithloss.md  
    docs/tutorial/layers/split.md  
    docs/tutorial/layers/spp.md  
    docs/tutorial/layers/tanh.md  
    docs/tutorial/layers/threshold.md  
    docs/tutorial/layers/tile.md  
    docs/tutorial/layers/windowdata.md  
    examples/02-fine-tuning.ipynb  
    examples/brewing-logreg.ipynb  
    examples/images/cat gray.jpg  
    examples/mnist/train_lenet_docker.sh  
    examples/pascal-multilabel-with-datalayer.ipynb  
    examples/pycaffe/layers/pascal_multilabel_datalayers.py  
    examples/pycaffe/tools.py  
    include/caffe/layers/crop_layer.hpp  
    include/caffe/layers/input_layer.hpp  
    include/caffe/layers/lstm_layer.hpp  
    include/caffe/layers/parameter_layer.hpp  
    include/caffe/layers/recurrent_layer.hpp  
    include/caffe/layers/rnn_layer.hpp  
    include/caffe/util/nccl.hpp  
    python/caffe/coord_map.py  
    python/caffe/test/test_coord_map.py  
    python/caffe/test/test_draw.py  
    python/train.py  
    scripts/split_caffe_proto.py  
    scripts/travis/build.sh  
    scripts/travis/configure-cmake.sh  
    scripts/travis/configure-make.sh  
    scripts/travis/configure.sh  
    scripts/travis/defaults.sh  
    scripts/travis/install-deps.sh  
    scripts/travis/install-python-deps.sh  
    scripts/travis/setup-venv.sh  
    scripts/travis/test.sh  
    src/caffe/layers/crop_layer.cpp  
    src/caffe/layers/crop_layer.cu  
    src/caffe/layers/input_layer.cpp  
    src/caffe/layers/lstm_layer.cpp  
    src/caffe/layers/lstm_unit_layer.cpp  
    src/caffe/layers/lstm_unit_layer.cu  
    src/caffe/layers/parameter_layer.cpp  
    src/caffe/layers/recurrent_layer.cpp  
    src/caffe/layers/recurrent_layer.cu  
    src/caffe/layers/rnn_layer.cpp  
    src/caffe/test/test_crop_layer.cpp  
    src/caffe/test/test_lstm_layer.cpp  
    src/caffe/test/test_rnn_layer.cpp  
Please move or remove them before you can merge.  
Aborting  
不是很懂git工具的合併命令,但一番苦找,找到了
sudo git clean -d -fx

成功移除合併多餘的部分,移除後的部分為
sudo git clean -d -fx
Removing .github/
Removing docker/
Removing docs/tutorial/layers/

再次合併

sudo git merge caffe/master
Auto-merging src/caffe/proto/caffe.proto
Auto-merging src/caffe/layers/dropout_layer.cpp
Removing src/caffe/data_reader.cpp
Removing scripts/travis/travis_setup_makefile_config.sh
Removing scripts/travis/travis_install.sh
Removing scripts/travis/travis_build_and_test.sh
Auto-merging python/caffe/_caffe.cpp
CONFLICT (content): Merge conflict in python/caffe/_caffe.cpp
Auto-merging python/caffe/__init__.py
CONFLICT (content): Merge conflict in python/caffe/__init__.py
Auto-merging include/caffe/layers/python_layer.hpp
Auto-merging include/caffe/layer.hpp
Removing include/caffe/data_reader.hpp
Removing examples/hdf5_classification/solver.prototxt
Removing examples/hdf5_classification/nonlinear_solver.prototxt
Removing examples/03-fine-tuning.ipynb
Removing examples/02-brewing-logreg.ipynb
Auto-merging LICENSE
CONFLICT (content): Merge conflict in LICENSE
Automatic merge failed; fix conflicts and then commit the result.

此次合併後雖仍有部分檔案沒有合併成功,但已經不影響編譯和使用