您的位置:首页 > 运维架构 > Linux

Linux Ubuntu下面安装CUDA3.1攻略

2010-08-06 10:41 381 查看
******Install CUDA3.1 on ubuntu 10.04********

                Made by Talor(thuhhx@gmail.com)  2010-7-6

[0]Operation: ubuntu 10.04

   CUDA 3.1

[1]Software: SDK     gpucomputingsdk_3.1_linux.run

             Toolkit cudatoolkit_3.1_linux_32_ubuntu9.10.run

             Driver  devdriver_3.1_linux_32_256.35.run

   Address:  http://developer.nvidia.com/object/cuda_3_1_downloads.html
[2]check hardware

   [a]verify NVIDIA GPU exists

     @ubuntu:~$ lspci | grep VGA[enter]

     01:00.0 VGA compatible controller: nVidia Corporation G92 [GeForce GTS 250] (rev a2)

     04:01.0 VGA compatible controller: nVidia Corporation NV34 [GeForce FX 5500] (rev a1)

  

   [b]verify CPU supports CUDA3.1(CPU must be X86 architecture)

     @ubuntu:~$ uname -m[enter]

     i686

[3]setup

  [a]Install cuda driver

      切换到控制台:    ctrl+Alt+Fn(n不等于7)

      关掉gdm:        @ubuntu:~$ sudo /etc/init.d/gdm stop

   

      卸载原来的驱动 :    @ubuntu:~$ sudo nvidia-installer --uninstall   

      安装driver:        @ubuntu:~$ sudo sh devdriver_3.1_linux_32_256.35.run

      重启gdm:        @ubuntu:~$ sudo /etc/init.d/gdm restart

  [b]Install Toolkit

      install the toolkit:    @ubuntu:~$ sudo sh cudatoolkit_3.1_linux_32_ubuntu9.10.run

      安装程序会提示输入安装路径,推荐使用root身份安装 并 接受默认路径 (/usr/local)

      <CUDA_INSTALL_PATH>表示Toolkit安装的路径

  [c]Install CUDA SDK

      install the SDK:    @ubuntu:~$ sh gpucomputingsdk_3.1_linux.run

      安装程序会提示输入安装路径,推荐使用普通身份安装 并 接受默认路径 (~/NVIDIA_CUDA_SDK)

      <SDK_INSTALL_PATH>表示SDK安装的路径   

  [d]compile environment

      [a]

      要安装如下的库:apt-get install freeglut3-dev libXi-dev and libXmu-dev 或者 libglut3-dev

      cuda 2.3使用 g++ 4.3编译;

 

    @ubuntu:~$ sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.4 44  --slave /usr/bin/g++ g++ /usr/bin/g++-4.4 --slave /usr/bin/gcov gcov /usr/bin/gcov-4.4

   

    @ubuntu:~$ sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.3 43 --slave /usr/bin/g++ g++ /usr/bin/g++-4.3 --slave /usr/bin/gcov gcov /usr/bin/gcov-4.3

 

    @ubuntu:~$ sudo update-alternatives --display gcc

 

    @ubuntu:~$ sudo update-alternatives --config gcc 

     [b]环境变量的设置:

    export PATH=/usr/local/cuda/bin:$PATH

    export LD_LIBRARY_PATH=/usr/local/cuda/lib:$LD_LIBRARY_PATH

    把以上两条命令写到~/.bashrc中。

    注:ubuntu中环境变量写在.bashrc或.profile文件中。

     [c] Modifying ld.so.conf: (this file located in the /etc derectory)

     把     <CUDA_INSTALL_PATH>/cuda/lib    (32bit)

         或者     <CUDA_INSTALL_PATH>/cuda/lib64  (64bit)

     写入ld.so.conf文件中 .

[4]bulid the SDK

       

    @ubuntu:~$ cd [to your NVIDIA_GPU_Computing_SDK/C]

    @ubuntu:~$ make

        -release :     input "make"

    -debug   :     input "make dbg=1"

    -emurelease:    input "make emu=1"

    -emudebug:    input "make emu=1 dbg=1"

        or

       @ubuntu:~$ cd [to your NVIDIA_GPU_Computing_SDK/C]/src/[project name]

           @ubuntu:~$ make

[5]execute example project

    @ubuntu:~$ cd [to your NVIDIA_GPU_Computing_SDK/C]/src/deviceQuery

    @ubuntu:~$ make

    @ubuntu:~$ cd [to your NVIDIA_GPU_Computing_SDK/C]/bin/linux/release

    @ubuntu:~$ ./deviceQuery

---------------result-----------------

./deviceQuery Starting...

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

There is 1 device supporting CUDA

Device 0: "GeForce GTS 250"

  CUDA Driver Version:                           3.10

  CUDA Runtime Version:                          3.10

  CUDA Capability Major revision number:         1

  CUDA Capability Minor revision number:         1

  Total amount of global memory:                 536674304 bytes

  Number of multiprocessors:                     16

  Number of cores:                               128

  Total amount of constant memory:               65536 bytes

  Total amount of shared memory per block:       16384 bytes

  Total number of registers available per block: 8192

  Warp size:                                     32

  Maximum number of threads per block:           512

  Maximum sizes of each dimension of a block:    512 x 512 x 64

  Maximum sizes of each dimension of a grid:     65535 x 65535 x 1

  Maximum memory pitch:                          2147483647 bytes

  Texture alignment:                             256 bytes

  Clock rate:                                    1.62 GHz

  Concurrent copy and execution:                 Yes

  Run time limit on kernels:                     No

  Integrated:                                    No

  Support host page-locked memory mapping:       No

  Compute mode:                                  Default (multiple host threads can use this device simultaneously)

  Concurrent kernel execution:                   No

  Device has ECC support enabled:                No

deviceQuery, CUDA Driver = CUDART, CUDA Driver Version = 3.10, CUDA Runtime Version = 3.10, NumDevs = 1, Device = GeForce GTS 250

PASSED

Press <Enter> to Quit...

-----------------------------deviceQuery end----------------------------------

    @ubuntu:~$ cd [to your NVIDIA_GPU_Computing_SDK/C]/src/bandwidthTest

    @ubuntu:~$ make

    @ubuntu:~$ cd [to your NVIDIA_GPU_Computing_SDK/C]/bin/linux/release

    @ubuntu:~$ ./bandwidthTest

----------------reslut--------------------------------

[bandwidthTest]

./bandwidthTest Starting...

Running on...

 Device 0: GeForce GTS 250

 Quick Mode

 Host to Device Bandwidth, 1 Device(s), Paged memory

   Transfer Size (Bytes)    Bandwidth(MB/s)

   33554432            1470.6

 Device to Host Bandwidth, 1 Device(s), Paged memory

   Transfer Size (Bytes)    Bandwidth(MB/s)

   33554432            1308.4

 Device to Device Bandwidth, 1 Device(s)

   Transfer Size (Bytes)    Bandwidth(MB/s)

   33554432            51895.2

[bandwidthTest] - Test results:

PASSED

Press <Enter> to Quit...

-----------------------------------------------------------
8a33

OVER! good luck !

   

[参考信息]

[01]http://www.docin.com/p-44550472.html (CUDA在linux系统上安装指南)

[02]http://www.devbaldwin.com/blog/2010/03/15/setting-up-cuda-on-ubuntu-9-10/

[03]http://www.linuxidc.com/Linux/2010-02/24329p3.htm (Ubuntu下CUDA安装)

[04]http://forums.nvidia.com/index.php?showtopic=167422
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息