最近又重新捡起来Caffe编译了一下,鉴于以后估计就要和它打交道了,还是记录下遇到过的问题。
拿到一个Caffe,依赖项什么的就不说了,网上教程很多,结合官网就能下好。
然后,caffe文件夹下
cp Makefile.config.example Makefile.config
复制出来,根据需求修改.config里的以下几条:
# cuDNN acceleration switch (uncomment to build with cuDNN).
# USE_CUDNN := 1
# CPU-only switch (uncomment to build without GPU support).
# CPU_ONLY := 1
# Uncomment to support layers written in Python (will link against Python libs)
WITH_PYTHON_LAYER := 1
然后
make all -j
make test -j
make runtest -j
如果都没报错就成功了。
可能遇到:
1.hdf5找不到
解决方法:Makefile中181行附近
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
2.OpenCV找不到
解决方法:上面的LIBRARIES添加四项OpenCV关键项。
LIBRARIES += glog gflags protobuf boost_system boost_filesystem m hdf5_serial_hl hdf5_serial opencv_core opencv_highgui opencv_imgproc opencv_imgcodecs
3.Boost报错
解决方法:Makefile中265行附近
LIBRARIES += boost_thread stdc++
后面,添加报错的项。例如如果发现报错
boost::program_options::xxxx undefined 或者boost::boost_regex::xxxx undefined
就在后面相应的添加缺失的项,例如
265 LIBRARIES += boost_thread stdc++ boost_program_options boost_regex
如果还解决不了问题,网上说可能是boost版本太低。我的是1.58。
4.其它问题
目前遇到的很多问题都是和显卡有关的,比如
Check failed: error == cudaSuccess (30 vs. 0) unknown error
Check failed: error == cudaSuccess (8 vs. 0) invalid device function
这里有一个对上面问题的解决方法,但是对我的不奏效。
还有一个2vs.0的问题,是显卡容量不足,需要对网络设置进行修改。