caffe编译错误记录
1. caffe.pb.h丢失问题
错误代码如图:
zhuoshi@zhuoshi-SYS-7048GR-TR:~/ZSZT/Geoffrey/caffe/caffe-master$ make all –j8
PROTOC src/caffe/proto/caffe.proto
CXX .build_release/src/caffe/proto/caffe.pb.cc
CXX src/caffe/layer.cpp
In file included from ./include/caffe/common.hpp:19:0,
from ./include/caffe/blob.hpp:8,
from ./include/caffe/layer.hpp:8,
from src/caffe/layer.cpp:1:
./include/caffe/util/device_alternate.hpp:34:23: fatal error: cublas_v2.h: No such file or directory
compilation terminated.
Makefile:591: recipe for target '.build_release/src/caffe/layer.o' failed
make: *** [.build_release/src/caffe/layer.o] Error 1
解决方法
解决办法参考这个博客:http://blog.csdn.net/xmzwlw/article/details/48270225, 用protoc从caffe/src/caffe/proto/caffe.proto生成caffe.pb.h和caffe.pb.cc.
但是有个问题需要注意,此处不能使用'~', 而要使用完整路径
2. 未定义的引用, undefined reference to 'cblas_scopy'
参考这篇博客,https://blog.csdn.net/sdlypyzq/article/details/85237512, 的确是搞笑, 我也在open后面多了个空格,去掉就可以了.
3. Protobuf 错误
报错内容: PROTOC (python) src/caffe/proto/caffe.proto python/caffe/_caffe.cpp:1:52: fa
原因: caffe自带的requirement.txt内容如下, 只规定protobuf>=2.5.0
, 并没有规定上限,所以我直接conda install protobuf
导致版本过高
解决方法:
conda install protobuf=3.2
更新时间: 2019/06/10
4. libcblas.a错误
在cmake后, 修改build文件夹下的CMakeCache.txt
5. 为定义的引用libopencv_highgui.so.2.4.9
解决办法:用sudo su
, 参考自链接
6. FlagRegisterer问题
解决办法:重新安装 GLog & GFlags 的安装
1)安装 GFlags
git clone https://github.com/gflags/gflags.git
cd gflags
mkdir build && cd build
cmake .. -DGFLAGS_NAMESPACE=google -DCMAKE_CXX_FLAGS=-fPIC ..
make -j4
sudo make install
2)安装 GLog:
git clone https://github.com/google/glog
cd glog
./autogen.sh
./configure CPPFLAGS="-I/usr/local/include -fPIC" LDFLAGS="-L/usr/local/lib"
make -j8
sudo make install
7. pycaffe找不到Python.h文件
添加环境变量即可
export CPLUS_INCLUDE_PATH="/opt/anaconda/envs/caffe_27/include/python2.7:$CPLUS_INCLUDE_PATH"
8. gflags命名空间问题
/home/geoffrey/caffe/include/caffe/common.hpp(31): error: "gflags" has already been declared in the current scope
,
可以修改这个地方, 进行注释:
// #ifndef GFLAGS_GFLAGS_H_
namespace gflags = google;
// #endif // GFLAGS_GFLAGS_H_
具体参考: stackoverflow
9. __builtin_is_constant_evaluated未定义
报错内容:/usr/include/c++/9.1.0/bits/stl_function.h(437): error: identifier "__builtin_is_constant_evaluated" is undefined
更新时间:2019.07.17
原因, gcc版本太高,我的是系统滚动更新的gcc9.1版本, 换成gcc6好了.
对于cmake指定gcc和g++版本方法:
SET(CMAKE_C_COMPILER /usr/bin/gcc-6)
SET(CMAKE_CXX_COMPILER /usr/bin/g++-6)
10. error: token ""CUDACC_VER is no longer supported
解决办法, https://github.com/BVLC/caffe/issues/5994, upgrade boost from 1.62 to 1.65,
conda install boost=1.65
conda install boost-cpp=1.65
11. /usr/include/c++/9.2.0/bits/stl_function.h(437): 未定义"__builtin_is_constant_evaluated"
更新时间: 2019/11/07
原因: gcc版本太高,如图,cuda只支持8以下版本:
解决办法:
指定一个低版本gcc,g++: