caffe cuda8.0 GTX1070安装问题总结

本文总结了在配备GTX1070显卡和CUDA8.0环境下,安装Caffe过程中遇到的挑战及解决方案,包括protobuf、glog、gflags、lmdb和leveldb的重新编译与安装步骤,以及一些未解决的编译错误。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

最近终于有了1070的显卡,可以尝试使用GPU进行训练,这里把安装caffe遇到的一些大坑以及解决方法进行一下汇总。
PS:安装时部分参考

http://www.fx114.net/qa-94-147874.aspx
http://blog.youkuaiyun.com/u010673367/article/details/52832008
http://www.linuxdiyf.com/linux/24659.html

1.

.build_release/lib/libcaffe.so: undefined reference to google ::protobuf...  

重新安装编译protobuf
参考:http://blog.youkuaiyun.com/fansetcool/article/details/51569374

在安装之前需要先把工具automake给装了:

sudo apt-get install autoconf automake libtool

那接下来就下载protobuf吧,在github下载,解压https://github.com/google/protobuf
解压后,进入目录protobuf-master, 运行:

./autogen.sh

这时会提醒你的curl没有安装的错误。所以安装curl,再从https://googlemock.googlecode.com/files/gmock-1.7.0.zip直接下载(翻墙下载)。下完后不用解压,直接把gtest-1.7.0.zip放到protobuf-master的目录下就ok了。vim打开autogen.sh 把有用到curl的地方注释掉就ok了。然后再次运行./autogen.sh。
运行成功后,依次输入命令(还是在protobuf-master的目录下):

 ./configure
make
make check

make跟make check都会费一点时间(如果你遇到很多次坑,每次都想重新编译protobuf的话记得make之前要make clean一下)。
最后

sudo make install

2.

CXX/LD -o .build_debug/tools/device_query.bin
CXX/LD -o .build_debug/tools/upgrade_net_proto_binary.bin
.build_debug/lib/libcaffe.so: undefined reference to `google::base::CheckOpMessageBuilder::NewString()'
collect2: error: ld returned 1 exit status
Makefile:616: recipe for target '.build_debug/tools/upgrade_net_proto_binary.bin' failed
make: *** [.build_debug/tools/upgrade_net_proto_binary.bin] Error 1
make: *** Waiting for unfinished jobs....
.build_debug/tools/compute_image_mean.o: In function `std::string* google::MakeCheckOpString<int, int>(int const&, int const&, char const*)':
/usr/include/glog/logging.h:672: undefined reference to `google::base::CheckOpMessageBuilder::NewString()'

重新安装手动编译glog,gflags,lmdb等
1)卸载

sudo apt-get remove libgoogle-glog-dev libgoogle-glog0v5
sudo apt-get remove libgflags-dev liblmdb-dev

2)安装glog

wget https://github.com/google/glog/archive/v0.3.4.tar.gz
tar zxvf v0.3.4.tar.gz
cd glog-0.3.4
./configure

进入glog-0.3.4,编辑makefile。

change line 613 to ACLOCAL=aclocal-1.15
change line 619 to AUTOMAKE=automake-1.15

保存退出

make 
automake --add-missing
make -j 8
sudo make install

其中make这一步遇到error没关系。
3)安装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
sudo make install

4)安装lmdb

git clone https://github.com/LMDB/lmdb
cd lmdb/libraries/liblmdb
make
sudo make install

3.

.build_release/lib/libcaffe.so:对‘leveldb::DB::Open(leveldb::Options const&, std::string const&, leveldb::DB**)’未定义的引用
.build_release/lib/libcaffe.so:对‘leveldb::Status::ToString() const’未定义的引用

重装leveldb

1)卸载

sudo apt-get remove libleveldb-dev

2)下载leveldb

wget https://github.com/google/leveldb/archive/v1.19.zip
unzip v1.19.zip && cd leveldb-1.19/
make
cd out-shared/ 
sudo mv libleveldb.* /usr/local/lib
cd
cd leveldb-1.19/include/
sudo cp -R leveldb /usr/local/include
sudo ldconfig

4.

...
[ RUN      ] FilterLayerTest/3.TestForward
[       OK ] FilterLayerTest/3.TestForward (4 ms)
[----------] 3 tests from FilterLayerTest/3 (4119 ms total)

[----------] 1 test from HDF5OutputLayerTest/3, where TypeParam = caffe::GPUDevice<double>
[ RUN      ] HDF5OutputLayerTest/3.TestForward
*** Aborted at 1495022541 (unix time) try "date -d @1495022541" if you are using GNU date ***
PC: @     0x7f799dd0a143 boost::filesystem::path::operator/=()
*** SIGSEGV (@0x706d742f) received by PID 26194 (TID 0x7f79a2b78740) from PID 1886221359; stack trace: ***
    @     0x7f7998eb7390 (unknown)
    @     0x7f799dd0a143 boost::filesystem::path::operator/=()
    @           0x4917c4 caffe::MakeTempDir()
    @           0x4c97f0 caffe::MakeTempFilename()
    @           0x56fdcb testing::internal::TestFactoryImpl<>::CreateTest()
    @           0x942bc3 testing::internal::HandleExceptionsInMethodIfSupported<>()
    @           0x93aca3 testing::TestInfo::Run()
    @           0x93ae05 testing::TestCase::Run()
    @           0x93b798 testing::internal::UnitTestImpl::RunAllTests()
    @           0x93ba63 testing::UnitTest::Run()
    @           0x46eb6f main
    @     0x7f7998afd830 __libc_start_main
    @           0x476759 _start
Makefile:532: recipe for target 'runtest' failed
make: *** [runtest] 段错误 (core dumped)

这个是make runtest时出现的,之前的make all 以及make test都成功了,查了好多资料都没解决,不过貌似影响不大,我忽略了这个错误,后面caffe好像也能正常运行。。。以后找到解决方法时再补。。。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值