Nvidia CUDA 6 Installed In Ubuntu 12.04

环境:ubuntu 12.04 (x64)

如果不能够 service lightdm stop,显示:unknown service 或者其他的 

sudo /etc/init.d/lightdm restart

cuda 6.0

1)Verify You Have a CUDA-Capable GPU

To verify that your GPU is CUDA-capable, go to your distribution’s equivalent of SystemProperties, or, from the command line, enter:

1
lspci | grep -i nvidia


2) Verify the System Has gcc Installed

1
gcc --version

一般系统安装完毕后便自带C编译环境和Python编译环境

3)安装必要的库

If you wish to build allof the samples, including those with graphical rather than
command-line interfaces, you may need to install additional system libraries or
headers if you have not done so before.

1
2
sudo apt-get install freeglut3-dev build-essential libx11-dev libxmu-dev
libxi-dev libgl1-mesa-glx libglu1-mesa libglu1-mesa-dev


注:
安装libgl1-mesa-* library时可能会提示你缺少依赖包,请谨记安装提示信息中Recommended依赖包,否则,呵呵呵…

4)卸载(禁止)存在的NVIDIA(nouveau)驱动

一般Ubuntu系统安装完毕后,会弹出Additional Driver警示框,提醒安装驱动,为了避免兼容性问题,如果已经安装的请卸载PS:The CUDA 5.5 installers include the CUDA Toolkit, SDK code samples, Nsight Visual Studio edition (for Windows) and Nsight Eclipse Edition (for Linux / Mac OS X), and developer drivers.

1
sudo nvidia-uninstall

如果卸载失败,或者卸载完成后,建议这样做一下

1
sudo apt-get remove --purge nvidia*

禁止开源驱动nouveau的开机加载

1
sudo gedit /etc/modprobe.d/blacklist.conf

在文件后添加如下内容保存后重启

1
2
blacklist nouveau
options nouveau modeset=0


5)Installation

Exit the GUI if you are in a GUI environment by pressing Ctrl-Alt-F1 and login as root, then type into the commond below and press Enter

1
service lightdm stop

Install the CUDA Toolkit (xx in 5.5.xx is the minor version of the installation package)by running the downloaded .runfile as a superuser.

1
sudo sh cuda_5.5.xx_linux_32_rhel5.x.run

这个初始化时间有点长,耐心等待…

安装完成后切换回GUI界面

1
service lightdm start




6)Define the environment variables

我习惯用如下方式进行环境变量的添加修改:

首先

1
gedit ~/.bashrc

添加如下内容

1
2
export PATH=/usr/local/cuda-6.0/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/cuda-6.0/lib64:$LD_LIBRARY_PATH

然后

1
gedit /etc/ld.so.conf

添加如下内容

1
/usr/local/cuda-6.0/lib64

完成之后执行如下命令

1
sudo ldconfig

验证是否添加路径成功

1
ldconfig -v|grep cuda

以上内容其实在你安装完毕CUDA Toolkit之后的信息中都有所提示!文章最后会给出安装完毕后的截图!

7)关于Bug:

执行 nvidia.settings 出现错误提示框 no driver detected 以及 nvidia driver is activated but not currently in use

不知道怎么解决,郁闷中…反正console project都能运行,只是进入Ubuntu系统时因为驱动未安装好的缘故会花屏而已,另外建议运行一下Samples中的1_Utilities中的deviceQuery程序作为测试!

原文地址:https://www.cnblogs.com/assassin/p/3689974.html