1 gcc版本过高
安装cuda
sudo apt-get install nvidia-cuda-toolkit
cuda是7.5.18版,安装完后重启,在终端输入nivdia-smi,有结果则驱动和cuda安装成功。
但是cuda只支持gcc5.0以下,即使后续用cmake编译opencv成功,gpu还是无法调用
需要强制取消cuda的gcc版本检查
注释掉host_config.h中关于gcc版本的检查,版本大于5则返回错误
//
//
//
通过nvidia-cuda-toolkit安装的,host_config.h在 /usr/include/下,如果通过cuda的run文件安装,也会因为gcc版本检查提示错误,也要修改对应位置的host_config.h
2 usr/local/下没有cuda文件夹
ln -sf /usr/lib/nvidia-cuda-toolkit /usr/local/cuda
3 Error when Building GPU docker image for caffe: Unsupported gpu architecture 'compute_60'
In the Makefile.example, try commenting out the *_60 and *_61 lines (for compatibility with CUDA < 8.0).
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
vim the Makefile and changing the line
NVCCFLAGS += -ccbin=$(CXX) -Xcompiler -fPIC $(COMMON_FLAGS)
into
NVCCFLAGS += -D_FORCE_INLINES -ccbin=$(CXX) -Xcompiler -fPIC $(COMMON_FLAGS)
For me this was on line 415