C接口:
安装caffe所需库,按照官方要求安装。
将Makefile.config.example复制为Makefile.config,打开修改一些配置。
# USE_CUDNN := 1 GPU版,使用cudnn库则放开;
#CPU_ONLY := 1 CPU版要放开,GPU版不需要;
CUSTOM_CXX := g++;
CUDA_DIR := /usr/local/cuda GPU版;
CUDA_ARCH := -gencode arch=compute_20,code=sm_21 \
-gencode arch=compute_30,code=sm_30 \
-gencode arch=compute_35,code=sm_35 \
-gencode arch=compute_50,code=sm_50 \
-gencode arch=compute_52,code=sm_52 \
-gencode arch=compute_60,code=sm_60 \
-gencode arch=compute_61,code=sm_61 \
-gencode arch=compute_61,code=compute_61 不同型号、计算能力的GPU要求不一样,根据提示删减一些;
# open for OpenBlasBLAS := open
# Custom (MKL/ATLAS/OpenBLAS) include and lib directories.
# Leave commented to accept the defaults for your choice of BLAS
# (which should work)!
BLAS_INCLUDE := /home/liushu/env/OpenBLAS/include
BLAS_LIB := /home/liushu/env/OpenBLAS/lib 选择不同的库及对应路径
make clean;make -j
Python 接口:
make clean;make -j
make pycaffe
其中make pycaffe的时候会提示缺少一些Python相关库,按提示安装即可。
其中,make pycaffe的时候提示Python2.7库问题(/usr/bin/ld: cannot find -lpython2.7),如下,其实/usr/ 下已经安装了Python,
后来去Makefile.config里修改,放开了这段,就可以了,而之前在别的机器上编译的时候不需要这样。