安装相应依赖
apt-get install libprotobuf-dev libleveldb-dev libsnappy-dev libopencv-dev libhdf5-serial-dev protobuf-compiler
apt-get install --no-install-recommends libboost-all-dev
apt-get install python-dev
apt-get install libgflags-dev libgoogle-glog-dev liblmdb-dev
apt-get install libatlas-base-dev
apt-get install the python-matplotlib python-scipy python-numpy
pip3 install pytest numpy boost
安装CMAKE
注意:使用apt-get安装的cmake版本太低,在使用CUDA10.2的环境下进行caffe编译时会出现CUDA_cublas_device_LIBRARY/CUDA_cublas_LIBRA报错。这是由于低版本cmake找不到cuda的库所导致。为解决这个问题,我们需要手动安装cmake,版本要求至少为3.12.0。我们选择3.14.3。
如果已经存在cmake请确认版本 cmake --version
- 从cmake官网下载cmake-3.14.3-Linux-x86_64.tar.gz
- 解压 tar -zxvf cmake-3.14.3-Linux-x86_64.tar.gz
- 在~/.bashrc文件中添加环境变量,在文件末尾添加:
export CMAKE_ROOT=/home/shiyh/download/cmake-3.14.3-Linux-x86_64
export PATH=$PATH:$CMAKE_ROOT/bin:
注意/home/shiyh/download/请替换为具体路径 - 保存,并执行source ~/.bashrc
cmake编译
- 修改Makefile.config
源码文件夹中已提供Makefile.config.example
执行cp Makefile.config.example Makefile.config - 修改CMakeList.txt中第35行
第35行的set(python_version “2” CACHE STRING “Specify which Python version to use”)中的2改为3.6(根据自己的python版本确定),保存退出 - vim Makefile.config 对配置文件中相关参数修改
## Refer to http://caffe.berkeleyvision.org/installation.html # Contributions simplifying and improving our build system are welcome! # cuDNN acceleration switch (uncom