由于系统从Ubuntu 14.04升级到了16.04,原来的CUDA 6.5无法继续使用,所以重新安装了CUDA 8.0。
以下操作都在命令行界面操作,比如按下Ctrl+alt+F1进入命令行
首先停止lightdm:
sudo service lightdm stop
卸载NVIDIA驱动
原来安装CUDA 6.5的时候一起安装了 NVIDIA驱动,首先卸载掉,命令一般是:
sudo /usr/bin/nvidia-uninstall
如果找不到命令,可以在命令行下直接输入:
sudo apt-get install autoremove --purge nvidia*
卸载CUDA toolkit
CUDA默认安装在 /usr/local/cuda-6.5下,用下面的命令卸载:
sudo /usr/local/cuda-6.5/bin/uninstall_cuda-6.5.pl
此时一般需要重启一下
首先下载CUDA安装文件,网址:https://developer.nvidia.com/cuda-release-candidate-download
需要注册NVIDIA的开发者账号。根据电脑的系统下载对应的安装文件,这里下载的是CUDA 8.0的runfile(local)文件。安装方法可以按照官方安装指南:http://docs.nvidia.com/cuda/cuda-installation-guide-linux/#axzz4HIBXnwyt
依旧进入命令行界面,然后还是
sudo service lightdm stop
执行下面语句,运行runfile文件:
sudo sh cuda_8.0.44_linux.run
会有一系列的安装选项,比如是否安装NVIDIA367驱动等,由于之前卸载了NVIDAI驱动,所以这里选择了安装,其他还有比如是否安装samples以及安装目录等。
安装完成后会出现以下界面:
============ Summary ============Driver: Not SelectedToolkit: Installed in /usr/local/cuda-8.0Samples: Installed in /home/textminerPlease make sure that– PATH includes /usr/local/cuda-8.0/bin– LD_LIBRARY_PATH includes /usr/local/cuda-8.0/lib64, or, add /usr/local/cuda-8.0/lib64 to /etc/ld.so.conf and run ldconfig as rootTo uninstall the CUDA Toolkit, run the uninstall script in /usr/local/cuda-8.0/binPlease see CUDA_Installation_Guide_Linux.pdf in /usr/local/cuda-8.0/doc/pdf for detailed information on setting up CUDA.***WARNING: Incomplete installation! This installation did not install the CUDA Driver. A driver of version at least 361.00 is required for CUDA 8.0 functionality to work.To install the driver using this installer, run the following command, replacing with the name of this run file:sudo .run -silent -driverLogfile is /opt/temp//cuda_install_6583.log
然后设置环境变量和动态链接库,在/etc/profile文件中添加:
export PATH = /usr/local/cuda-8.0/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/cuda-8.0/lib64:$LD_LIBRARY_PATH
之后再
source /etc/profile
可以使改变立即生效
测试
如果安装了CDUA samples可以运行一下以测试CUDA是否能成功运行。
进入sample的目录,CUDA 8.0的默认安装目录变成了用户主目录,会有一个NVIDA_CUDA-8.0_Samples的目录,里面有Makefile文件,直接make就行,一般需要编译一段比较长的时间。之后就可以在当前目录的bin目录中随意运行一些程序,以验证CUDA是否正确安装,比如deviceQuery程序的运行结果:
./deviceQuery Starting...
CUDA Device Query (Runtime API) version (CUDART static linking)
Detected 1 CUDA Capable device(s)
Device 0: "GeForce GTX 980 Ti"
CUDA Driver Version / Runtime Version 8.0 / 8.0
CUDA Capability Major/Minor version number: 5.0
Total amount of global memory: 1999 MBytes (2095841280 bytes)
( 5) Multiprocessors, (128) CUDA Cores/MP: 640 CUDA Cores
GPU Max Clock rate: 1084 MHz (1.08 GHz)
Memory Clock rate: 2700 Mhz
Memory Bus Width: 128-bit
L2 Cache Size: 2097152 bytes
Maximum Texture Dimension Size (x,y,z) 1D=(65536), 2D=(65536, 65536), 3D=(4096, 4096, 4096)
Maximum Layered 1D Texture Size, (num) layers 1D=(16384), 2048 layers
Maximum Layered 2D Texture Size, (num) layers 2D=(16384, 16384), 2048 layers
Total amount of constant memory: 65536 bytes
Total amount of shared memory per block: 49152 bytes
Total number of registers available per block: 65536
Warp size: 32
Maximum number of threads per multiprocessor: 2048
Maximum number of threads per block: 1024
Max dimension size of a thread block (x,y,z): (1024, 1024, 64)
Max dimension size of a grid size (x,y,z): (2147483647, 65535, 65535)
Maximum memory pitch: 2147483647 bytes
Texture alignment: 512 bytes
Concurrent copy and kernel execution: Yes with 1 copy engine(s)
Run time limit on kernels: Yes
Integrated GPU sharing Host Memory: No
Support host page-locked memory mapping: Yes
Alignment requirement for Surfaces: Yes
Device has ECC support: Disabled
Device supports Unified Addressing (UVA): Yes
Device PCI Domain ID / Bus ID / location ID: 0 / 1 / 0
Compute Mode:
< Default (multiple host threads can use ::cudaSetDevice() with device simultaneously) >
deviceQuery, CUDA Driver = CUDART, CUDA Driver Version = 8.0, CUDA Runtime Version = 8.0, NumDevs = 1, Device0 = GeForce GTX 750 Ti
Result = PASS
参考
http://www.th7.cn/system/lin/201608/176823.shtml
blog.csdn.net/xulingqiang/article/details/46660107