码迷,mamicode.com
首页 > 系统相关 > 详细

caffe ubuntu16安装报错和程序总结

时间:2016-12-10 11:18:03      阅读:406      评论:0      收藏:0      [点我收藏+]

标签:错误   scope   路径   经典的   转换   lag   b/s   老版本   buffer   

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

couldnt find hdf5.h

 

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

--- INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include
+++ INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include /usr/include/hdf5/serial/

--- LIBRARIES += glog gflags protobuf boost_system boost_filesystem m hdf5_hl hdf5
+++ LIBRARIES += glog gflags protobuf boost_system boost_filesystem m hdf5_serial_hl hdf5_serial

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

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

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

diff --git a/Makefile.config.example b/Makefile.config.example
index a873502..33441b3 100644
--- a/Makefile.config.example
+++ b/Makefile.config.example
@@ -70,7 +70,7 @@ PYTHON_LIB := /usr/lib

 # Whatever else you find you need goes here.
 INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include
-LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib
+LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib /usr/lib/x86_64-linux-gnu/hdf5/serial

 # If Homebrew is installed at a non standard location (for example your home directory) and you use it for general dependencies
 # INCLUDE_DIRS += $(shell brew --prefix)/include
diff --git a/include/caffe/data_layers.hpp b/include/caffe/data_layers.hpp
index 3958cb7..2ccbaec 100644
--- a/include/caffe/data_layers.hpp
+++ b/include/caffe/data_layers.hpp
@@ -6,7 +6,7 @@
 #include <vector>

 #include "boost/scoped_ptr.hpp"
-#include "hdf5.h"
+#include "hdf5/serial/hdf5.h"

 #include "caffe/blob.hpp"
 #include "caffe/common.hpp"
diff --git a/include/caffe/util/io.hpp b/include/caffe/util/io.hpp
index 3a62c3c..f4363f0 100644
--- a/include/caffe/util/io.hpp
+++ b/include/caffe/util/io.hpp
@@ -5,8 +5,8 @@
 #include <string>

 #include "google/protobuf/message.h"
-#include "hdf5.h"
-#include "hdf5_hl.h"
+#include "hdf5/serial/hdf5.h"
+#include "hdf5/serial/hdf5_hl.h"

 #include "caffe/blob.hpp"
 #include "caffe/common.hpp"
diff --git a/src/caffe/layers/hdf5_data_layer.cpp b/src/caffe/layers/hdf5_data_layer.cpp
index 8a782f7..42890be 100644
--- a/src/caffe/layers/hdf5_data_layer.cpp
+++ b/src/caffe/layers/hdf5_data_layer.cpp
@@ -10,8 +10,8 @@ TODO:
 #include <string>
 #include <vector>

-#include "hdf5.h"
-#include "hdf5_hl.h"
+#include "hdf5/serial/hdf5.h"
+#include "hdf5/serial/hdf5_hl.h"
 #include "stdint.h"

 #include "caffe/data_layers.hpp"
diff --git a/src/caffe/layers/hdf5_data_layer.cu b/src/caffe/layers/hdf5_data_layer.cu
index 5e3e4ce..23bc02a 100644
--- a/src/caffe/layers/hdf5_data_layer.cu
+++ b/src/caffe/layers/hdf5_data_layer.cu
@@ -7,8 +7,8 @@ TODO:
 #include <string>
 #include <vector>

-#include "hdf5.h"
-#include "hdf5_hl.h"
+#include "hdf5/serial/hdf5.h"
+#include "hdf5/serial/hdf5_hl.h"

 #include "caffe/data_layers.hpp"
 #include "caffe/layer.hpp"
diff --git a/src/caffe/layers/hdf5_output_layer.cpp b/src/caffe/layers/hdf5_output_layer.cpp
index f63375c..0b57eb9 100644
--- a/src/caffe/layers/hdf5_output_layer.cpp
+++ b/src/caffe/layers/hdf5_output_layer.cpp
@@ -1,7 +1,7 @@
 #include <vector>

-#include "hdf5.h"
-#include "hdf5_hl.h"
+#include "hdf5/serial/hdf5.h"
+#include "hdf5/serial/hdf5_hl.h"

 #include "caffe/blob.hpp"
 #include "caffe/common.hpp"
diff --git a/src/caffe/layers/hdf5_output_layer.cu b/src/caffe/layers/hdf5_output_layer.cu
index ae497c3..ada682f 100644
--- a/src/caffe/layers/hdf5_output_layer.cu
+++ b/src/caffe/layers/hdf5_output_layer.cu
@@ -1,7 +1,7 @@
 #include <vector>

-#include "hdf5.h"
-#include "hdf5_hl.h"
+#include "hdf5/serial/hdf5.h"
+#include "hdf5/serial/hdf5_hl.h"

 #include "caffe/blob.hpp"
 #include "caffe/common.hpp"

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

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

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

单独对它进行编译

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

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

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

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

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

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

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

 

caffe ubuntu16安装报错和程序总结

标签:错误   scope   路径   经典的   转换   lag   b/s   老版本   buffer   

原文地址:http://www.cnblogs.com/kangronghu/p/6155101.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!