歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
您现在的位置: Linux教程網 >> UnixLinux >  >> Linux基礎 >> Linux技術

ubuntu14.04 Nvidia 驅動和cuda安裝(轉)

1. 安裝build-essentials

安裝開發所需要的一些基本包
sudo apt-get install build-essential

2. 安裝NVIDIA驅動

2.1 准備工作

在關閉桌面管理 lightdm 的情況下安裝驅動似乎可以實現Intel 核芯顯卡 來顯示 + NVIDIA 顯卡來計算。

具體步驟如下:

1. 進入Ubuntu, 按 ctrl+alt+F1 進入tty, 登錄tty後輸入如下命令

sudo service lightdm stop
該命令會關閉lightdm。如果你使用 gdm或者其他的desktop manager 請在安裝NVIDIA驅動前關閉他。

2. 屏蔽cpu集顯

sudo vim /etc/modprobe.d/blacklist.conf

添加以下內容:

vga16fb

nouveau

rivafb

nvidiafb

rivatv

2.2 安裝驅動

下載與計算機顯卡匹配的驅動源<文件名>.runsudo sh ./<文件>.run

3. 安裝CUDA 6.5

下載CUDA 6.5. 然後通過下列命令, 將下載得到的.run文件解壓成三個文件, 分別為

CUDA安裝包: cuda-linux64-rel-6.5.14-18749181.run

NVIDIA驅動: NVIDIA-Linux-x86_64-340.29.run

SAMPLE包: cuda-samples-linux-6.5.14-18745345.run

這裡不安裝NVIDIA驅動

cuda6.5.run --extract=extract_path
注意, 需要通過下面命令給所有.run文件可執行權限

chmod +x *.run

3.1 安裝CUDA

通過下列命令安裝CUDA, 按照說明一步一步安裝至完成.

sudo ./cuda-linux64-rel-6.5.14-18749181.run
3.1.1 添加環境變量

安裝完成後需要在/etc/profile中添加環境變量, 在文件最後添加:

PATH=/usr/local/cuda-6.5/bin:$PATH
export PATH
保存後, 執行下列命令, 使環境變量立即生效

source /etc/profile
3.1.2 添加lib庫路徑

/etc/ld.so.conf.d/加入文件 cuda.conf, 內容如下

/usr/local/cuda-6.5/lib64
執行下列命令使之立刻生效

sudo ldconfig

3.2 安裝CUDA SAMPLE

首先安裝下列依賴包

sudo apt-get install freeglut3-dev build-essential libx11-dev libxmu-dev libxi-dev libglu1-mesa-dev
然後用下述命令安裝sample文件

sudo ./cuda-samples-linux-6.5.14-18745345.run
完成後編譯Sample文件, 整個過程大概10分鐘左右

cd /usr/local/cuda-6.5/samples
sudo make
全部編譯完成後, 進入 samples/bin/x86_64/linux/release, sudo下運行deviceQuery

sudo ./deviceQuery
如果出現下列顯卡信息, 則驅動及顯卡安裝成功:

./deviceQuery Starting...

 CUDA Device Query (Runtime API) version (CUDART static linking)

Detected 1 CUDA Capable device(s)

Device 0: "GeForce GTX 670"
  CUDA Driver Version / Runtime Version          6.5 / 6.5
  CUDA Capability Major/Minor version number:    3.0
  Total amount of global memory:                 4095 MBytes (4294246400 bytes)
  ( 7) Multiprocessors, (192) CUDA Cores/MP:     1344 CUDA Cores
  GPU Clock rate:                                1098 MHz (1.10 GHz)
  Memory Clock rate:                             3105 Mhz
  Memory Bus Width:                              256-bit
  L2 Cache Size:                                 524288 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 Bus ID / PCI location ID:           1 / 0
  Compute Mode:
     < Default (multiple host threads can use ::cudaSetDevice() with device simultaneously) >

deviceQuery, CUDA Driver = CUDART, CUDA Driver Version = 6.5, CUDA Runtime Version = 6.5, NumDevs = 1, Device0 = GeForce GTX 670
Result = PASS

Copyright © Linux教程網 All Rights Reserved