配置说明
使用nvidia/cuda:8.0-devel-ubuntu16.04
镜像
使用源码 编译安装caffe
使用源码 编译安装protobuf-3.5.1
基础环境准备 1 2 3 4 5 6 apt update apt install libgflags-dev libgoogle-glog-dev libatlas-base-dev libhdf5-* libgflags-dev libgoogle-glog-dev liblmdb-dev libleveldb-dev libsnappy-dev libopencv-dev libhdf5-serial-dev -y apt install git vim python-pip autoconf unzip -y apt install --no-install-recommends libboost-all-dev python-numpy -y easy_install pip==20.3.4 pip install opencv-python==4.2.0.32 scikit-image
编译protobuf-3.5.1 参考链接
1 2 3 4 5 6 7 8 9 10 11 12 13 14 cd /workspcae/ wget https://github.com/protocolbuffers/protobuf/archive/refs/tags/v3.5.1.tar.gz tar zxvf v3.5.1.tar.gz cd protobuf-3.5.1/ ./autogen.sh # 运行此脚本需要访问一些404网站,因此需要具备访问外网的网络环境 ./configure make -j1 # 后面的1可以根据实际电脑cpu核心数量修改 make check -j1 make install ldconfig protoc --version # 查看版本信息 cd python/ python setup.py install
编译caffe 参考链接
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 cd /workspace/ git clone https://github.com/BVLC/caffe cd caffe/ cp Makefile.config.example Makefile.config # 修改Makefile.config中的配置 # 将`/usr/include/hdf5/serial/`和`/usr/local /lib/python2.7/dist-packages/numpy/core/include/` 添加到`INCLUDE_DIRS`中 # 将`/usr/lib/x86_64-linux-gnu/hdf5/serial`添加到`LIBRARY_DIRS`中 make all -j1 # 后面的1可以根据实际电脑cpu核心数量修改 # 此处是编译并运行测试,可以根据实际情况省略 make test -j1 make runtest make pycaffe make distribute
若执行python时无法import caffe,运行命令export PYTHONPATH=/workspace/caffe/python:$PYTHONPATH
临时修改PYTHONPATH