ubuntu16.04+cuda8.0+cudnn5.1+caffe------caffe安装与编译

8 篇文章 0 订阅
5 篇文章 0 订阅
opencv
步骤1:sudo make all -j4
遇到问题:
CXX src/caffe/layers/data_layer.cpp
src/caffe/layers/data_layer.cpp:2:33: fatal error: opencv2/core/core.hpp: 没有那个文件或目录
compilation terminated.
Makefile:579: recipe for target '.build_release/src/caffe/layers/data_layer.o' failed
make: *** [.build_release/src/caffe/layers/data_layer.o] Error 1
make: *** 正在等待未完成的任务....

遇到问题:
 这里附一下 caffe Makefile.config 源码#CUDA architecture setting: going with all of them.
# For CUDA < 6.0, comment the *_50 lines for compatibility.
CUDA_ARCH := -gencode arch=compute_20,code=sm_20 \
        -gencode arch=compute_20,code=sm_21 \
        -gencode arch=compute_30,code=sm_30 \
        -gencode arch=compute_35,code=sm_35 \
        -gencode arch=compute_50,code=sm_50 \
        -gencode arch=compute_50,code=compute_50
 
保留所有设置的话,编译的时候出现warning

nvcc warning : The 'compute_20', 'sm_20', and 'sm_21' architectures are deprecated, and may be removed in a future release (Use -Wno-deprecated-gpu-targets to suppress warning)

delete:

-gencode arch=compute_20,code=sm_20 \

     -gencode arch=compute_20,code=sm_21 \

步骤2:sudo make test

CXX/LD -o .build_release/test/test_all.testbin src/caffe/test/test_caffe_main.cpp

/usr/bin/ld: warning: libopencv_imgproc.so.3.1, needed by /usr/local/opencv310/lib/libopencv_imgcodecs.so, may conflict with libopencv_imgproc.so.2.4
/usr/bin/ld: warning: libopencv_core.so.3.1, needed by /usr/local/opencv310/lib/libopencv_imgcodecs.so, may conflict with libopencv_core.so.2.4
/usr/bin/ld: .build_release/src/caffe/test/test_io.o: undefined reference to symbol '_ZN2cv6String10deallocateEv'
//usr/local/opencv310/lib/libopencv_core.so.3.1: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
Makefile:604: recipe for target '.build_release/test/test_all.testbin' failed
make: *** [.build_release/test/test_all.testbin] Error 1


步骤3:sudo make -j4 runtest

[ RUN      ] ConvolutionLayerTest/1.Test0DConvolution
[       OK ] ConvolutionLayerTest/1.Test0DConvolution (0 ms)
[ RUN      ] ConvolutionLayerTest/1.TestGradient
[       OK ] ConvolutionLayerTest/1.TestGradient (53 ms)
[ RUN      ] ConvolutionLayerTest/1.TestNDAgainst2D
[       OK ] ConvolutionLayerTest/1.TestNDAgainst2D (195 ms)
[ RUN      ] ConvolutionLayerTest/1.TestDilatedConvolution
[       OK ] ConvolutionLayerTest/1.TestDilatedConvolution (1 ms)
[ RUN      ] ConvolutionLayerTest/1.Test1x1Gradient
[       OK ] ConvolutionLayerTest/1.Test1x1Gradient (457 ms)
[ RUN      ] ConvolutionLayerTest/1.TestSimpleConvolution
[       OK ] ConvolutionLayerTest/1.TestSimpleConvolution (0 ms)
[----------] 15 tests from ConvolutionLayerTest/1 (1109 ms total)

[----------] Global test environment tear-down
[==========] 2123 tests from 281 test cases ran. (349521 ms total)
[  PASSED  ] 2123 tests.

步骤4:caffe 安装测试

sudo apt-get install python-numpy python-setuptools python-pip cython python-skimage python-protobuf

make pycaffe

cd python

python

import caffe #测试安装成功


jennifer@jennifer-pc:/usr/local/caffe$sudo apt-get install python-numpy python-setuptools python-pip cython python-skimage python-protobuf

jennifer@jennifer-pc:/usr/local/caffe$ sudo make pycaffe
CXX/LD -o python/caffe/_caffe.so python/caffe/_caffe.cpp
touch python/caffe/proto/__init__.py
PROTOC (python) src/caffe/proto/caffe.proto
jennifer@jennifer-pc:/usr/local/caffe$ cd python
jennifer@jennifer-pc:/usr/local/caffe/python$ python
Python 3.5.2 |Anaconda 4.2.0 (64-bit)| (default, Jul  2 2016, 17:53:06)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import caffe
>>>
caffe安装测试成功

jennifer@jennifer-pc:/usr/local/caffe$ ./build/tools/caffe time --gpu 0 --model ./models/bvlc_alexnet/deploy.prototxt
I0206 13:33:56.932345 15398 caffe.cpp:348] Use GPU with device ID 0
E0206 13:33:57.220649 15398 common.cpp:114] Cannot create Cublas handle. Cublas won't be available.
I0206 13:33:57.228081 15398 net.cpp:51] Initializing net from parameters:
name: "AlexNet"

。。。。。。。

I0206 13:33:57.228345 15398 layer_factory.hpp:77] Creating layer data
I0206 13:33:57.228356 15398 net.cpp:84] Creating Layer data
I0206 13:33:57.228363 15398 net.cpp:380] data -> data
F0206 13:33:58.141152 15398 syncedmem.hpp:22] Check failed: error == cudaSuccess (30 vs. 0)  unknown error

一脸mengbi,后来查资料原来是要加上sudo执行,好吧:

 sudo ./build/tools/caffe time --gpu 0 --model ./models/bvlc_alexnet/deploy.prototxt

I0206 13:44:28.654764 15586 caffe.cpp:409]      pool5    forward: 0.0483789 ms.
I0206 13:44:28.654769 15586 caffe.cpp:412]      pool5    backward: 0.00116928 ms.
I0206 13:44:28.654773 15586 caffe.cpp:409]        fc6    forward: 2.24384 ms.
I0206 13:44:28.654778 15586 caffe.cpp:412]        fc6    backward: 3.33728 ms.
I0206 13:44:28.654783 15586 caffe.cpp:409]      relu6    forward: 0.00932288 ms.
I0206 13:44:28.654786 15586 caffe.cpp:412]      relu6    backward: 0.00099648 ms.
I0206 13:44:28.654791 15586 caffe.cpp:409]      drop6    forward: 0.0211648 ms.
I0206 13:44:28.654795 15586 caffe.cpp:412]      drop6    backward: 0.0011392 ms.
I0206 13:44:28.654817 15586 caffe.cpp:409]        fc7    forward: 0.987882 ms.
I0206 13:44:28.654822 15586 caffe.cpp:412]        fc7    backward: 1.54874 ms.
I0206 13:44:28.654826 15586 caffe.cpp:409]      relu7    forward: 0.00878528 ms.
I0206 13:44:28.654831 15586 caffe.cpp:412]      relu7    backward: 0.00106304 ms.
I0206 13:44:28.654835 15586 caffe.cpp:409]      drop7    forward: 0.0153037 ms.
I0206 13:44:28.654839 15586 caffe.cpp:412]      drop7    backward: 0.00114112 ms.
I0206 13:44:28.654844 15586 caffe.cpp:409]        fc8    forward: 0.281272 ms.
I0206 13:44:28.654848 15586 caffe.cpp:412]        fc8    backward: 0.400394 ms.
I0206 13:44:28.654852 15586 caffe.cpp:409]       prob    forward: 0.0158477 ms.
I0206 13:44:28.654856 15586 caffe.cpp:412]       prob    backward: 0.00114048 ms.
I0206 13:44:28.654866 15586 caffe.cpp:417] Average Forward pass: 12.1988 ms.
I0206 13:44:28.654872 15586 caffe.cpp:419] Average Backward pass: 15.5891 ms.
I0206 13:44:28.654881 15586 caffe.cpp:421] Average Forward-Backward: 27.86 ms.
I0206 13:44:28.654887 15586 caffe.cpp:423] Total Time: 1393 ms.
I0206 13:44:28.654892 15586 caffe.cpp:424] *** Benchmark ends ***

×*×*×*×*×*×*×**×*×*×*×*×*×*×*××*×*×*×*×*×*×*×*×*××*×

问题:import caffe出错,或者在caffe目录下:

$ sudo make pycaffe

如果出现“make: Nothing to be done for `pycaffe'.”

使用

$ sudo make clean

之后运行
 $ sudo make pycaffe




评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值