安装caffe出错

安装依赖

依赖包:

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

在安装caffe前,需要安装许多的依赖包,但是经常遇到就是依赖包安装不了,例如:在进行安装时发现有些包:

yanghe@ubuntu:~/Desktop/Yanghe$ sudo apt-get install libprotobuf-dev libleveldb-dev libsnappy-dev libopencv-dev libhdf5-serial-dev protobuf-compiler

出错:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 libhdf5-serial-dev : Depends: libhdf5-dev but it is not going to be installed
 libopencv-dev : Depends: libopencv-calib3d-dev (= 3.2.0+dfsg-4build2) but it is not going to be installed
                 Depends: libopencv-contrib-dev (= 3.2.0+dfsg-4build2) but it is not going to be installed
                 Depends: libopencv-features2d-dev (= 3.2.0+dfsg-4build2) but it is not going to be installed
                 Depends: libopencv-highgui-dev (= 3.2.0+dfsg-4build2) but it is not going to be installed
                 Depends: libopencv-objdetect-dev (= 3.2.0+dfsg-4build2) but it is not going to be installed
                 Depends: libopencv-stitching-dev (= 3.2.0+dfsg-4build2) but it is not going to be installed
                 Depends: libopencv-videostab-dev (= 3.2.0+dfsg-4build2) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

  • 解决方案:
  1. 通过安装
sudo apt-get install aptitude
  1. 使用 aptitude
sudo aptitude install  libprotobuf-dev libleveldb-dev libsnappy-dev libopencv-dev libhdf5-serial-dev protobuf-compiler

编译caffe

make clean
cd caffe
sudo cmake ./
sudo make all -j4
sudo make install 

安装pycaffe

cd caffe

sudo make pycaffe -j8

安装参考
安装参考

或许

yanghe@ubuntu:~/Desktop/Yanghe/caffe$ sudo make all -j4 
PROTOC src/caffe/proto/caffe.proto
NVCC src/caffe/solvers/nesterov_solver.cu
NVCC src/caffe/solvers/rmsprop_solver.cu
NVCC src/caffe/solvers/adadelta_solver.cu
NVCC src/caffe/solvers/adagrad_solver.cu
In file included from ./include/caffe/util/math_functions.hpp:9:0,
                 from src/caffe/solvers/rmsprop_solver.cu:1:
./include/caffe/common.hpp:4:32: fatal error: boost/shared_ptr.hpp: No such file or directory
In file included from ./include/caffe/util/math_functions.hpp:9:0,
                 from src/caffe/solvers/adadelta_solver.cu:1:
./include/caffe/common.hpp:4:32: fatal error: boost/shared_ptr.hpp: No such file or directory
compilation terminated.
compilation terminated.
Makefile:605: recipe for target '.build_release/cuda/src/caffe/solvers/rmsprop_solver.o' failed
make: *** [.build_release/cuda/src/caffe/solvers/rmsprop_solver.o] Error 1
make: *** Waiting for unfinished jobs....
Makefile:605: recipe for target '.build_release/cuda/src/caffe/solvers/adadelta_solver.o' failed
make: *** [.build_release/cuda/src/caffe/solvers/adadelta_solver.o] Error 1
In file included from ./include/caffe/util/math_functions.hpp:9:0,
                 from src/caffe/solvers/nesterov_solver.cu:1:
./include/caffe/common.hpp:4:32: fatal error: boost/shared_ptr.hpp: No such file or directory
compilation terminated.
Makefile:605: recipe for target '.build_release/cuda/src/caffe/solvers/nesterov_solver.o' failed
make: *** [.build_release/cuda/src/caffe/solvers/nesterov_solver.o] Error 1
In file included from ./include/caffe/util/math_functions.hpp:9:0,
                 from src/caffe/solvers/adagrad_solver.cu:1:
./include/caffe/common.hpp:4:32: fatal error: boost/shared_ptr.hpp: No such file or directory
compilation terminated.
Makefile:605: recipe for target '.build_release/cuda/src/caffe/solvers/adagrad_solver.o' failed
make: *** [.build_release/cuda/src/caffe/solvers/adagrad_solver.o] Error 1

  1. 遇到:
In file included from ./include/caffe/util/math_functions.hpp:9:0,
                 from src/caffe/solvers/rmsprop_solver.cu:1:
./include/caffe/common.hpp:4:32: fatal error: boost/shared_ptr.hpp: No such file or directory

安装caffe出错_第1张图片
image.png

这是没装libboost

sudo aptitude install  libboost-all-dev
  1. 遇到
src/caffe/layers/hdf5_data_layer.cu:10:18: fatal error: hdf5.h: No such file or directory
compilation terminated.

安装caffe出错_第2张图片
image.png

这是没装好libhdf5-serial-dev

sudo aptitude install   libhdf5-serial-dev

遇到caffe 无法找到cuda

sudo ldconfig /usr/local/cuda/lib64

cankao:
ubuntu18.04安装配置opencv3.3.0(完全安装)
ubuntu18.04环境下编译安装opencv3.4
Ubuntu16.04编译OpenCV3.4
opencv recipe for target 'all' failed解决
在Windows下编译扩展OpenCV 3.1.0 + opencv_contrib
Ubuntu16.04安装配置Caffe教程(GPU版)
Ubuntu18.04LTS下基于 Anaconda3 安装 Caffe-GPU及 Python3.6 + Pycharm + Mnist例子教程(超详细)
Caffe安装(Ubuntu16.04 GPU版本)以及入门

你可能感兴趣的:(安装caffe出错)