Ubuntu18.04在docker内安装caffe

1. 下载caffe:(不用命令安装cuda--caffe,因为会导致docker内nvidia-smi无反应)

git clone https://github.com/Qengineering/caffe.git

2. 安装依赖项

sudo apt-get install libprotobuf-dev libleveldb-dev libsnappy-dev libopencv-dev
sudo apt-get install 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

3.修改Makefile 和Makefile.config.如果不是从官网下的caffe就不用改了,这步跳过

4.Caffe源码中安装Python的必要项

cd /root/caffe/python 
pip3 install --upgrade python-dateutil
for req in $(cat requirements.txt); do pip3 install $req; done

5. 编译

cd /home/li.guangyao/Programming/caffe
sudo make clean
sudo make all -j16 		//-j16表示使用16核处理器执行当前指令
sudo make test -j16       //最好加上sudo防止有些文件的访问权限不够
sudo make runtest -j16         //最好加上sudo防止有些文件的访问权限不够
sudo make pycaffe -j16 		//配置pycaffe

环境变量

在bashrc里加入

export PYTHONPATH=/root/caffe/python:$PYTHONPATH
source ~/.bashrc

6.在终端里输入以下命令,如果没有报错则成功。

>>python3
>>import caffe

7. 如果有问题

pip3 install scikit-image #安装ski-image
sudo pip3 install --upgrade protobuf  #安装protobuf

上一篇:人工智能的开创性人物


下一篇:darknet yolov3 yolov4转caffe 教程