安装各种依赖包
sudo apt
-get update
sudo apt
-get install build
-essential cmake git pkg
-config
sudo apt
-get install libprotobuf
-dev libleveldb
-dev libsnappy
-dev libhdf5
-serial-dev protobuf
-compiler
sudo apt
-get install libatlas
-base-dev
sudo apt
-get install libboost
-all-dev
sudo apt
-get install libgflags
-dev libgoogle
-glog-dev liblmdb
-dev
sudo apt
-get install python
-pip
sudo apt
-get install libopencv-dev
sudo apt
-get install python
-devsudo apt
-get install python
-numpy python
-scipysudo apt
-get install libopenblas
-dev liblapack
-dev libatlas
-base-dev安装caffe
git clone https://github
.com/BVLC/caffe
.git //
从
github
上
git caffe
修改
Makefile.conf配置文件
如下图所示:
修改为:
INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include /usr/include/hdf5/serial
LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib /usr/lib/aarch64-linux-gnu /usr/lib/aarch64-linux-gnu/hdf5/serial
将
CUDA_ARCH := -gencode arch=compute_20,code=sm_20 \
-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
中的
-gencode arch=compute_20,code=sm_20 \
-gencode arch=compute_20,code=sm_21 \
-gencode arch=compute_30,code=sm_30 \
-gencode arch=compute_35,code=sm_35 \
删除,如果不删除,对caffe进行编译时会报错。报错如下图:
修改Makefile文件
将Makefile文件中的
NVCCFLAGS += -ccbin=$(CXX) -Xcompiler -fPIC $(COMMON_FLAGS)
替换为
NVCCFLAGS +=-D_FORCE_INLINES-ccbin=$(CXX) -Xcompiler-fPIC $(COMMON_FLAGS)
将LIBRARIES+= glog gflags protobuf boost_system boost_filesystem m hdf5_hl hdf5
修改为:
LIBRARIES += glog gflags protobuf boost_system boost_filesystem boost_regex m hdf5_hl hdf5
修改host_config.h文件
#error -- unsupported GNU version! gcc versions later than 7 are not supported!
改为
//#error -- unsupported GNU version! gcc versions later than 7 are not supported!
设置环境变量
export PYTHONPATH=/home/nvidia/caffe/python:$PYTHONPATH
export PATH=$PATH:/usr/local/cuda-10.0/bin
export PATH=/usr/local/cuda-10.0/bin:$PATH
进入caffe目录进行编译