1. 程式人生 > >Ubuntu 16.04解除安裝CUDA 6.5和安裝CUDA 8.0

Ubuntu 16.04解除安裝CUDA 6.5和安裝CUDA 8.0

一,引言

由於系統從Ubuntu 14.04升級到了16.04,原來的CUDA 6.5無法繼續使用,所以重新安裝了CUDA 8.0。

二,解除安裝CUDA 6.5 和驅動

以下操作都在命令列介面操作,比如按下Ctrl+alt+F1進入命令列 
首先停止lightdm: 
sudo service lightdm stop

解除安裝NVIDIA驅動

原來安裝CUDA 6.5的時候一起安裝了 NVIDIA驅動,首先解除安裝掉,命令一般是:

sudo /usr/bin/nvidia-uninstall
  • 1

如果找不到命令,可以在命令列下直接輸入:

sudo apt-get install autoremove --purge nvidia*
  • 1

解除安裝CUDA toolkit

CUDA預設安裝在 /usr/local/cuda-6.5下,用下面的命令解除安裝:

sudo /usr/local/cuda-6.5/bin/uninstall_cuda-6.5.pl
  • 1

此時一般需要重啟一下

三, 安裝CUDA 8.0

首先下載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
  • 1

執行下面語句,執行runfile檔案:

sudo sh cuda_8.0.44_linux.run
  • 1

會有一系列的安裝選項,比如是否安裝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
  • 1
  • 2

之後再

source /etc/profile
  • 1

可以使改變立即生效

測試 
如果安裝了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