我最近安装安装了老版本的caffe,安装过程真是两个字“想死”,所以我的错误一般都是比较经典的。

我是使用cuda的版本,所以可能会出现undefined refference to cudnn.h。这个时候该做的就是把所有版本全都装一遍试试,而如果不追求速度的话,直接转cudnn1,最原始的版本,一般不会有问题。gpu版本一定是比cpu快n倍的,这个不用怀疑。

在编译caffe的时候,报错:

  1. couldn't find hdf5.h

在网上很容易找到普通解决方法:

  1. --- INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include
  2. +++ INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include /usr/include/hdf5/serial/
  3.  
  4. --- LIBRARIES += glog gflags protobuf boost_system boost_filesystem m hdf5_hl hdf5
  5. +++ LIBRARIES += glog gflags protobuf boost_system boost_filesystem m hdf5_serial_hl hdf5_serial
    INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include /usr/include/hdf5/serial
    LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib /usr/lib/x86_64-linux-gnu /usr/lib/x86_64-linux-gnu/hdf5/serial

但是老版本的caffe真的是很争气,即使已经改掉了还是找不到,当时内心是奔溃的WTF

奔溃的我在github找到了这个,大神都在github把所有的包含hdf5.h头文件的文件都改了

https://github.com/BVLC/caffe/issues/2690

  1. diff --git a/Makefile.config.example b/Makefile.config.example
  2. index a873502..33441b3
  3. --- a/Makefile.config.example
  4. +++ b/Makefile.config.example
  5. @@ -, +, @@ PYTHON_LIB := /usr/lib
  6.  
  7. # Whatever else you find you need goes here.
  8. INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include
  9. -LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib
  10. +LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib /usr/lib/x86_64-linux-gnu/hdf5/serial
  11.  
  12. # If Homebrew is installed at a non standard location (for example your home directory) and you use it for general dependencies
  13. # INCLUDE_DIRS += $(shell brew --prefix)/include
  14. diff --git a/include/caffe/data_layers.hpp b/include/caffe/data_layers.hpp
  15. index 3958cb7..2ccbaec
  16. --- a/include/caffe/data_layers.hpp
  17. +++ b/include/caffe/data_layers.hpp
  18. @@ -, +, @@
  19. #include <vector>
  20.  
  21. #include "boost/scoped_ptr.hpp"
  22. -#include "hdf5.h"
  23. +#include "hdf5/serial/hdf5.h"
  24.  
  25. #include "caffe/blob.hpp"
  26. #include "caffe/common.hpp"
  27. diff --git a/include/caffe/util/io.hpp b/include/caffe/util/io.hpp
  28. index 3a62c3c..f4363f0
  29. --- a/include/caffe/util/io.hpp
  30. +++ b/include/caffe/util/io.hpp
  31. @@ -, +, @@
  32. #include <string>
  33.  
  34. #include "google/protobuf/message.h"
  35. -#include "hdf5.h"
  36. -#include "hdf5_hl.h"
  37. +#include "hdf5/serial/hdf5.h"
  38. +#include "hdf5/serial/hdf5_hl.h"
  39.  
  40. #include "caffe/blob.hpp"
  41. #include "caffe/common.hpp"
  42. diff --git a/src/caffe/layers/hdf5_data_layer.cpp b/src/caffe/layers/hdf5_data_layer.cpp
  43. index 8a782f7..42890be
  44. --- a/src/caffe/layers/hdf5_data_layer.cpp
  45. +++ b/src/caffe/layers/hdf5_data_layer.cpp
  46. @@ -, +, @@ TODO:
  47. #include <string>
  48. #include <vector>
  49.  
  50. -#include "hdf5.h"
  51. -#include "hdf5_hl.h"
  52. +#include "hdf5/serial/hdf5.h"
  53. +#include "hdf5/serial/hdf5_hl.h"
  54. #include "stdint.h"
  55.  
  56. #include "caffe/data_layers.hpp"
  57. diff --git a/src/caffe/layers/hdf5_data_layer.cu b/src/caffe/layers/hdf5_data_layer.cu
  58. index 5e3e4ce..23bc02a
  59. --- a/src/caffe/layers/hdf5_data_layer.cu
  60. +++ b/src/caffe/layers/hdf5_data_layer.cu
  61. @@ -, +, @@ TODO:
  62. #include <string>
  63. #include <vector>
  64.  
  65. -#include "hdf5.h"
  66. -#include "hdf5_hl.h"
  67. +#include "hdf5/serial/hdf5.h"
  68. +#include "hdf5/serial/hdf5_hl.h"
  69.  
  70. #include "caffe/data_layers.hpp"
  71. #include "caffe/layer.hpp"
  72. diff --git a/src/caffe/layers/hdf5_output_layer.cpp b/src/caffe/layers/hdf5_output_layer.cpp
  73. index f63375c..0b57eb9
  74. --- a/src/caffe/layers/hdf5_output_layer.cpp
  75. +++ b/src/caffe/layers/hdf5_output_layer.cpp
  76. @@ -, +, @@
  77. #include <vector>
  78.  
  79. -#include "hdf5.h"
  80. -#include "hdf5_hl.h"
  81. +#include "hdf5/serial/hdf5.h"
  82. +#include "hdf5/serial/hdf5_hl.h"
  83.  
  84. #include "caffe/blob.hpp"
  85. #include "caffe/common.hpp"
  86. diff --git a/src/caffe/layers/hdf5_output_layer.cu b/src/caffe/layers/hdf5_output_layer.cu
  87. index ae497c3..ada682f
  88. --- a/src/caffe/layers/hdf5_output_layer.cu
  89. +++ b/src/caffe/layers/hdf5_output_layer.cu
  90. @@ -, +, @@
  91. #include <vector>
  92.  
  93. -#include "hdf5.h"
  94. -#include "hdf5_hl.h"
  95. +#include "hdf5/serial/hdf5.h"
  96. +#include "hdf5/serial/hdf5_hl.h"
  97.  
  98. #include "caffe/blob.hpp"
  99. #include "caffe/common.hpp"

然后在使用的时候出现了can't find features

之前傻不拉几的pip isntall features结果并没有卵用,于是下载了

https://github.com/cvondrick/pyvision/blob/master/vision/features.pyx

发现出现一定问题:

  1. im=Image.fromarray(im)
  2. width, height = im.size

单独对它进行编译

  1. cython -a features.pyx
  2. gcc -shared -pthread -fPIC -fwrapv -O2 -Wall -fno-strict-aliasing \
  3. -I/usr/include/python2. -o features.so features.c

最后在需要的代码之前对features路径进行引用,比如我把features在vision文件中,在py文件开头加一句这个

  1. sys.path = ['/home/hu/pyvision/vision'] + sys.path

在调用程序的时候发现narray和image对象存在不兼容,所以我就写了一个PIL与array之间的转换程序

  1. def array2PIL(arr, size=[96,96]):
  2. mode = 'RGBA'
  3. arr = arr.reshape(arr.shape[0]*arr.shape[1], arr.shape[2])
  4. if len(arr[0]) == 3:
  5. arr = np.c_[arr, 255*np.ones((len(arr),1), np.uint8)]
  6. return Image.frombuffer(mode, size, arr.tostring(), 'raw', mode, 0, 1)

最终程序能够跑了,代码也看的差不多了。

幸运之神总是眷顾努力的人,加油

caffe ubuntu16安装报错和程序总结的更多相关文章

  1. 链接Caffe,程序报错应用程序无法正常启动(0xc000007b)

    目录 背景 Debug 解决办法 原因(猜想) 总结 重点是介绍了一种排查这个问题的方法. 背景 Windows 下, Caffe 单独编译成库并且安装在路径 Caffe_DIR, 动态链接库 Caf ...

  2. 记录laravelchina中的微信小程序教程的npm install安装报错

    npm安装报错时 npm ERR! code EIOnpm ERR! syscall symlinknpm ERR! path ../@babel/parser/bin/babel-parser.js ...

  3. 使用pip安装报错的处理方法

    在新的机子上使用pip安装程序一直报错: Retrying (Retry(total=4, connect=None, read=None, redirect=None)) after connect ...

  4. pydensecrf安装报错1、UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 29: invalid start byte2、 LINK : fatal error LNK1158: 无法运行“rc.exe” error: command 'D:\\software\\vs2015\\VC\\BIN

    pydensecrf安装报错 1.UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 29: invalid st ...

  5. 【Datastage】Datastage在win10上安装报错:This Application requires one of the following versions of the .NET Framework:v1.1.4322 Do you want to install this .NET Framework version now?

    Datastage在win10上安装报错如下: 这个错误的意思是:.netFramWork的版本不符合要求,于是,我在网上下载了一个版本一致的 下载地址为:http://pan.baidu.com/s ...

  6. linux 安装报错:pkg-config not found

    linux 安装报错:pkg-config not found 使用编译安装时,在执行./configure时报如下错误: ... ... checking for pkg-config... no ...

  7. MSSQL 2012安装报错之0x858C001B

    之前安装 Microsoft Sql Server 2012 R2 的时候总是报这样的错误: SQL Server Setup has encountered the following error: ...

  8. mydumper 安装报错处理

    mydumper 官网:https://launchpad.net/mydumper 下载之后,安装报错: [root@localhost local]# cd mydumper-0.6.2 [roo ...

  9. linux -小记(2)问题:yum 安装报错"Another app is currently holding the yum lock; waiting for it to exit... ...: yum Memory : 26 M RSS (868 MB VSZ) Started: Wed Oct 26 22:48:24 2016 - 0"

    yum 安装报错 "Another app is currently holding the yum lock; waiting for it to exit... The other ap ...

随机推荐

  1. Exception在方法继承中的限制

    问题: 父类或接口中定义了方法应该抛出的异常,那么当子类重写方法时应该怎样定义将要抛出的异常: 首先定义异常和父类: class Exception1 extends Exception {} cla ...

  2. session生命周期

    session生命周期 原文链接:http://blog.sina.com.cn/s/blog_72c8c1150100qpgl.html 文中黄色字体为我的标记修改或添加 Session保存在服务器 ...

  3. 【转】Gvim开发环境配置笔记--Windows篇

    配置文件(vimrc) set nocompatible set nu! set cursorline colorscheme murphy " vim 自身命令行模式智能补全 set wi ...

  4. LaTex 基础

    一.文档 \documentclass{article} %book, report, letter 二.宏包 \usepackage{amsmath} 三.正文 \begin{document} \ ...

  5. 【iCore3 双核心板_FPGA】例程十三:FSMC总线通信实验——复用地址模式

    实验指导书及代码包下载: http://pan.baidu.com/s/1nuYpI8x iCore3 购买链接: https://item.taobao.com/item.htm?id=524229 ...

  6. 本地化word复制来的网页中的图片

    复制一个网页到word文档中,图片会以链接到网页里图片,而不是本地化保存在文档里.为了让图片存在文档里,而不是每次链接到外部,可以这样做. 全选文档,菜单栏里的编辑,点击链接,断开所有链接. 然后再复 ...

  7. 使用NPOI将TABLE内容导出到EXCEL

    项目中需要将页面中的table内容导出到EXCEL,在用了几种方法后发现NPO是最快&最好的 需要应用 NPOI.dll 还有个Ionic.Zip.dll不知道有用没,没去研究,两个DLL都放 ...

  8. XE系列资源文件的奇怪问题

    这是一个关于资源文件的故事.......-_- 今天写一个功能测试Demo, 为了省事直接在工程文件里Resources And Images里添加了几个图片, 类型都是默认的RCDATA 然后直接就 ...

  9. svn的差异查看器和合并工具换成BCompare.exe

    svn的差异查看器和合并工具换成BCompare.exe

  10. 用Unity开发HTC VIVE——手柄控制篇

    写这篇文章的原因主要是因为现在虚拟现实非常的火爆但目前主流的虚拟现实设备(HTC VIVE)的教程却少的可怜,这个我深有体会.所以,我想将我平时开发中遇到的问题以及解决方法记录下来,分享给大家,若其中 ...