0%

Docker安装Caffe

先安装以下软件:cuda, cudnn, openblas, protobuf, glog, gflags, hdf5, snappy, leveldb, boost(+python), opencv(+python)doxygenlmdb

由于华为云提供包含cudacudnndocker镜像,所以不用安装这两个。同时由于不能改变镜像中的/usr文件夹,所以最好不要通过apt安装以上依赖库。(华为云提供docker时的要求,否则用apt安装是最方便、最好的!!!)

启动docker镜像

下载华为云docker镜像压缩包(custom-gpu-cuda9-cudnn7-inner-moxing-cp36.tar)后:

1
2
3
4
5
6
7
# 加载镜像并重命名
docker load -i 镜像压缩包文件名称
docker images|grep dls
docker tag #image-id basic-caffe:1.0.0
docker images|grep dls
docker rmi dls.io/eiwizard/custom-gpu-cuda9-inner-moxing-cp36:1.1
docker images|grep basic-caffe

建立文件夹software,用以放置安装包:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# 运行镜像,退出不关
docker run --name test-basic-caffe -it #image-id bash
# root@b0a4a7125b7f:/#
# 其中 b0a4a7125b7f 为 container-id
# 镜像里包含了cuda, cudnn, python3.6
nvcc --version
find / -name *cudnn*
python --version
Ctrl+P+Q
# 查看运行容器,重新进入容器
docker ps -a|grep test-basic-caffe
docker attach #container-id
cd /home
mkdir software
cd software
Ctrl+P+Q

docker退出及重新启动进入:

1
2
docker里#exit
docker外#docker start -ia #container-id

安装caffe依赖库

1.下载并拷贝各个压缩包:

1
2
3
4
5
docker cp boost_1_68_0.tar.gz b0a4a7125b7f:/home/software
...

docker attach #docker-id
ls /home/software

2.安装各个依赖库:

安装zlib, libpng, jpegsrc.v9c

1
2
3
4
5
6
7
8
9
10
11
12
13
14
# zlib
cd /home/software/zlib-1.2.11
./configure --prefix=/home/software/zlib-1.2.11-install
make -j && make install
# libpng
export LDFLAGS="-L/home/software/zlib-1.2.11-install/lib"
export CPPFLAGS="-I/home/software/zlib-1.2.11-install/include"
cd /home/software/libpng-1.6.37
./configure --prefix=/home/software/libpng-1.6.37-install
make -j && make install
# jpeg-9c
cd /home/software/jpeg-9c
./configure --prefix=/home/software/jpeg-9c-install
make -j && make install

安装cmake

1
2
3
cd /home/software/cmake-3.15.0-rc3
./configure --system-curl --prefix=/home/software/cmake-3.15.0-rc3-install -- -DCMAKE_USE_OPENSSL=ON -DZLIB_LIBRARY=/home/software/zlib-1.2.11-install/lib/libz.so -DZLIB_INCLUDE_DIR=/home/software/zlib-1.2.11-install/include
make -j && make install

/root下的vi .bashrc中添加:

1
2
export PATH=/home/software/cmake-3.15.0-rc3-install/bin:$PATH
export LD_LIBRARY_PATH=/home/software/cmake-3.15.0-rc3-install/lib:$LD_LIBRARY_PATH

然后执行source .bashrc && cmake

安装openblas

1
2
3
4
5
cd /home/software/OpenBLAS-0.3.6
make CC=gcc FC=gfortran
make PREFIX=/home/software/OpenBLAS-0.3.6-install install
cd /home/software/OpenBLAS-0.3.6-install/lib
ls

安装protobuf

1
2
3
4
5
6
7
cd /home/software/protobuf-2.6.1
./configure --prefix=/home/software/protobuf-2.6.1-install
make check
make -j
make install
cd /home/software/protobuf-2.6.1-install/bin
./protoc --version

安装snappy

1
2
3
4
cd /home/software/snappy-1.1.7
mkdir build
cd build && cmake -DCMAKE_INSTALL_PREFIX=/home/software/snappy-1.1.7-install ..
make -j && make install

安装leveldb

1
2
3
4
cd /home/software/leveldb-1.22
mkdir -p build && cd build
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/home/software/leveldb-1.22-install -DBUILD_SHARED_LIBS=ON ..
make -j && make install

安装glog

需要先安装libtool

1
2
3
cd /home/software/libtool-2.4.6
./configure --prefix=/home/software/libtool-2.4.6-install
make -j && make install

/root下的vi .bashrc中添加:

1
2
3
4
export CMAKE_PATH=/home/software/cmake-3.15.0-rc3-install
export LIBTOOL_PATH=/home/software/libtool-2.4.6-install
export PATH=$LIBTOOL_PATH/bin:$CMAKE_PATH/bin:$PATH
export LD_LIBRARY_PATH=$LIBTOOL_PATH/lib:$CMAKE_PATH/lib:$LD_LIBRARY_PATH

然后执行source .bashrc && cmake以及cp /home/software/libtool-2.4.6-install/share/aclocal/* /usr/share/aclocal/(原因就是aclocallibtool没有安装在一个相同目录下面,而aclocal是去默认安装目录 /usr/share/aclocal 下面搜索所有的.m4文件找所定义的宏,所以自定义安装后要copy到一起)。

1
2
3
cd /home/software/glog-0.4.0
aclocal -I m4
./autogen.sh && ./configure --prefix=/home/software/glog-0.4.0-install && make -j && make install

安装gflags

1
2
3
4
5
6
cd /home/software/gflags-2.2.0
mkdir build
cd build/
cmake -DCMAKE_INSTALL_PREFIX=/home/software/gflags-2.2.0-install -DBUILD_SHARED_LIBS=ON ..
make -j
make install

安装hdf5

1
2
3
4
5
(源码包下载太慢了)
cd /home/software/hdf5-1.8.18
./configure --prefix=/home/software/hdf5-1.8.18-install && make -j && make install
或者
conda install -c anaconda hdf5==1.8.18

安装boost(+python)

1
2
cd /home/software/boost_1_68_0
vi tools/build/src/tools/python.jam

修改其中547行:

1
includes ?= $(prefix)/include/python$(version) ; -> includes ?= $(prefix)/include/python$(version)m ;

然后指定python3路径及版本,安装boost

1
2
3
./bootstrap.sh --with-python=/root/miniconda3/bin/python --with-python-version=3.6 --with-python-root=/root/miniconda3 --prefix=/home/software/boost_1_68_0-install
./b2 install -a --with=all
./b2 --with-python --buildid=3

建立软连接:

1
ln -s /home/software/boost_1_68_0-install/lib/libboost_python36.so.1.68.0 /home/software/boost_1_68_0-install/lib/libboost_python3.so

安装lmdb

1
2
3
4
5
6
7
8
cd /home/software/lmdb-LMDB_0.9.23/libraries/liblmdb
make -j
mkdir -p /home/software/lmdb-LMDB_0.9.23-install/include
mkdir -p /home/software/lmdb-LMDB_0.9.23-install/lib
mkdir -p /home/software/lmdb-LMDB_0.9.23-install/bin
for f in mdb_stat mdb_copy mdb_dump mdb_load; do cp $f /home/software/lmdb-LMDB_0.9.23-install/bin; done
for f in liblmdb.a liblmdb.so; do cp $f /home/software/lmdb-LMDB_0.9.23-install/lib; done
for f in lmdb.h; do cp $f /home/software/lmdb-LMDB_0.9.23-install/include; done

安装doxygen

1
2
3
4
cd /home/software/doxygen-Release_1_8_15
mkdir build && cd build
cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/home/software/doxygen-Release_1_8_15-install ..
make -j && make install

安装opencv(+contribu+python)

由于opencv安装依赖protobuf,所以要找对应opencv安装版本的protobuf版本(我是opencv-3.4.4,对应protobuf-3.5.1),所以先conda安装(会升级Python版本):

1
conda install -c conda-forge protobuf==3.5.1

需要先下载opencvopencv-contrib的包,解压然后按照:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
cd /home/software/opencv-3.4.4
mkdir build && cd build
cmake -D CMAKE_BUILD_TYPE=RELEASE -D BUILD_opencv_world=ON \
-D CMAKE_INSTALL_PREFIX=/home/software/opencv-3.4.4-install/ -D INSTALL_C_EXAMPLES=OFF \
-D OPENCV_EXTRA_MODULES_PATH=/home/software/opencv_contrib-3.4.4/modules \
-D OPENCV_ENABLE_NONFREE=ON -D BUILD_EXAMPLES=OFF -D WITH_FFMPEG=0 -D WITH_TIFF=OFF \
-D WITH_CUDA=ON -D ENABLE_FAST_MATH=1 -D CUDA_FAST_MATH=1 \
-D WITH_CUBLAS=ON -D WITH_LAPACK=OFF -D WITH_GTK=OFF -D WITH_GTK_2_X=OFF -D WITH_MATLAB=OFF -D WITH_QT=OFF \
-D CUDA_NVCC_FLAGS="-D_FORCE_INLINES" -D ENABLE_CXX11=1 \
-D BUILD_opencv_python3=ON -D BUILD_opencv_python2=ON \
-D WITH_PROTOBUF=ON -D BUILD_PROTOBUF=OFF -D -BUILD_LIBPROTOBUF_FROM_SOURCES=OFF -D PROTOBUF_UPDATE_FILES=OFF \
-D ENABLE_PRECOMPILED_HEADERS=ON -D BLAS=Open \
-D Protobuf_INCLUDE_DIR=/home/software/protobuf-3.5.1-install/include \
-D Protobuf_INCLUDE_DIRS=/home/software/protobuf-3.5.1-install/include \
-D Protobuf_LIBRARIES='/home/software/protobuf-3.5.1-install/lib/libprotobuf.so;-lpthread' \
-D Protobuf_LIBRARY=/home/software/protobuf-3.5.1-install/lib/libprotobuf.so \
-D Protobuf_LIBRARY_DEBUG=/home/software/protobuf-3.5.1-install/lib/libprotobuf.so \
-D Protobuf_LITE_LIBRARIES=/home/software/protobuf-3.5.1-install/lib/libprotobuf-lite.so \
-D Protobuf_LITE_LIBRARY=/home/software/protobuf-3.5.1-install/lib/libprotobuf-lite.so \
-D Protobuf_LITE_LIBRARY_DEBUG=/home/software/protobuf-3.5.1-install/lib/libprotobuf-lite.so \
-D Protobuf_PROTOC_EXECUTABLE=/home/software/protobuf-3.5.1-install/bin/protoc \
-D Protobuf_PROTOC_LIBRARIES=/home/software/protobuf-3.5.1-install/lib/libprotoc.so \
-D Protobuf_PROTOC_LIBRARY=/home/software/protobuf-3.5.1-install/lib/libprotoc.so \
-D Protobuf_PROTOC_LIBRARY_DEBUG=/home/software/protobuf-3.5.1-install/lib/libprotoc.so \
-D PYTHON3_EXECUTABLE=/root/miniconda3/bin/python \
-D PYTHON3_INCLUDE_DIR=/root/miniconda3/include/python3.6m \
-D PYTHON3_LIBRARY=/root/miniconda3/lib/libpython3.6m.so \
-D PYTHON3_NUMPY_INCLUDE_DIRS=/root/miniconda3/lib/python3.6/site-packages/numpy/core/include \
-D INSTALL_PYTHON_EXAMPLES=OFF -D OPENCV_SKIP_PYTHON_LOADER=ON \
-D ZLIB_LIBRARY=/home/software/zlib-1.2.11-install/lib/libz.so \
-D ZLIB_INCLUDE_DIR=/home/software/zlib-1.2.11-install/include \
-D PNG_LIBRARY=/home/software/libpng-1.6.37-install/lib/libpng.so \
-D PNG_PNG_INCLUDE_DIR=/home/software/libpng-1.6.37-install/include \
-D JPEG_LIBRARY=/home/software/jpeg-9c-install/lib/libjpeg.so \
-D JPEG_INCLUDE_DIR=/home/software/jpeg-9c-install/include \
-D HDF5_LIBRARIES=/root/miniconda3/lib/libhdf5_cpp.so \
-D HDF5_INCLUDE_DIRS=/root/miniconda3/include \
-D GLOG_LIBRARY=/home/software/glog-0.4.0-install/lib/libglog.so \
-D GLOG_INCLUDE_DIR=/home/software/glog-0.4.0-install/include \
..
make -j && make install

如果报下载boostdesc_bgm.i等i文件错误,到该issue下下载,放到指定路径(修改下载地址为本地file://),其他下载错误同理。若是hash验证不通过,则修改对应cmakelist里的hash值为actual值就行。

要是报c++内部错误,可能是内存炸了,make -j改小点(如make -j4)。

安装完成后,到安装路径(CMAKE_INSTALL_PREFIX=/home/software/opencv-3.4.4-install)的python目录下,可以发现python-3.6文件夹,里面都有cv2.cpython-36m-x86_64-linux-gnu.so文件,到对应python环境lib/python3.6/site-packages下,建立so文件的软链接(如到/root/miniconda3/lib/python3.6/site-packages下执行:ln -s /home/software/opencv-3.4.4-install/python/python-3.6/cv2.cpython-36m-x86_64-linux-gnu.so /root/miniconda3/lib/python3.6/site-packages/cv2.so); 最后,检查是否安装成功,也可建立对应的opencv.pc文件,并添加到PATH路径。

添加所有库路径vi /root/.bashrc

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
export BOOST_PATH=/home/software/boost_1_68_0-install
export CMAKE_PATH=/home/software/cmake-3.15.0-rc3-install
export DOXYGEN_PATH=/home/software/doxygen-Release_1_8_15-install
export GFLAGS_PATH=/home/software/gflags-2.2.0-install
export GLOG_PATH=/home/software/glog-0.4.0-install
export HDF5_PATH=/home/software/hdf5-1.8.21-install
export JPEG_PATH=/home/software/jpeg-9c-install
export LEVELDB_PATH=/home/software/leveldb-1.22-install
export LIBPNG_PATH=/home/software/libpng-1.6.37-install
export LIBTOOL_PATH=/home/software/libtool-2.4.6-install
export LMDB_PATH=/home/software/lmdb-LMDB_0.9.23-install
export OPENBLAS_PATH=/home/software/OpenBLAS-0.3.6-install
export OPENCV_PATH=/home/software/opencv-3.4.4-install
export PROTOBUF_PATH=/home/software/protobuf-3.5.1-install
export SNAPPY_PATH=/home/software/snappy-1.1.7-install
export ZLIB_PATH=/home/software/zlib-1.2.11-install
export PATH=$DOXYGEN_PATH/bin:$PROTOBUF_PATH/bin:$LIBTOOL_PATH/bin:$CMAKE_PATH/bin:$PATH
export LD_LIBRARY_PATH=$BOOST_PATH/lib:$CMAKE_PATH/lib:$GFLAGS_PATH/lib:$GLOG_PATH/lib:$HDF5_PATH/lib:$JPEG_PATH/lib:$LEVELDB_PATH/lib:$LIBPNG_PATH/lib:$LIBTOOL_PATH/lib:$LMDB_PATH/lib:$OPENBLAS_PATH/lib:$OPENCV_PATH/lib:$PROTOBUF_PATH/lib:$SNAPPY_PATH/lib:$ZLIB_PATH/lib:$LD_LIBRARY_PATH
export C_INCLUDE_PATH=$BOOST_PATH/include:$CMAKE_PATH/include:$GFLAGS_PATH/include:$GLOG_PATH/include:$HDF5_PATH/include:$JPEG_PATH/include:$LEVELDB_PATH/include:$LIBPNG_PATH/include:$LIBTOOL_PATH/include:$LMDB_PATH/include:$OPENBLAS_PATH/include:$OPENCV_PATH/include:$PROTOBUF_PATH/include:$SNAPPY_PATH/include:$ZLIB_PATH/include:$C_INCLUDE_PATH
export CPLUS_INCLUDE_PATH=$BOOST_PATH/include:$CMAKE_PATH/include:$GFLAGS_PATH/include:$GLOG_PATH/include:$HDF5_PATH/include:$JPEG_PATH/include:$LEVELDB_PATH/include:$LIBPNG_PATH/include:$LIBTOOL_PATH/include:$LMDB_PATH/include:$OPENBLAS_PATH/include:$OPENCV_PATH/include:$PROTOBUF_PATH/include:$SNAPPY_PATH/include:$ZLIB_PATH/include:$CPLUS_INCLUDE_PATH

安装caffe

把caffe源码库拷贝下来后,有两种编译caffe的方式:

  • 在caffe目录下直接 makemake pycaffe 来构建工程caffe的C++库和Python库;
  • mkdir build后,在build文件夹下cmake,然后再makemake pycaffe

对于makefile方法

主要修改Makefile.config文件,主要修改点有:

1
2
3
4
5
6
7
8
9
10
11
12
USE_CUDNN := 1
OPENCV_VERSION := 3
CUDA_DIR := /usr/local/cuda-8.0 # 选择特定的CUDA安装路径
# 选择特定的Python/Numpy安装include/lib目录
PYTHON_INCLUDE := /usr/local/public/anaconda3/envs/caffe_py35/include \
/usr/local/public/anaconda3/envs/caffe_py35/lib/python3.5/site-packages/numpy/core/include
PYTHON_LIBRARIES := boost_python3 python3.5m
PYTHON_LIB := /usr/local/public/anaconda2/envs/caffe_py3.5/lib /usr/local/lib/
INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include /usr/include/hdf5/serial
LIBRARY_DIRS := $(PYTHON_LIB) $(CUDA_DIR)/lib64 /usr/local/lib \
/usr/lib /usr/lib/x86_64-linux-gnu /usr/lib/x86_64-linux-gnu/hdf5/serial
USE_NCCL := 1 # 多GPU

同时,也可修改下Makefile文件里的:

1
NVCCFLAGS += -D_FORCE_INLINES -ccbin=$(CXX) -Xcompiler -fPIC $(COMMON_FLAGS)

对于cmake方法

修改cmake/Dependencies.cmake: 在if(BUILD_python)分支中,if(NOT "${python_version}" VERSION_LESS "3.0.0")分支中,添加:

1
2
3
4
if(NOT Boost_PYTHON_FOUND)
find_package(Boost 1.46 COMPONENTS "python3")
set(Boost_PYTHON_FOUND ${Boost_PYTHON3_FOUND})
endif()

需改cmake/Cuda.cmake中(具体可以对照GPU型号和支持的架构进行设置修改V100是70):

1
set(Caffe_known_gpu_archs "30 35 50 52 61 70")

然后到build文件加下,执行cmake:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
cd .. && rm -r build && mkdir build && cd build
cmake -D CMAKE_BUILD_TYPE=RELEASE \
-D CUDA_TOOLKIT_ROOT_DIR="/usr/local/cuda" \
-D CUDNN_INCLUDE="/usr/local/cuda/include" \
-D CUDNN_LIBRARY="/usr/local/cuda/lib64/libcudnn.so" \
-D CUDA_NVCC_FLAGS="-D_FORCE_INLINES" -D CMAKE_CXX_FLAGS="${CMAKE_CXX_FLAGS} -std=c++11" \
-D PYTHON_LIBRARIES="/root/miniconda3/lib;/usr/local/lib" \
-D PYTHON_INCLUDE_DIR=/root/miniconda3/include/python3.6m/ \
-D PYTHON_EXECUTABLE=/root/miniconda3/bin/python \
-D python_version=3.6 -D BLAS=Open -D CUDA_ARCH_NAME=All -D CUDA_NVCC_FLAGS="-D_FORCE_INLINES" \
-D CUDNN_INCLUDE="/usr/include" -D CUDNN_LIBRARY="/usr/lib/x86_64-linux-gnu/libcudnn.so" \
-D Protobuf_INCLUDE_DIR=/home/software/protobuf-2.6.1-install/include \
-D Protobuf_LIBRARY_RELEASE=/home/software/protobuf-2.6.1-install/lib/libprotobuf.so \
-D Protobuf_LIBRARY_DEBUG=/home/software/protobuf-2.6.1-install/lib/libprotobuf.so \
-D Protobuf_LITE_LIBRARY_RELEASE=/home/software/protobuf-2.6.1-install/lib/libprotobuf-lite.so \
-D Protobuf_LITE_LIBRARY_DEBUG=/home/software/protobuf-2.6.1-install/lib/libprotobuf-lite.so \
-D Protobuf_PROTOC_EXECUTABLE=/home/software/protobuf-2.6.1-install/bin/protoc \
-D Protobuf_PROTOC_LIBRARY_RELEASE=/home/software/protobuf-2.6.1-install/lib/libprotoc.so \
-D Protobuf_PROTOC_LIBRARY_DEBUG=/home/software/protobuf-2.6.1-install/lib/libprotoc.so \
-D PROTOBUF_INCLUDE_DIR=/home/software/protobuf-2.6.1-install/include \
-D PROTOBUF_INCLUDE_DIRS=/home/software/protobuf-2.6.1-install/include \
-D PROTOBUF_LIBRARIES='/home/software/protobuf-2.6.1-install/lib/libprotobuf.so;-lpthread' \
-D PROTOBUF_LIBRARY=/home/software/protobuf-2.6.1-install/lib/libprotobuf.so \
-D PROTOBUF_LIBRARY_DEBUG=/home/software/protobuf-2.6.1-install/lib/libprotobuf.so \
-D PROTOBUF_LITE_LIBRARIES=/home/software/protobuf-2.6.1-install/lib/libprotobuf-lite.so \
-D PROTOBUF_LITE_LIBRARY=/home/software/protobuf-2.6.1-install/lib/libprotobuf-lite.so \
-D PROTOBUF_LITE_LIBRARY_DEBUG=/home/software/protobuf-2.6.1-install/lib/libprotobuf-lite.so \
-D PROTOBUF_PROTOC_EXECUTABLE=/home/software/protobuf-2.6.1-install/bin/protoc \
-D PROTOBUF_PROTOC_LIBRARIES=/home/software/protobuf-2.6.1-install/lib/libprotoc.so \
-D PROTOBUF_PROTOC_LIBRARY=/home/software/protobuf-2.6.1-install/lib/libprotoc.so \
-D PROTOBUF_PROTOC_LIBRARY_DEBUG=/home/software/protobuf-2.6.1-install/lib/libprotoc.so \
-D CMAKE_PREFIX_PATH='/home/software/boost_1_68_0-install;/home/software/cmake-3.15.0-rc3-install;/home/software/doxygen-Release_1_8_15-install;/home/software/gflags-2.2.0-install;/home/software/glog-0.4.0-install;/home/software/hdf5-1.8.21-install;/home/software/jpeg-9c-install;/home/software/leveldb-1.22-install;/home/software/libpng-1.6.37-install;/home/software/libtool-2.4.6-install;/home/software/lmdb-LMDB_0.9.23-install;/home/software/OpenBLAS-0.3.6-install;/home/software/opencv-3.4.4-install2;/home/software/protobuf-3.5.1-install;/home/software/snappy-1.1.7-install;/home/software/zlib-1.2.11-install/lib' \
-D CMAKE_INSTALL_PREFIX=/home/caffe ..
make -j
make pycaffe
make install

Q. 如果的确已经安装protobuf 2.6.1,但还是出现版本不对(older version),可以加入以下编译选项(其实是conda里的protobuf造成的影响)。

A. 我是将conda中protobuf的头文件的文件夹名由protobuf改为其他名。

1
2
3
4
5
6
7
8
-D Protobuf_INCLUDE_DIR=/home/software/protobuf-2.6.1-install/include \
-D Protobuf_LIBRARY_RELEASE=/home/software/protobuf-2.6.1-install/lib/libprotobuf.so \
-D Protobuf_LIBRARY_DEBUG=/home/software/protobuf-2.6.1-install/lib/libprotobuf.so \
-D Protobuf_LITE_LIBRARY_RELEASE=/home/software/protobuf-2.6.1-install/lib/libprotobuf-lite.so \
-D Protobuf_LITE_LIBRARY_DEBUG=/home/software/protobuf-2.6.1-install/lib/libprotobuf-lite.so \
-D Protobuf_PROTOC_EXECUTABLE=/home/software/protobuf-2.6.1-install/bin/protoc \
-D Protobuf_PROTOC_LIBRARY_RELEASE=/home/software/protobuf-2.6.1-install/lib/libprotoc.so \
-D Protobuf_PROTOC_LIBRARY_DEBUG=/home/software/protobuf-2.6.1-install/lib/libprotoc.so \

Q. 如果发生protobuf undefined reference的问题? 安装glog A. protobuf版本问题,opencv用3.5.1编译,而caffe需要2.6.1,所以依赖不一致。我是把opencv编一个不用protobuf的版本,提供给caffe的。

保存新镜像

1
2
docker commit #container-id basic-caffe:2.0.0
docker save basic-caffe:2.0.0 | gzip > basic-caffe.tar.gz
感谢对原创的支持~