这里最坑爹的一点是LIBRARY_PATH这个环境变量配置,官方的文档上一点没提,如果不写的话,在编译cuda的samples时,会在3_Imaging这个samples下报这个错误
1 2 3 /usr/bin/ld: cannot find -lnvcuvid collect2: error: ld returned 1 exit status Makefile:346: recipe for target 'cudaDecodeGL' failed因为Ubuntu 16.10自带的gcc编译器版本是6.2,对于CUDA来说太新了,所以会报错
1 error -- unsupported GNU version! gcc versions later than 5 are not supported!可以看到CUDA 8.0 能够支持的gcc最新版本不能超过5。网上给出的比较好的解决办法是利用Ubutnu的update-alternatives 命令来切换版本,具体命令如下:
1 2 3 4 sudo apt-get install gcc-4.9 g++-4.9 sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.9 40 --slave /usr/bin/g++ g++ /usr/bin/g++-4.9 sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-6 30 --slave /usr/bin/g++ g++ /usr/bin/g++-6 sudo update-alternatives --config gcc敲完sudo update-alternatives --config gcc之后,你就可以看到不同版本的gcc优先级了。
备注:安装过程中一定要看CUDA的官方说明文档!!!!安装哪个版本就看哪个版本对应的安装文档!!!!!!!