安装过程的主要问题是依赖的各种库版本兼容问题,有时即使编译成功了,运行时也会报错。
目前使用 protobuf 3.6,opencv3.4.5, glog-0.3.3 gflags-2.0, 顺利解决问题。
安装主要参考文章 https://blog.csdn.net/yhaolpz/article/details/71375762
- 首先参考文章, 通过apt-get安装好依赖库。
sudo apt-get install libprotobuf-dev libleveldb-dev libsnappy-dev libopencv-dev libhdf5-serial-dev protobuf-compiler
sudo apt-get install --no-install-recommends libboost-all-dev
sudo apt-get install libopenblas-dev liblapack-dev libatlas-base-dev
sudo apt-get install libgflags-dev libgoogle-glog-dev liblmdb-dev
sudo apt-get install git cmake build-essential
-
编译安装opencv3.4.5 , 3.4的版本应该都可以
-
依次安装 glog gflags, leveldb
glog
wget https://github.com/google/glog/archive/v0.3.3.tar.gz
tar zxvf v0.3.3.tar.gz
cd glog-0.3.3
./configure
make && make install
gflags
wget https://github.com/schuhschuh/gflags/archive/master.zip
unzip master.zip
cd gflags-master
mkdir build && cd build
export CXXFLAGS="-fPIC" && cmake … && make VERBOSE=1
make && make install
lmdb
git clone https://github.com/LMDB/lmdb
cd lmdb/libraries/liblmdb
make && make install
-
安装CUDA和CUDNN,机器以前已经安装好了
-
按照参考文章,修改Makefile.config, 并进行编译caffe
make all -j8
编译后运行build/tools/caffe , 如果出现错误: caffe: symbol lookup error: caffe: undefined symbol: _ZN6google16SetVersionStringERKSs
运行 export LD_LIBRARY_PATH=/usr/local/lib, 然后应该可以解决
- 安装 pycaffe 接口环境
参考 https://github.com/BVLC/caffe/issues/3220
修改_caffe.cpp ,解决运行时遇到的错误 Error in python interface. " Net.init(Net, str, str, int) did not match C++ signature
diff --git a/python/caffe/_caffe.cpp b/python/caffe/_caffe.cpp
index 4ea2ec6…4c558cb 100644
— a/python/caffe/_caffe.cpp
+++ b/python/caffe/_caffe.cpp
@@ -75,7 +75,7 @@ void CheckContiguousArray(PyArrayObject* arr, string name,
// Net constructor for passing phase as int
shared_ptr<Net > Net_Init(
- string param_file, int phase) {
- char* param_file, int phase) {
CheckFile(param_file);
shared_ptr<Net > net(new Net(param_file,
@@ -85,7 +85,7 @@ shared_ptr<Net > Net_Init(
// Net construct-and-load convenience constructor
shared_ptr<Net > Net_Init_Load(
- string param_file, string pretrained_param_file, int phase) {
- char* param_file, char* pretrained_param_file, int phase) {
CheckFile(param_file);
CheckFile(pretrained_param_file);
修改后编译 make pycaffe
然后就可以在在python中使用caffe了
本文详细记录了Caffe深度学习框架在Ubuntu环境下从依赖库安装到PyCaffe接口配置的全过程,包括解决常见编译及运行时错误的方法。
867

被折叠的 条评论
为什么被折叠?



