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++:



免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM