您的位置:首页 > Web前端

简略版ubuntu14.04下安装caffe所遇到的问题解决

2016-06-12 21:47 681 查看
转自http://blog.csdn.net/doral/article/details/45620857
【问题1】对于双显卡的笔记本而已,通过*.run方式安装CUDA时,重启后会黑屏出现无法进入桌面,只能进入tty

解决方法:采用*.deb方式来安装CUDA,不需要另外安装NVIDIA驱动(CUDA-7.0自带的就是最新的驱动),同时也不需关闭lightdm服务进入tty终端来安装。

在CUDA官网 https://developer.nvidia.com/cuda-downloads下载deb离线包安装即可。

【问题2】error: ‘CUDNN_POOLING_AVERAGE_COUNT_INCLUDE_PADDING’ was not declared in this scope(安装cuDNN时,make 未声明错误)

[plain] view
plain copy

In file included from ./include/caffe/util/device_alternate.hpp:40:0,  

                 from ./include/caffe/common.hpp:19,  

                 from ./include/caffe/util/math_functions.hpp:9,  

                 from src/caffe/util/im2col.cpp:6:  

./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:117:13: error: ‘CUDNN_POOLING_AVERAGE_COUNT_INCLUDE_PADDING’ was not declared in this scope  

     *mode = CUDNN_POOLING_AVERAGE_COUNT_INCLUDE_PADDING;  

             ^  

Makefile:510: recipe for target '.build_release/src/caffe/util/im2col.o' failed  

make: *** [.build_release/src/caffe/util/im2col.o] Error 1  

make: *** Waiting for unfinished jobs....  

解决方法:原因是之前用cuDNN版本cudnn-6.5-linux-x64-R2-rc1.tgz过低,不适合当前的caffe版本,在cuDNN官网https://developer.nvidia.com/cuDNN注册下载目前最新的cuDNN版本cudnn-6.5-linux-x64-v2.tgz即可。

【问题3】Check failed: status == CUDNN_STATUS_SUCCESS (6 vs. 0)  CUDNN_STATUS_ARCH_MISMATCH (make runtest 的check错误)

[plain] view
plain copy

F0510 12:25:55.208068  9923 cudnn_softmax_layer.cpp:19] Check failed: status == CUDNN_STATUS_SUCCESS (6 vs. 0)  CUDNN_STATUS_ARCH_MISMATCH  

*** Check failure stack trace: ***  

    @     0x7f13a97c7a0d  google::LogMessage::Fail()  

    @     0x7f13a97c98c0  google::LogMessage::SendToLog()  

    @     0x7f13a97c75d2  google::LogMessage::Flush()  

    @     0x7f13a97ca2de  google::LogMessageFatal::~LogMessageFatal()  

    @     0x7f13a63347a6  caffe::CuDNNSoftmaxLayer<>::LayerSetUp()  

    @     0x7f13a633afad  caffe::SoftmaxWithLossLayer<>::LayerSetUp()  

    @           0x47d375  caffe::GradientChecker<>::CheckGradientExhaustive()  

    @           0x51e078  caffe::SoftmaxWithLossLayerTest_TestGradientUnnormalized_Test<>::TestBody()  

    @           0x74f923  testing::internal::HandleExceptionsInMethodIfSupported<>()  

    @           0x747aba  testing::Test::Run()  

    @           0x747c08  testing::TestInfo::Run()  

    @           0x747ce5  testing::TestCase::Run()  

    @           0x748678  testing::internal::UnitTestImpl::RunAllTests()  

    @           0x748943  testing::UnitTest::Run()  

    @           0x44722a  main  

    @     0x7f13a5654a40  (unknown)  

    @           0x44c409  _start  

Makefile:465: recipe for target 'runtest' failed  

make: *** [runtest] Aborted (core dumped)  

解决方法:在cuDNN安装包中的INSTALL.txt可以看到

[html] view
plain copy

PREREQUISITES  

  

    CUDA 6.5 and a GPU of compute capability 3.0 or higher are required.  

意思是GPU的加速能力不够,CUDNN只支持CUDA Capability 3.0以上的GPU加速,而我的笔记本显卡GT635M才2.1的加速能力,在其他3.0以上的显卡运行正常,因此选择不启用cuDNN加速,在Makefile.config中注释USE_CUDNN行。

【问题4】/usr/bin/ld: cannot find -lopenblas

解决方法

 一般出现这种错误有以下几种原因:

1.系统缺乏对应的库文件;

2.版本不对应;

3.库文件的链接错误;

4.库文件路径设置问题。

 

对应第一第二种情况,可以通过下载安装lib来解决,ubuntu大多数可以直接通过apt-get来安装:

 

[html] view
plain copy

apt-get install libxxx-dev  

 一般遇到这种问题笔者第一时间也是会去检查系统是否已安装该lib或者是否已选择正确版本,

如果还是不能解决问题,那么,引起错误的原因不是链接错误就是库文件路径问题。

 

 通过find或者locate指令定位到链接文件,查看链接文件是否正确的指向了我们希望的lib,如果不是,用 ln -sf */libxxx.so.x */libxxx.so 指令修改它。

 如果是库文件路径引发的问题,可以到/etc/ld.so.conf.d目录下,修改其中任意一份conf文件,(可以自建conf,以方便识别)将lib所在目录写进去,然后在终端输入 ldconfig 更新缓存。      

这里,就直接修改Makefile中BLAS_INCLUDE和BLAS_LIB

[html] view
plain copy

# BLAS choice:  

# atlas for ATLAS (default)  

# mkl for MKL  

# open for OpenBlas  

BLAS := open  

# Custom (MKL/ATLAS/OpenBLAS) include and lib directories.  

# Leave commented to accept the defaults for your choice of BLAS  

# (which should work)!  

BLAS_INCLUDE := /opt/OpenBLAS/include  

BLAS_LIB := /opt/OpenBLAS/lib  

【问题5】g++版本过高
error: kernel launches from templates are not allowed in system files 1
error detected in the compilation of "/tmp/tmpxft_00005657_00000000-10_math_functions.cpp4.ii".


解决方法

在Ubuntu14.04中会出现g++版本过高的问题,Ubuntu15.04则正常

[html] view
plain copy

sudo apt-get install gcc-4.6 g++-4.6 gcc-4.6-multilib g++-4.6-multilib  

sudo update-alternatives --remove-all gcc  

sudo update-alternatives --remove-all g++  

sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.6 20  

sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.6 20  

sudo update-alternatives --install /usr/bin/cc cc /usr/bin/gcc 30  

sudo update-alternatives --set cc /usr/bin/gcc  

sudo update-alternatives --install /usr/bin/c++ c++ /usr/bin/g++ 30  

sudo update-alternatives --set c++ /usr/bin/g++  

sudo update-alternatives --config gcc  

sudo update-alternatives --config g++  

修改makefile,指定g++版本

[html] view
plain copy

CXX := /usr/bin/g++-4.6  

【问题6】

[html] view
plain copy

./create_mnist.sh: 16: ./create_mnist.sh: build/examples/mnist/convert_mnist_data.bin: not found  

解决方法

新版caffe都需要从根目录上执行,不然可能会遇到这个错误

默认切换到了该工作目录 home/username/caffe-master,测试Caffe是否工作正常

[html] view
plain copy

$ sh data/mnist/get_mnist.sh  % 数据预处理  

$ sh examples/mnist/create_mnist.sh % 生成mnist-train-lmdb 和 mnist-train-lmdb文件夹,这里包含了lmdb格式的数据集  

$ sh examples/mnist/train_lenet.sh % 训练mnist  

【问题7】

在用pycaffe在做可视化时,出现如下错误

[html] view
plain copy

ImportError: No module named skimage  

解决方法:

After installing cython , and then scikit-image.

[html] view
plain copy

pip install cython  

pip install scikit-image  
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: