http://caffe.berkeleyvision.org/installation.html
部分模块已安装过,这些模块只进行验证。
先安装一堆依赖:
sudo apt install libprotobuf-dev libleveldb-dev libsnappy-dev libopencv-dev libhdf5-serial-dev protobuf-compiler
sudo apt install --no-install-recommends libboost-all-dev
sudo apt install libgflags-dev libgoogle-glog-dev liblmdb-dev
sudo apt install libopenblas-dev (openblas和atlas的依赖库不同)
CUDA
查看cuda版本:
nvcc -V
详细例程见:https://docs.nvidia.com/cuda/archive/9.0/cuda-installation-guide-linux/index.html#compiling-examples
cuDNN
查看cuDNN版本:
cat /usr/include/x86_64-linux-gnu/cudnn_v*.h | grep CUDNN_MAJOR -A 2
详细例程见:https://docs.nvidia.com/deeplearning/sdk/cudnn-install/index.html#verify
OPENBLAS
源代码下载:https://github.com/xianyi/OpenBLAS
make
sudo make install
添加搜索路径:
export LD_LIBRARY_PATH=/opt/OpenBLAS/lib:$LD_LIBRARY_PATH
则在/opt/OpenBLAS可见。
例程:
//test_cblas_dgemm.c
#include <cblas.h>
#include <stdio.h>
void main()
{
int i=0;
double A[6] = {1.0,2.0,1.0,-3.0,4.0,-1.0};
double B[6] = {1.0,2.0,1.0,-3.0,4.0,-1.0};
double C[9] = {.5,.5,.5,.5,.5,.5,.5,.5,.5};
cblas_dgemm(CblasColMajor, CblasNoTrans, CblasTrans,3,3,2,1,A, 3, B, 3,2,C,3);
for(i=0; i<9; i++)
printf("%lf ", C[i]);
printf("\n");
}
编译:
gcc -o test_cblas_open test_cblas_dgemm.c -I /opt/OpenBLAS/include/ -L/opt/OpenBLAS/lib -lopenblas -lpthread -lgfortran
如果没有安装gfortran,还要单独安装:
sudo apt install gfortran
执行:
./test_cblas_open
11.000000 -9.000000 5.000000 -9.000000 21.000000 -1.000000 5.000000 -1.000000 3.000000
Boost
从 https://www.boost.org/users/history/version_1_67_0.html 下载源代码并解压
切换到解压文件夹下,
./bootstrap.sh
sudo ./b2 install
添加搜索路径
export LD_LIBRARY_PATH=/usr/local/lib:${LD_LIBRARY_PATH}
例程:
//example.cpp
#include <boost/regex.hpp>
#include <iostream>
#include <string>
int main()
{
std::string line;
boost::regex pat( "^Subject: (Re: |Aw: )*(.*)" );
while (std::cin)
{
std::getline(std::cin, line);
boost::smatch matches;
if (boost::regex_match(line, matches, pat))
std::cout << matches[2] << std::endl;
}
}
jayne.txt :
To: George Shmidlap
From: Rita Marlowe
Subject: Will Success Spoil Rock Hunter?
---
See subject.
c++ -I /usr/local example.cpp -o example /usr/local/lib/libboost_regex.a
./example < ./jayne.txt
Will Success Spoil Rock Hunter?
OpenCV
我之前安装了opencv-python-3.4.3,在没有卸载的情况下安装,也通过了测试…但是因为后期caffe因为别的原因没有make通过,我第二次安装的时候就卸载了opencv-python。有些博客提到旧的版本会和cuda8.0有不兼容的情况发生,我的cuda9.0和opencv-3.4.3编译一次通过。
https://docs.opencv.org/3.4/d7/d9f/tutorial_linux_install.html
安装cmake
sudo apt install cmake
安装一堆依赖:
sudo apt install build-essential
sudo apt install git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev
sudo apt install python3-dev python3-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev
切到源代码文件夹下,新建临时文件夹:
mkdir build
cd build
cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local ..
make -j12
sudo make install
安装文档doxygen
http://www.stack.nl/~dimitri/doxygen/download.html
sudo apt install flex
sudo apt install bison
git clone https://github.com/doxygen/doxygen.git
cd doxygen
mkdir build
cd build
cmake -G "Unix Makefiles" ..
make
make install
在这里我cmake opencv的时候没有配置python路径,但是最后在python里面也能import。不知道是什么原因。
测试:
cd ~
git clone https://github.com/opencv/opencv_extra.git
export OPENCV_TEST_DATA_PATH=~/opencv_extra/testdata
切换到前面的build文件夹下运行测试文件:
./bin/opencv_test_core
测试结果有一个未通过:
[----------] Global test environment tear-down
[==========] 10522 tests from 208 test cases ran. (478989 ms total)
[ PASSED ] 10521 tests.
[ FAILED ] 1 test, listed below:
[ FAILED ] Core_globbing.accuracy
不要紧的 http://answers.opencv.org/question/23356/opencv-300-dev-core_globbing-failure/
CAFFE
http://caffe.berkeleyvision.org/installation.html#compilation
修改配置文件的时候一定要仔细仔细仔细!!!
cp Makefile.config.example Makefile.config
# Adjust Makefile.config (for example, if using Anaconda Python, or if cuDNN is desired)
make all
make test
make runtest
编译过程中会有报错找不到hdf5.h,处理方案见:https://blog.csdn.net/xue_wenyuan/article/details/52037121
链接过程找不到-lhdf5的处理方案见:
https://github.com/BVLC/caffe/issues/4333
编译通过的config文件另开一篇放出见:https://blog.csdn.net/tfcy694/article/details/83834188