Skip to content

Latest commit

 

History

History
891 lines (779 loc) · 43.6 KB

踩坑.md

File metadata and controls

891 lines (779 loc) · 43.6 KB

源码编译 Caffe1.0

基于: conda py37; cuda11.1; cudnn8; numpy1.9.1; opencv4.3(CUDA11.1); gcc9.1; std c++11

依赖库的版本一定要对应;尤其是protobuf

系统环境检查

# 查看当前conda环境
>> conda env export > torch11.yaml

# 查看Centos版本
>> cat /etc/redhat-release
CentOS Linux release 7.2.1511 (Core)

# 查看CUDA版本
>> nvcc --version
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2020 NVIDIA Corporation
Built on Mon_Oct_12_20:09:46_PDT_2020
Cuda compilation tools, release 11.1, V11.1.105
Build cuda_11.1.TC455_06.29190527_0

>> cd /usr/local
>> ls -al
...
lrwxrwxrwx.  1 root root   21 Mar 11 23:34 cuda -> /usr/local/cuda-11.1/
drwxr-xr-x. 15 root root 4096 May 12  2020 cuda-10.1
drwxr-xr-x. 15 root root 4096 Sep 11  2020 cuda-10.2
drwxr-xr-x. 14 root root 4096 Mar 11 23:35 cuda-11.1
lrwxrwxrwx.  1 root root   20 Mar 29 16:57 cuda-8.0 -> /home/share/cuda-8.0
lrwxrwxrwx.  1 root root   20 Mar 29 16:57 cuda-9.0 -> /home/share/cuda-9.0
...

# CUDNN版本
cat ~/.zshrc
...
# CUDNN
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/share/cudnn-8.0-v5.1/lib64
...

python版本
Python 3.7.3 (default, Mar 27 2019, 22:11:17) 
[GCC 7.3.0] :: Anaconda, Inc. on linux

下载源码

注意在编译完成caffe之前,别安装python依赖 因为:python依赖中requirements.txt要求protobuf>=2.5.0;直接pip install会安装一个2021年较新的protobuf-3.18; 而caffe使用的版本较老; 所以建议是安装老依赖;但是protobuf-2.5.0的pyhon接口是python2的,

我使用的是:pip install protobuf==3.6.0编译caffe用了protobuf的3.6版本,python依赖也要装3.6版本

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

以下是坑,快跳过去

若:出现pip相关的ERROR,因为pip 20.3之后,新的依赖解释器默认是打开状态,但可能出现兼容问题,有一些老包没适配这个新的解释器,所以需要加一个参数,来安装这些没有适配的老包 ERROR: After October 2020 you may experience errors when installing or updating packages. This is because pip will change the way that it resolves dependency conflicts. We recommend you use --use-feature=2020-resolver to test your packages with the new resolver before it becomes the default.

升级pip,加上参数再安装pycaffe的依赖

python -m pip install --upgrade pip
pip install -r caffe/python/requirements.txt --use-feature=2020-resolver

安装C、C++依赖

查看 Makefile.config: 需要有opencv,CUDA,BLAS(矩阵运算库),hdf5(数据格式),protobuf(数据格式),glog(谷歌轻量级日志库),gflags(谷歌命令行标记处理库),lmdb(轻量内存映射型数据库),leveldb(持久化KV单机数据库) ,cuDNN,python,numpy,boostpython(python中调用c++,或者c++中调用python)

opencv4

电脑里两个版本的opencv

  1. 查看python对应的opencv版本(只安装了动态库cv2.so, 位于dist-packages)
import cv2
cv2.__version__
`opencv 4.4.0`
  1. 从源码编译,使用了cuda加速版本的opencv4.3,建议编译的时候,为了让opencv依赖的库版本适配,需要将那些依赖的的源码编译选项打开,opencv很人性化的将一些依赖的对应源码放在了3rdparty

可以使用我的安装脚本zzopencv.sh

但实际上pc文件位于以下路径
"$ROOTDIR"/lib64/pkgconfig
所以zshrc环境变量中加入
export PKG_CONFIG_PATH=$ZZROOT/lib64/pkgconfig:$PKG_CONFIG_PATH

源码编译openblas(编译caffe没用到这个版本,optional)

安装openblas

以下是坑,快跳过

>> yum search openblas
>> yumdownloader openblas-devel.x86_64
得到
openblas-devel-0.3.3-2.el7.x86_64.rpm 

rpm2cpio openblas-devel-0.3.3-2.el7.x86_64.rpm  |cpio -idvm
得到:
./usr/include/openblas                                                             │
./usr/include/openblas/cblas.h                                                     │
./usr/include/openblas/f77blas.h                                                   │
./usr/include/openblas/lapacke.h                                                   │
./usr/include/openblas/lapacke_config.h                                            │
./usr/include/openblas/lapacke_mangling.h                                          │
./usr/include/openblas/lapacke_utils.h                                             │
./usr/include/openblas/openblas_config.h                                           │
./usr/lib64/libopenblas.so                                                         │
./usr/lib64/libopenblas64.so                                                       │
./usr/lib64/libopenblas64_.so                                                      │
./usr/lib64/libopenblaso.so                                                        │
./usr/lib64/libopenblaso64.so                                                      │
./usr/lib64/libopenblaso64_.so                                                     │
./usr/lib64/libopenblasp.so                                                        │
./usr/lib64/libopenblasp64.so                                                      │
./usr/lib64/libopenblasp64_.so  
重命名
mv usr OpenBLAS-0.3.3
移动到软件路径
mv OpenBLAS-0.3.3 ~/app

vi ~/.zshrc
配置动态链接库
export LD_LIBRARY_PATH=/home/zhangwenting/app/OpenBLAS-0.3.3/lib64:$LD_LIBRARY_PATH
不靠谱 ....... ======> 动态库都是软连接,链接到不存在的文件

boost_python37(编译caffe没用到这个版本,optional)

安装 boost_python37 Boost源码 /home/zhangwenting/zzapp/src/boost

whereis python
使用虚拟环境中的py37
/home/zhangwenting/anaconda3/envs/torch11/bin/python3.7m

cd /home/zhangwenting/zzapp/src/boost
./bootstrap.sh --with-python=/home/zhangwenting/anaconda3/envs/torch11/bin/python3.7m --prefix=.(安装在当前目录,默认安装位置是/usr/local)

输出:
Building Boost.Build engine with toolset gcc... tools/build/src/engine/b2          │
Detecting Python version... 3.7                                                    │
Detecting Python root... /home/zhangwenting/anaconda3/envs/torch11                 │
Unicode/ICU support for Boost.Regex?... /usr                                       │
Generating Boost.Build configuration in project-config.jam for gcc...              │

build提示信息:                                                                     │
Bootstrapping is done. To build, run:                                              │
    ./b2                                                                           │
                                                                                   │
To generate header files, run:                                                     │
    ./b2 headers                                                                   │
                                                                                   │
To adjust configuration, edit 'project-config.jam'.                                │
Further information:                                                               │
                                                                                   │
   - Command line help:                                                            │
     ./b2 --help                                                                   │
                                                                                   │
   - Getting started guide:                                                        │
     http://www.boost.org/more/getting_started/unix-variants.html                  │
                                                                                   │
   - Boost.Build documentation:                                                    │
     http://www.boost.org/build/  

根据提示
执行 ./b2 --with-python include="/home/zhangwenting/anaconda3/envs/torch11/include/python3.7m/" 得到动态链接库
执行 ./b2 install

输出
...
The Boost C++ Libraries were successfully built!
The following directory should be added to compiler include paths: 编译器 include paths
    /home/zhangwenting/zzapp/src/boost 
The following directory should be added to linker library paths: 链接库 paths 要写入环境变量
    /home/zhangwenting/zzapp/src/boost/stage/lib

>> ls stage/lib
cmake                  libboost_numpy37.so.1.73    libboost_python37.so.1          │
libboost_numpy37.a     libboost_numpy37.so.1.73.0  libboost_python37.so.1.73       │
libboost_numpy37.so    libboost_python37.a         libboost_python37.so.1.73.0     │
libboost_numpy37.so.1  libboost_python37.so                                   
编译出了挺多东西的

vi ~/.zshrc
export LD_LIBRARY_PATH=/home/zhangwenting/zzapp/src/boost/lib:$LD_LIBRARY_PATH

caffe编译时能查询到 libboost_python37.sopython3.7m

修改 caffe 的 Makefile 中对应配置:PYTHON_LIBRARIES := libboost_python37 python3.7m

hdf5(编译caffe没用到这个版本,optional)

安装hdf5 通过setup安装,当然zzsetup里面的有的脚本中的下载路径可能过期了,自己配置一下; 他都会安装到$ZZROOT路径下

echo $ZZROOT 
/home/zhangwenting/zzapp
sh zzopencv.sh # 很久以前安装的,这个脚本写了一套从源码安装的流程
sh zzhdf5.sh # 也是从源码编译安装,放到$ZZROOT路径下
安装后多出来了
$ZZROOT/share/hdf5_examples
$ZZROOT/src/hdf5/
$ZZROOT/include/

protobuf(编译caffe用了这个版本,necessary)

安装protobuf

protobuf-2.5.0还是用的python2语法编写的。python setup.py build 会有py2的语法错误 有几个ISSUE说caffe能支持到protobuf-3.6.0 BVLC#5711 BVLC#6359

wget https://github.com/google/protobuf/releases/download/v3.6.0/protobuf-3.6.0.tar.gz
tar -zxvf protobuf-3.6.0.tar.gz 
cd protobuf-3.6.0/ 
./configure --prefix=/your/install/path 
make 
make install
cd protobuf-3.6.0/python
python setup.py build
python setup.py install # 会生成 当前python环境下的 包;但是最终的pycaffe中没有使用他

更新cmake2到cmake3(最终编译caffe使用了该版本,necessary)

glog-master8d40d75最低支持3.0.2的Cmake版本

git clone https://github.com/google/glog.git

需要用cmake安装
>> whereis cmake
cmake: /usr/bin/cmake /usr/lib64/cmake /usr/share/cmake /usr/share/man/man1/cmake.1.gz
cmake version 2.8.11

cmake -S . -B build -G "Unix Makefiles"
提示最低支持3.0.2的Cmake版本
下载最新的编译好的cmake
>> cd ~/app
>> wget https://github.com/Kitware/CMake/releases/download/v3.20.1/cmake-3.20.1-linux-x86_64.tar.gz
>> tar -xzvf cmake-3.20.1-linux-x86_64.tar.gz
>> cd cmake-3.20.1-linux-x86_64
>> vi ~/.zhrc
>> export PATH=/home/zhangwenting/app/cmake-3.20.1-linux-x86_64/bin:$PATH
>> source ~/.zshrc
>> cmake --version
cmake version 3.20.1
>> whereis cmake
cmake: /usr/bin/cmake /usr/lib64/cmake /usr/share/cmake /home/zhangwenting/app/cmake-3.20.1-linux-x86_64/bin/cmake /usr/share/man/man1/cmake.1.gz
可见刚刚装的cmake优先级更高
再保险一点

>> vi ~/.zshrc
alias cmake=/home/zhangwenting/app/cmake-3.20.1-linux-x86_64/bin/cmake
alias cmake2=/usr/bin/cmake

安装glog,先安装gflags,gtest

gflags(编译caffe没用到这个版本,optional)

安装gflags

wget https://codeload.github.com/gflags/gflags/tar.gz/v2.2.0
tar -zxvf gflags-2.2.0.tar.gz
cd gflags-2.2.0/
mkdir build
cd build/
cmake ..
ccmake ..
调出配置
                                                     Page 1 of 1
 BUILD_PACKAGING                  OFF
 BUILD_SHARED_LIBS                ON
 BUILD_TESTING                    OFF
 BUILD_gflags_LIB                 ON
 BUILD_gflags_nothreads_LIB       ON
 CMAKE_BUILD_TYPE                 Release
 CMAKE_INSTALL_PREFIX             /home/zhangwenting/zzapp
 REGISTER_BUILD_DIR               OFF
 REGISTER_INSTALL_PREFIX          ON

[ press c then e then g]
最后执行编译安装
make -j4

[ 12%] Building CXX object CMakeFiles/gflags_shared.dir/src/gflags.cc.o
[ 25%] Building CXX object CMakeFiles/gflags_nothreads_shared.dir/src/gflags.cc.o
[ 37%] Building CXX object CMakeFiles/gflags_shared.dir/src/gflags_reporting.cc.o
[ 50%] Building CXX object CMakeFiles/gflags_shared.dir/src/gflags_completions.cc.o
[ 62%] Building CXX object CMakeFiles/gflags_nothreads_shared.dir/src/gflags_reporting.cc.o
[ 75%] Building CXX object CMakeFiles/gflags_nothreads_shared.dir/src/gflags_completions.cc.o
[ 87%] Linking CXX shared library lib/libgflags_nothreads.so
[100%] Linking CXX shared library lib/libgflags.so
[100%] Built target gflags_nothreads_shared
[100%] Built target gflags_shared

make install
(base) ➜  build make install
Consolidate compiler generated dependencies of target gflags_shared
[ 50%] Built target gflags_shared
Consolidate compiler generated dependencies of target gflags_nothreads_shared
[100%] Built target gflags_nothreads_shared
Install the project...
-- Install configuration: "Release"
-- Installing: /home/zhangwenting/zzapp/lib/libgflags.so.2.2.0
-- Installing: /home/zhangwenting/zzapp/lib/libgflags.so.2.2
-- Installing: /home/zhangwenting/zzapp/lib/libgflags.so
-- Installing: /home/zhangwenting/zzapp/lib/libgflags_nothreads.so.2.2.0
-- Installing: /home/zhangwenting/zzapp/lib/libgflags_nothreads.so.2.2
-- Installing: /home/zhangwenting/zzapp/lib/libgflags_nothreads.so
-- Installing: /home/zhangwenting/zzapp/include/gflags/gflags.h
-- Installing: /home/zhangwenting/zzapp/include/gflags/gflags_declare.h
-- Installing: /home/zhangwenting/zzapp/include/gflags/gflags_completions.h
-- Installing: /home/zhangwenting/zzapp/include/gflags/gflags_gflags.h
-- Installing: /home/zhangwenting/zzapp/lib/cmake/gflags/gflags-config.cmake
-- Installing: /home/zhangwenting/zzapp/lib/cmake/gflags/gflags-config-version.cmake
-- Installing: /home/zhangwenting/zzapp/lib/cmake/gflags/gflags-targets.cmake
-- Installing: /home/zhangwenting/zzapp/lib/cmake/gflags/gflags-targets-release.cmake
-- Installing: /home/zhangwenting/zzapp/bin/gflags_completions.sh
-- Installing: /home/zhangwenting/zzapp/lib/pkgconfig/gflags.pc
-- Installing: /home/zhangwenting/.cmake/packages/gflags/8675a4a6997470d9d629b8efbe6d1dba

gtest(编译caffe没用到这个版本,optional)

安装gtest

wget https://github.com/google/googletest/archive/refs/tags/release-1.8.1.tar.gz
tar -xzvf googletest-release-1.8.1.tar.gz
cd googletest-release-1.8.1
mkdir build
cd build
cmake .. 生成配置Makefile

-- The C compiler identification is GNU 4.8.5
-- The CXX compiler identification is GNU 4.8.5
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed (???????)
-- Check if compiler accepts -pthread
-- Check if compiler accepts -pthread - yes
-- Configuring done
-- Generating done
-- Build files have been written to: /home/zhangwenting/app/googletest-release-1.8.1/build

ccmake ..
设置如下
                                                     Page 1 of 1
 BUILD_GMOCK                      ON
 BUILD_SHARED_LIBS                ON
 CMAKE_BUILD_TYPE
 CMAKE_INSTALL_PREFIX             /home/zhangwenting/zzapp
 INSTALL_GTEST                    ON
 gmock_build_tests                OFF
 gtest_build_samples              OFF
 gtest_build_tests                OFF
 gtest_disable_pthreads           OFF
 gtest_force_shared_crt           OFF
 gtest_hide_internal_symbols      OFF

make -j4 编译
make install 安装
关键文件:
/home/zhangwenting/zzapp/lib64/pkgconfig/gtest.pc
/home/zhangwenting/zzapp/lib64/libgtest.so
/home/zhangwenting/zzapp/lib64/libgtest_main.so
/home/zhangwenting/zzapp/lib64/libgmock_main.so
/home/zhangwenting/zzapp/lib64/libgmock.so
/home/zhangwenting/zzapp/include
/home/zhangwenting/zzapp/lib64/cmake/GTest/GTestConfig.cmake
...

glog(编译caffe没用到这个版本,optional)

安装glog

------------------------------------------ 弃用 --------------------------------------------------

wget https://github.com/google/glog/archive/refs/tags/v0.4.0.tar.gz
tar -xzvf glog-0.4.0.tar.gz
cd glog-0.4.0
mkdir build
cd build
cmake ..
ccmake ..
                                                     Page 1 of 1
 BUILD_SHARED_LIBS                ON
 BUILD_TESTING                    ON
 CMAKE_BUILD_TYPE
 CMAKE_INSTALL_PREFIX             /home/zhangwenting/zzapp
 PRINT_UNSYMBOLIZED_STACK_TRACE   OFF
 WITH_GFLAGS                      ON
 WITH_THREADS                     ON
 WITH_TLS                         ON
 gflags_DIR                       /home/zhangwenting/zzapp/lib/cmake/gflags

出现报错 libgflas.so.2.2.0
libglog.so.0.4.0: undefined reference to `google::FlagRegistererr::FlagRegisterer<std::string>(char const*, char const*, char const*, std::string*, std::string*)
意思大致是gflag中找不到google这个命名空间
查一下CMake日志: glog-0.4.0/build/CMakeFiles/CMakeError.log
"Determining the gflags namespace gflags failed with the following output:" 找到了gflags的命名空间为gflags
总结原因:glog认为gflags的命名空间应该为google,但我们安装的gflags(2.2)命名空间为gflags(老版gflags命名空间才是gflags)
尝试重新安装gflags,改命名空间失败
cmake -DBUILD_SHARED_LIBS=ON -DGFLAGS_NAMESPACE=google -DCMAKE_INSTALL_PREFIX=/opt/gflags -DCMAKE_CXX_FLAGS=-fPIC ..
解决方案:https://github.com/google/glog/issues/317 作者让使用最新的glog
------------------------------------------ 弃用 --------------------------------------------------

>> git clone https://github.com/google/glog.git
>> mv glog glog-master
>> cd glog-master
>> cmake -S . -B build -G "Unix Makefiles"
记录一下错误

-- Could NOT find Unwind (missing: Unwind_INCLUDE_DIR Unwind_LIBRARY Unwind_PLATFORM_LIBRARY)
-- Check size of unsigned __int16 - failed
-- Looking for dladdr - not found
-- Performing Test HAVE_NO_UNNAMED_TYPE_TEMPLATE_ARGS - Failed
-- Looking for UnDecorateSymbolName in dbghelp - not found
-- Performing Test HAVE_RWLOCK - Failed
-- Performing Test HAVE___DECLSPEC - Failed
-- Performing Test STL_NO_NAMESPACE - Failed
-- Performing Test HAVE_MSVC_TLS - Failed


>> cd build
>> cmake ..

我试了在环境变量里加入 Unwind_INCLUDE_DIR Unwind_LIBRARY Unwind_PLATFORM_LIBRARY 然并卵
-- Could NOT find Unwind (missing: Unwind_INCLUDE_DIR Unwind_LIBRARY Unwind_PLATFORM_LIBRARY)
-- Configuring done
-- Generating done
-- Build files have been written to: /home/zhangwenting/app/glog-master/build

>> ccmake ..
                                                     Page 1 of 1
 BUILD_SHARED_LIBS                ON
 BUILD_TESTING                    ON
 CMAKE_BUILD_TYPE
 CMAKE_INSTALL_PREFIX             /home/zhangwenting/zzapp
 GTest_DIR                        /home/zhangwenting/zzapp/lib64/cmake/GTest
 PRINT_UNSYMBOLIZED_STACK_TRACE   OFF
 WITH_CUSTOM_PREFIX               OFF
 WITH_GFLAGS                      ON
 WITH_GTEST                       ON
 WITH_PKGCONFIG                   ON
 WITH_SYMBOLIZE                   ON
 WITH_THREADS                     ON
 WITH_TLS                         ON
 WITH_UNWIND                      ON
 gflags_DIR                       /home/zhangwenting/zzapp/lib/cmake/gflags
 Unwind_INCLUDE_DIR               /home/zhangwenting/app/libunwind-devel-1.1/include
 Unwind_LIBRARY                   /home/zhangwenting/app/libunwind-devel-1.1/lib/libunwind.so
 Unwind_PLATFORM_LIBRARY          /home/zhangwenting/app/libunwind-devel-1.1/lib/libunwind-x86_64.so

注意还要自己编译一个libunwind,根据官方git就行

修改Makefile.config (最终编译没用到,optional)

INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include /usr/lib/x86_64-redhat-linux6E/include /home/zhangwenting/zzapp/include/opencv4 /home/zhangwenting/zzapp/include

让caffe编译的时候能找到/home/zhangwenting/zzapp/include路径下的hdf5.h
由于不是root用户,对/usr/local/include没有读写权限,所以这个路径几乎是空的

LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib /usr/lib/x86_64-linux-gnu/hdf5/serial
我们改为
LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib /usr/lib/x86_64-redhat-linux6E/lib64 /home/zhangwenting/zzapp/lib64 /home/zhangwenting/zzapp/lib

------------------------------------------------------
修改MakeFile
LIBRARIES += glog gflags protobuf boost_system boost_filesystem boost_regex m hdf5_hl hdf5 opencv_core opencv_highgui opencv_imgproc

最终版本(超快速安装)

使用anaconda安装依赖(这些依赖的版本一定是互相适配你的系统(cuda,gcc...)的,但是和caffe不一定兼容,未来某天如果你还想从源码编译caffe的话,记得使用2021.4.22经过检验的这些依赖库版本)

conda activate torch11 (一个装了pytorch1.1的虚拟环境)

conda install -c conda-forge glog
conda install -c conda-forge zlib
conda install -c conda-forge openblas
conda install -c conda-forge lmdb
conda install -c conda-forge leveldb
conda install -c conda-forge protobuf (坑:会安装高版本的protobuf出现兼容)
conda install -c conda-forge boost
conda install -c conda-forge hdf5

The following packages will be downloaded:

package                    |            build
---------------------------|-----------------
ca-certificates-2020.12.5  |       ha878542_0         137 KB  conda-forge
certifi-2020.12.5          |   py37h89c1867_1         143 KB  conda-forge
gflags-2.2.2               |    he1b5a44_1004         114 KB  conda-forge
glog-0.4.0                 |       h49b9bf7_3         104 KB  conda-forge
openssl-1.1.1h             |       h516909a_0         2.1 MB  conda-forge
python_abi-3.7             |          1_cp37m           4 KB  conda-forge
zlib-1.2.11                |    h516909a_1010         106 KB  conda-forge
libgfortran-ng-7.5.0       |      h14aa051_19          22 KB  conda-forge
libgfortran4-7.5.0         |      h14aa051_19         1.3 MB  conda-forge
libopenblas-0.3.12         |pthreads_hb3c22a3_1         8.2 MB  conda-forge
openblas-0.3.12            |pthreads_h43bd3aa_1         8.7 MB  conda-forge
lmdb-0.9.24                |       h516909a_0         660 KB  conda-forge
leveldb-1.22               |       h7cfaab3_1         197 KB  conda-forge
snappy-1.1.8               |       he1b5a44_3          32 KB  conda-forge
protobuf-3.13.0            |   py37h3340039_0         696 KB  conda-forge  
boost-1.74.0               |   py37he5a615d_2         335 KB  conda-forge
boost-cpp-1.74.0           |       h9d3c048_1        16.3 MB  conda-forge
bzip2-1.0.8                |       h516909a_3         398 KB  conda-forge
icu-68.1                   |       h58526e2_0        13.0 MB  conda-forge
hdf5-1.12.0                |nompi_h54c07f9_102         3.3 MB  conda-forge
krb5-1.17.2                |       h926e7f8_0         1.4 MB  conda-forge
libcurl-7.71.1             |       hcdd3856_3         302 KB  conda-forge
libssh2-1.9.0              |       hab1572f_5         225 KB  conda-forge
Step 1 自动配置路径

使用cmake配置caffe的MakeFile, 使用我修改过的CMakeList.txt可以避免boost_python模块找不到的坑:

>> cd caffe
>> mkdir build
>> cd build
>> cmake ..
得到以下输出, 提示一些库的路径无法自动找到,需要手动配置
 CMake Deprecation Warning at CMakeLists.txt:1 (cmake_minimum_required):
   Compatibility with CMake < 2.8.12 will be removed from a future version of
   CMake.

   Update the VERSION argument <min> value or use a ...<max> suffix to tell
   CMake that the project does not need compatibility with older versions.

 The C compiler identification is GNU 4.8.5
 The CXX compiler identification is GNU 4.8.5
 Detecting C compiler ABI info
 Detecting C compiler ABI info - done
 Check for working C compiler: /usr/bin/cc - skipped
 Detecting C compile features
 Detecting C compile features - done
 Detecting CXX compiler ABI info
 Detecting CXX compiler ABI info - done
 Check for working CXX compiler: /usr/bin/c++ - skipped
 Detecting CXX compile features
 Detecting CXX compile features - done
 CMake Warning (dev) at cmake/Misc.cmake:32 (set):
   implicitly converting 'BOOLEAN' to 'STRING' type.
 Call Stack (most recent call first):
   CMakeLists.txt:24 (include)
 This warning is for project developers.  Use -Wno-dev to suppress it.
 Looking for pthread.h
 Looking for pthread.h - found
 Performing Test CMAKE_HAVE_LIBC_PTHREAD
 Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
 Looking for pthread_create in pthreads
 Looking for pthread_create in pthreads - not found
 Looking for pthread_create in pthread
 Looking for pthread_create in pthread - found
 Found Threads: TRUE
 Found Boost: /home/zhangwenting/zzapp/src/boost (found suitable version "1.73.0", minimum required is "1.46") found components: system thread filesystem regex
 chrono date_time atomic
 Could NOT find GFlags (missing: GFLAGS_INCLUDE_DIR GFLAGS_LIBRARY)
 Could NOT find Glog (missing: GLOG_INCLUDE_DIR GLOG_LIBRARY)
 CMake Error at /home/zhangwenting/app/cmake-3.20.1-linux-x86_64/share/cmake-3.20/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
   Could NOT find Protobuf (missing: Protobuf_LIBRARIES Protobuf_INCLUDE_DIR)
 Call Stack (most recent call first):
   /home/zhangwenting/app/cmake-3.20.1-linux-x86_64/share/cmake-3.20/Modules/FindPackageHandleStandardArgs.cmake:594 (_FPHSA_FAILURE_MESSAGE)
   /home/zhangwenting/app/cmake-3.20.1-linux-x86_64/share/cmake-3.20/Modules/FindProtobuf.cmake:646 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
   cmake/ProtoBuf.cmake:4 (find_package)
   cmake/Dependencies.cmake:24 (include)
   CMakeLists.txt:43 (include)

 Configuring incomplete, errors occurred!
 See also "/home/zhangwenting/app/caffe-ssd/build/CMakeFiles/CMakeOutput.log". 
 See also "/home/zhangwenting/app/caffe-ssd/build/CMakeFiles/CMakeError.log". # 有error就查看这个文件,里面有详细的错误定位,细到源码位置

想了一下环境移植的事情,不同系统不容易直接移植,同系统把头文件库文件都拷走,路径配置对就行 annaconda是你配环境的利器

Step 2 手动配置路径

ccmake调出配置界面,他会自动生成你必填的一些选项,很智能 配置依赖的路径;建议别选软连接,尤其是二级软连接!

以下是部分配置,完整配置文件 ccmake.log

>> ccmake .. 
Protobuf_INCLUDE_DIR             /home/zhangwenting/anaconda3/envs/torch11/include
Protobuf_LIBRARY_DEBUG           /home/zhangwenting/anaconda3/envs/torch11/lib/libprotobuf.so
Protobuf_LIBRARY_RELEASE         /home/zhangwenting/anaconda3/envs/torch11/lib/libprotobuf.so
Protobuf_LITE_LIBRARY_DEBUG      /home/zhangwenting/anaconda3/envs/torch11/lib/libprotobuf-lite.so
Protobuf_LITE_LIBRARY_RELEASE    /home/zhangwenting/anaconda3/envs/torch11/lib/libprotobuf-lite.so
Protobuf_PROTOC_EXECUTABLE       /home/zhangwenting/anaconda3/envs/torch11/bin/protoc
Protobuf_PROTOC_LIBRARY_DEBUG    /home/zhangwenting/anaconda3/envs/torch11/lib/libprotoc.so
Protobuf_PROTOC_LIBRARY_RELEAS   /home/zhangwenting/anaconda3/envs/torch11/lib/libprotoc.so

Boost_DIR                        /home/zhangwenting/anaconda3/envs/torch11/lib/cmake/Boost-1.74.0
boost_filesystem_DIR             /home/zhangwenting/anaconda3/envs/torch11/lib/cmake/boost_filesystem-1.74.0
boost_headers_DIR                /home/zhangwenting/anaconda3/envs/torch11/lib/cmake/boost_headers-1.74.0
boost_system_DIR                 /home/zhangwenting/anaconda3/envs/torch11/lib/cmake/boost_system-1.74.0
boost_thread_DIR                 /home/zhangwenting/anaconda3/envs/torch11/lib/cmake/boost_thread-1.74.0
boost_python_DIR                 /home/zhangwenting/anaconda3/envs/torch11/lib/cmake/boost_python-1.74.0

Boost_INCLUDE_DIR                /home/zhangwenting/anaconda3/envs/torch11/include #??? include/boost
Boost_LIBRARY_DIR_DEBUG          /home/zhangwenting/anaconda3/envs/torch11/lib
Boost_LIBRARY_DIR_RELEASE        /home/zhangwenting/anaconda3/envs/torch11/lib

Boost_ATOMIC_LIBRARY_DEBUG       /home/zhangwenting/anaconda3/envs/torch11/lib/libboost_atomic.so
Boost_ATOMIC_LIBRARY_RELEASE     /home/zhangwenting/anaconda3/envs/torch11/lib/libboost_atomic.so
Boost_CHRONO_LIBRARY_DEBUG       /home/zhangwenting/anaconda3/envs/torch11/lib/libboost_chrono.so
Boost_CHRONO_LIBRARY_RELEASE     /home/zhangwenting/anaconda3/envs/torch11/lib/libboost_chrono.so
Boost_DATE_TIME_LIBRARY_DEBUG    /home/zhangwenting/anaconda3/envs/torch11/lib/libboost_date_time.so
Boost_DATE_TIME_LIBRARY_RELEASE  /home/zhangwenting/anaconda3/envs/torch11/lib/libboost_date_time.so
Boost_FIFESYSTEM_LIBRARY_DEBUG   /home/zhangwenting/anaconda3/envs/torch11/lib/libboost_filesystem.so
Boost_FIFESYSTEM_LIBRARY_RELEASE /home/zhangwenting/anaconda3/envs/torch11/lib/libboost_filesystem.so
Boost_SYSTEM_LIBRARY_DEBUG       /home/zhangwenting/anaconda3/envs/torch11/lib/libboost_system.so
Boost_SYSTEM_LIBRARY_RELEASE     /home/zhangwenting/anaconda3/envs/torch11/lib/libboost_system.so
Boost_THREAD_LIBRARY_DEBUG       /home/zhangwenting/anaconda3/envs/torch11/lib/libboost_thread.so
Boost_THREAD_LIBRARY_RELEASE     /home/zhangwenting/anaconda3/envs/torch11/lib/libboost_thread.so


HDF5_CXX_COMPILER_EXECUTABLE     /home/zhangwenting/anaconda3/envs/torch11/bin/h5c++
HDF5_CXX_INCLUDE_DIR             /home/zhangwenting/anaconda3/envs/torch11/include
HDF5_C_COMPILER_EXECUTABLE       /home/zhangwenting/anaconda3/envs/torch11/bin/h5cc
HDF5_C_INCLUDE_DIR               /home/zhangwenting/anaconda3/envs/torch11/include
HDF5_DIFF_EXECUTABLE             /home/zhangwenting/anaconda3/envs/torch11/bin/h5diff
HDF5_DIR                         /home/zhangwenting/anaconda3/envs/torch11
HDF5_hdf5_LIBRARY_DEBUG          /home/zhangwenting/anaconda3/envs/torch11/lib/libhdf5.so

LMDB_INCLUDE                     /home/zhangwenting/anaconda3/envs/torch11/include
LMDB_LIBRARIES                   /home/zhangwenting/anaconda3/envs/torch11/lib/liblmdb.so
LevelDB_INCLUDE                  /home/zhangwenting/anaconda3/envs/torch11/include
LevelDB_LIBRARIES                /home/zhangwenting/anaconda3/envs/torch11/lib/libleveldb.so
OpenBLAS_INCLUDE                 /home/zhangwenting/anaconda3/envs/torch11/include
OpenBLAS_LIB                     /home/zhangwenting/anaconda3/envs/torch11/lib/libopenblas.so
Snappy_INCLUDE_DIR               /home/zhangwenting/anaconda3/envs/torch11/include
Snappy_LIBRARIES                 /home/zhangwenting/anaconda3/envs/torch11/lib/libsnappy.so
GFLAGS_INCLUDE_DIR               /home/zhangwenting/anaconda3/envs/torch11/include
GFLAGS_LIBRARY                   /home/zhangwenting/anaconda3/envs/torch11/lib/libgflags.so
GLOG_INCLUDE_DIR                 /home/zhangwenting/anaconda3/envs/torch11/include
GLOG_LIBRARY                     /home/zhangwenting/anaconda3/envs/torch11/lib/libglog.so
CUDNN_LIBRARY                    /home/share/cudnn-8.0-v5.1/lib64/libcudnn.so

输入 c 检查依赖 输入 g 生成build/Makefile

-- Build files have been written to: /home/zhangwenting/software/caffe/build

输入 q 退出ccmake面板

Step 3 编译

编译

`make -j32 1> make.log 2> make.error`

如果使用了完整配置 ccmake.log,且用了小修版caffe 应该就顺顺利利,得到类似的编译成功日志,可以进入Step4了

记录一下我遇到过的ERROR

会有挺多warning出现,但只要不是Error就行,Warning是一些语法不规范,过时的提示

  1. 2%的时候提示需要使用c++11标准编译,改好的CMakeList.txt

  2. 75%的时候提示 /home/zhangwenting/app/caffe/src/caffe/layers/window_data_layer.cpp 中 CV_LOAD_IMAGE_COLOR 没有定义,因为caffe原本只支持到opencv3,我们用的opencv4 换成了cv::IMREAD_COLOR 这个定义 改一点点源码就行:参考 ISSUE#6919

  3. 90% Linking CXX executable compute_image_mean

  4. 92% Linking CXX executable convert_imageset

  5. 93% Linking CXX executable extract_features

3 4 5 都是一些undefined reference,libopencv_imgcodecs.so.4.3.0 中找到定义 libtiff-4.0 中的相关定义;是opencv的问题,不是caffe的问题,重新编译opecncv4.3libtiff依赖解决

/home/zhangwenting/zzapp/lib64/libopencv_imgcodecs.so.4.3.0: undefined reference to `TIFFClose@LIBTIFF_4.0'

以下是解决思路

查看libtiff的版本

>> locate libtiff
...

...
>> ll /usr/lib64 | grep libtiff
lrwxrwxrwx.  1 root root       16 Mar 22  2017 libtiff.so -> libtiff.so.5.2.0
lrwxrwxrwx.  1 root root       16 Mar 22  2017 libtiff.so.3 -> libtiff.so.3.9.4
...
>> ll $CONDA_ROOT/torch11/lib | grep libtiff
lrwxrwxrwx.  1 zhangwenting zhangwenting   16 Sep 28  2020 libtiff.so -> libtiff.so.5.5.0
...
我们用的都是5.0版本,要指定成4.0版本

发现了一个config文件:
>> cat /usr/lib64/pkgconfig/libtiff-4.pc
prefix=/usr
exec_prefix=/usr
libdir=/usr/lib64
includedir=/usr/include

Name: libtiff
Description:  Tag Image File Format (TIFF) library.
Version: 4.0.3
Libs: -L${libdir} -ltiff
Libs.private: -ljbig -ljpeg -lz 
Cflags: -I${includedir}

pc文件告诉我/usr/lib644.0.3版本的libtiff.so的所在地。然而并没有

注意到opencv4.3源码里有路径:/home/zhangwenting/zzapp/src/opencv/3rdparty/libtiff 里面定义了一堆.c .h文件,讲道理应该编译了一个libtiff4找到他! 没找到欸

查看了一下opencv4.3的编译日志(当初运行命令的时候重定向输出生成的, 随手存日志,好习惯!): 它使用了系统自带的libtiff(/lib64/libtiff.so (ver 42 / 4.0.3),与pc定义的一致,但可能根据pc去找so失败了)

解决方法:重新编译下opencv4.3日志, 使用libtiff源码(在opencv的3rdparty路径下)编译看能不能解决这个问题;查看opencv的CMakeLists.txtTIFF, cmake时加入参数 -D BUILD_TIFF=ON, 重新编译生成libtiff.solibopencv_imgcodecs.so.4.3.0 我觉得编译opencv的时候最好都使用源码编译,3rdparty中的源码编译确保版本一致 TIFF: /lib64/libtiff.so (ver 42 / 4.0.3)-->TIFF: build (ver 42 - 4.0.10)

  1. 100% 在Linking CXX shared library ../lib/_caffe.so时,
../lib/libcaffe.so.1.0.0: undefined reference to `google::protobuf::internal::xxxxx
../lib/libcaffe.so.1.0.0: undefined reference to `google::protobuf::MessageLite::xxxxx

以下是解决思路: 是protobuf的问题,2.5版本和3.14版本都试了一下,同时用gcc9.1自己编译了一个protobuf-2.5,但同样的报错, 确实缺失了include/google/protobuf/internel; 难道说找一个版本存在internel头文件的版本就行了?

不急,我们看一下caffe用到protobuf的地方 step1: src/caffe/test/test_data_layer.cpp 有这样的代码,这是proobuf的API,对照protobuf官方示例

  #include "caffe/proto/caffe.pb.h" # 盲猜这是`protoc`编译`src/caffe/proto/caffe.proto`的文件
  Datum datum;
  datum.set_label(i);
  datum.set_channels(2);
  datum.set_height(i % 2 + 1);
  datum.set_width(i % 4 + 1);
  CHECK(datum.SerializeToString(&out));

step2: build/include/caffe/proto/caffe.pb.h 其中有判断protoc版本和protobuf版本对应的文字,我用的是porotoc2.5,和文字也对应上了

#ifndef PROTOBUF_caffe_2eproto__INCLUDED
#define PROTOBUF_caffe_2eproto__INCLUDED

#include <string>

#include <google/protobuf/stubs/common.h>

#if GOOGLE_PROTOBUF_VERSION < 2005000
#error This file was generated by a newer version of protoc which is
#error incompatible with your Protocol Buffer headers.  Please update
#error your headers.
#endif
#if 2005000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION
#error This file was generated by an older version of protoc which is
#error incompatible with your Protocol Buffer headers.  Please
#error regenerate this file with a newer version of protoc.
#endif

#include <google/protobuf/generated_message_util.h>
#include <google/protobuf/message.h>
#include <google/protobuf/repeated_field.h>
#include <google/protobuf/extension_set.h>
#include <google/protobuf/generated_enum_reflection.h>
#include <google/protobuf/unknown_field_set.h>

step3: step1,2 可以确定protobuf和protoc需要对应,那是不是我们有多个版本的protobuf呢? 看到pip list中有protobuf,先卸了,可能是他起了冲突!卸干净一点!重新编译,果然关于protobuf的报错消失了。

解决方法

conda uninstall protobuf
conda uninstall libprotobuf
pip uninstall protobuf

make全部通过,没有出现make error

[100%] Built target caffe.bin
[100%] Linking CXX shared library ../lib/_caffe.so
Creating symlink /home/zhangwenting/software/caffe/python/caffe/_caffe.so -> /home/zhangwenting/software/caffe/build/lib/_caffe.so
[100%] Built target pycaffe

最后只剩关于c++14的Warning了; 这是我使用的CUDA11.1导致的, CUDA11.1 集成了CUB和Thrust库,使用了C++14规范

/usr/local/cuda/include/thrust/detail/config/cpp_dialect.h:104:13: warning: Thrust requires C++14. Please pass -std=c++14 to your compiler. Define THRUST_IGNORE_DEPRECATED_CPP_DIALECT to suppress this message.
  104 |   THRUST_COMPILER_DEPRECATION(C++14, pass -std=c++14 to your compiler);

/usr/local/cuda/include/cub/util_cpp_dialect.cuh:129:13: warning: CUB requires C++14. Please pass -std=c++14 to your compiler. Define CUB_IGNORE_DEPRECATED_CPP_DIALECT to suppress this message.
  129 |   CUB_COMPILER_DEPRECATION(C++14, pass -std=c++14 to your compiler);

想要支持CUDA11.1和cudnn8,估计又需要改一些源码了,遇到兼容性问题,再来改吧

Step 4 C++安装测试

安装

make install 1>install.log 2>install.error

日志

测试

make runtest 1>runtest.log 2>runtest.error

最后的check: 看一下生成_caffe.so动态库都用了哪些依赖 以下环境别乱改路径啊 完整输出见日志

>> ldd /home/zhangwenting/software/caffe/build/install/python/caffe/_caffe.so
linux-vdso.so.1 =>  (0x00007ffc913db000)
libcaffe.so.1.0.0 => /home/zhangwenting/software/caffe/build/install/lib64/libcaffe.so.1.0.0 (0x00007f4b15da7000)
libpython3.7m.so.1.0 => /home/zhangwenting/anaconda3/envs/torch11/lib/libpython3.7m.so.1.0 (0x00007f4b15a40000)
libboost_system.so.1.74.0 => /home/zhangwenting/anaconda3/envs/torch11/lib/libboost_system.so.1.74.0 (0x00007f4b15a3b000)
libboost_thread.so.1.74.0 => /home/zhangwenting/anaconda3/envs/torch11/lib/libboost_thread.so.1.74.0 (0x00007f4b15a19000)
libboost_filesystem.so.1.74.0 => /home/zhangwenting/anaconda3/envs/torch11/lib/libboost_filesystem.so.1.74.0 (0x00007f4b159f6000)
libglog.so.0 => /home/zhangwenting/anaconda3/envs/torch11/lib/libglog.so.0 (0x00007f4b159bd000)
libgflags.so.2.2 => /home/zhangwenting/anaconda3/envs/torch11/lib/libgflags.so.2.2 (0x00007f4b15998000)
libprotobuf.so.16 => /home/zhangwenting/software/protobuf-3.6.0/install/lib/libprotobuf.so.16 (0x00007f4b15505000)
libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f4b152b9000)
libhdf5.so.200 => /home/zhangwenting/anaconda3/envs/torch11/lib/libhdf5.so.200 (0x00007f4b14eb8000)
libhdf5_cpp.so.200 => /home/zhangwenting/anaconda3/envs/torch11/lib/libhdf5_cpp.so.200 (0x00007f4b14e40000)
libhdf5_hl.so.200 => /home/zhangwenting/anaconda3/envs/torch11/lib/libhdf5_hl.so.200 (0x00007f4b14e1b000)
libhdf5_hl_cpp.so.200 => /home/zhangwenting/anaconda3/envs/torch11/lib/libhdf5_hl_cpp.so.200 (0x00007f4b14e14000)
liblmdb.so => /home/zhangwenting/anaconda3/envs/torch11/lib/liblmdb.so (0x00007f4b14dfd000)
libleveldb.so.1 => /home/zhangwenting/anaconda3/envs/torch11/lib/libleveldb.so.1 (0x00007f4b14d9b000)
libcudart.so.11.0 => /usr/local/cuda/lib64/libcudart.so.11.0 (0x00007f4b14b15000)
libcurand.so.10 => /usr/local/cuda/lib64/libcurand.so.10 (0x00007f4b0fbe5000)
libcublas.so.11 => /usr/local/cuda/lib64/libcublas.so.11 (0x00007f4b077c9000)
libcudnn.so.5 => /home/share/cudnn-8.0-v5.1/lib64/libcudnn.so.5 (0x00007f4b029f4000)
libopencv_highgui.so.4.3 => /home/zhangwenting/zzapp/lib64/libopencv_highgui.so.4.3 (0x00007f4b027dc000)
libopencv_videoio.so.4.3 => /home/zhangwenting/zzapp/lib64/libopencv_videoio.so.4.3 (0x00007f4b02561000)
libopencv_imgcodecs.so.4.3 => /home/zhangwenting/zzapp/lib64/libopencv_imgcodecs.so.4.3 (0x00007f4b02050000)
libopencv_imgproc.so.4.3 => /home/zhangwenting/zzapp/lib64/libopencv_imgproc.so.4.3 (0x00007f4b002e4000)
libopencv_core.so.4.3 => /home/zhangwenting/zzapp/lib64/libopencv_core.so.4.3 (0x00007f4afede6000)
libopencv_cudev.so.4.3 => /home/zhangwenting/zzapp/lib64/libopencv_cudev.so.4.3 (0x00007f4afebe3000)
libopenblas.so.0 => /home/zhangwenting/anaconda3/envs/torch11/lib/libopenblas.so.0 (0x00007f4afce00000)
libboost_python37.so.1.74.0 => /home/zhangwenting/anaconda3/envs/torch11/lib/libboost_python37.so.1.74.0 (0x00007f4afcdc4000)
libstdc++.so.6 => /home/zhangwenting/anaconda3/envs/torch11/lib/libstdc++.so.6 (0x00007f4afcc4f000)
libm.so.6 => /lib64/libm.so.6 (0x00007f4afc94d000)
libgcc_s.so.1 => /home/zhangwenting/anaconda3/envs/torch11/lib/libgcc_s.so.1 (0x00007f4afc939000)
libc.so.6 => /lib64/libc.so.6 (0x00007f4afc575000)
libsnappy.so.1 => /home/zhangwenting/anaconda3/envs/torch11/lib/libsnappy.so.1 (0x00007f4afc56a000)
/lib64/ld-linux-x86-64.so.2 (0x00007f4b16976000)
Step 5 python接口

安装pycaffe

make pycaffe 1>pycaffe.log 2>pycaffe.error

日志

手动配置pycaffe

cd ~/software (caffe仓库所在路径)
➜  cp -r caffe/build/install pycaffe-release-1.0.0
146 files ( 14.5 MiB) copied in 0.1 seconds (199.9 MiB/s).
➜  tar -zcvf pycaffe-release-1.0.0.tar.gz pycaffe-release-1.0.0 # 备份下cd pycaffe-release-1.0.0
➜  ll
total 8.0K
drwxr-xr-x. 2 zhangwenting zhangwenting 4.0K Apr 22 15:28 bin # 可执行文件
drwxr-xr-x. 3 zhangwenting zhangwenting   26 Apr 22 15:28 include # C头文件
drwxr-xr-x. 2 zhangwenting zhangwenting   86 Apr 22 15:28 lib64 # C动态库
drwxr-xr-x. 3 zhangwenting zhangwenting 4.0K Apr 22 15:28 python # python接口
drwxr-xr-x. 3 zhangwenting zhangwenting   26 Apr 22 15:28 share
➜ cd python
➜ ll
total 32K
drwxr-xr-x. 5 zhangwenting zhangwenting 4.0K Apr 22 15:28 caffe
-rw-r--r--. 1 zhangwenting zhangwenting 4.2K Apr 22 15:28 classify.py
-rw-r--r--. 1 zhangwenting zhangwenting 5.6K Apr 22 15:28 detect.py
-rw-r--r--. 1 zhangwenting zhangwenting 2.3K Apr 22 15:28 draw_net.py
-rw-r--r--. 1 zhangwenting zhangwenting  261 Apr 22 15:28 requirements.txt # 其中 protobuf==3.6.0; python-dateutil>=2.6.0 
-rw-r--r--. 1 zhangwenting zhangwenting 3.1K Apr 22 15:28 train.py
➜ pip install -r requirements.txt

完整的python依赖:requirements.txt