已经安装了NVIDIA418.56+CUDA10.0+CUDNN7.5.1+OPENCV3.4.0(版本匹配很重要)
git clone https://github.com/BVLC/caffe.git
git clone git://github.com/BVLC/caffe.git
第一个不行用第二个
cd caffe
sudo cp Makefile.config.example Makefile.config
sudo gedit Makefile.config
修改 Makefile.config 文件内容:
1.应用 cudnn
将
#USE_CUDNN := 1
修改成:
USE_CUDNN := 1
2.应用 opencv 版本
将
#OPENCV_VERSION := 3
修改为:
OPENCV_VERSION := 3
3.使用 python 接口
将
#WITH_PYTHON_LAYER := 1
修改为
WITH_PYTHON_LAYER := 1
4.修改 python 路径
INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include
LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib
修改为:
INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include /usr/include/hdf5/serial
LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib /usr/lib/x86_64-linux-gnu /usr/lib/x86_64-linux-gnu/hdf5/serial
修改Makefile:
sudo gedit 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
改为:
LIBRARIES += glog gflags protobuf boost_system boost_filesystem m hdf5_serial_hl hdf5_serial
开始编译:
sudo make all -j16
报错:
Makefile:605: recipe for target ‘.build_release/cuda/src/caffe/solvers/sgd_solver.o’ failed
解决
编译通过后,测试
sudo make runtest -j16
报错啦
解决方法:
error while loading shared libraries: libcudart.so.10.0: cannot open shared object file
通过了,爽!!!!
至此,深度学习框架搭完了。