Home > Database > Mysql Tutorial > ubuntu14.04+cuda6.5+opencv2.4.9+cuda

ubuntu14.04+cuda6.5+opencv2.4.9+cuda

WBOY
Release: 2016-06-07 15:24:48
Original
1657 people have browsed it

第一次这么正式的写技术博客,一是锻炼下写总结的能力,二来也算是由于自己看技术贴多却从来没有贡献过自己的感到羞愧. 1.准备 一.首先,运行环境为ubuntu14.04 ,因此本文都假设大家已经装好了ubuntu14.04,另外,cuda时nvidia公司为自己的gpu设计的编程架构,因此

第一次这么正式的写技术博客,一是锻炼下写总结的能力,二来也算是由于自己看技术贴多却从来没有贡献过自己的感到羞愧.

1.准备

一.首先,运行环境为ubuntu14.04,因此本文都假设大家已经装好了ubuntu14.04,另外,cuda时nvidia公司为自己的gpu设计的编程架构,因此要使用cuda首先要保证自己的电脑具有nvidia的显卡特别时要有cuda支持的显卡.关于自己的显卡怎么看:

~$ lspci|grep VGA

我的显卡是NVIDIA GT540M系列得到的结果为:

01:00.0 VGA compatible controller: NVIDIA Corporation GF108M [GeForce GT 540M] (rev a1)

这一点看起来时小问题,我一个哥们当时就是没有注意到这个问题结果呼次呼吃装了半天发现压根装不了,最后才发现自己的电脑的显卡时AMD公司的

二.确定了了自己的电脑时NVIDIA的显卡就可以进行下面的工作了.

1.先到NVIDIA官网上下载最新版的cuda-6.5,由于现在新版的cuda已经将cuda-toolkit和cudaSDK整合到一起了,所以只需要下载一个就行了

下面是我下载时的下载链接:

http://developer.download.nvidia.com/compute/cuda/6_5/rel/installers/cuda_6.5.14_linux_64.run

2.然后当然还要下载nvidia的显卡驱动,不过我比较不清楚的是为何还要再装一遍驱动,而且装的时候时先要将原来的驱动先卸载,完全清除了再安装新的驱动,可能时我想多了,linux本身没有nvidia的显卡驱动,但为什么又要再卸载后再安装,反正很矛盾.

下面时nvidia_3.40的显卡驱动链接,我是再一篇帖子上看到cuda6.5好像能支持到的驱动就直到3.40,所以不要下太高的版本

http://cn.download.nvidia.com/XFree86/Linux-x86_64/340.24/NVIDIA-Linux-x86_64-340.24.run

准备工作做好了,需要先安装显卡驱动,然后再安装cuda:

2.安装显卡驱动,下面是我看到的比较简单的方法:

1.下载显卡驱动,这步已经再准备工作阶段做好了.

2.编辑blacklist.conf。

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

添加以下部分并保存:

blacklist vga16fb

blacklist nouveau

blacklist rivafb

blacklist nvidiafb

blacklist rivatv

(这里有一行空格)

3. 删除之前所安装的nVidia驱动。

sudo apt-get remove --purge nvidia-*(需要清除干净)

sudo apt-get remove --purge xserver-xorg-video-nouveau

4. 重启电脑。

5. 按Ctrl + Alt +F1到第一控制台(+F7是回到xservers)。

6. 输入用户名和密码后,登录后执行(数字不能用小键盘输入):

sudo /etc/init.d/gdm stop或者

sudo /etc/init.d/lightdm stop

7. 进入驱动所在的文件夹,安装驱动(这里有个小技巧,只需要输入NVIDIA加tab键就行了,文件名可以全部补全,不要说我太low,以前我还真不知道,当然也可先把驱动名字改为简单的,自己能认识的)。

sudo sh NVIDIA-Linux-x86_64-340.24.run

报错the distribution-provided pre-install script failed!不必理会,继续安装;

8.启动GDM :

sudo /etc/init.d/gdm restart或者

sudo /etc/init.d/lightdm restart

9.重启电脑。

sudo reboot

10.可能在详细信息里面显卡选项显示未知,可用以下手法:

sudo apt-get install mesa-utils

本人在按照上面的方法安装的时候,sudo /etc/init.d/gdm stop或者sudo /etc/init.d/gdm restart都没有找到文件,可能时系统的问题吧,不必管,这里第6步和第8步使用sudo /etc/init.d/lightdm stop和sudo /etc/init.d/lightdm restart就行了.

3.安装cuda,这也是我看到的比较简单的安装方法

1.安装cuda-6.5

进入刚刚下载的cuda-6.5所在的文件夹执行

sh cuda_6.5.14_linux_64.run

然后就是耐心的等待安装的完成

2.配置环境变量

ubuntu的环境变量配置文件再 ~/home/用户名/.bashrc或者/etc/bash.bashr或者/etc/profile三个文件中,具体的区别好像就是全局啊,什么的,反正就是权限和作用范围不一样了,可能还有别的区别,因此只需要使用gedit打开编辑其中一个就行了,这里为了保险还是使用大家都用的的.

具体执行以下命令:

:~$ sudo gedit .bashrc

在文件末尾加上,:

$ export PATH=/usr/local/cuda-6.5/bin:$PATH
$ export LD_LIBRARY_PATH=/usr/local/cuda-6.5/lib64:$LD_LIBRARY_PATH

我的系统是64位的所以是用的lib64,当然再下载,对了忘记说了,对于不同的系统再下载驱动时也要注意,不然白下了,

然后;

~$ source .bashrc

使得环境变量配置生效

3.编译sdk的sample

下面不是我的是别人的,我的也是这样的,但是不好截图,就没有贴了

完成后编译Sample文件, 整个过程大概10分钟左右

cd /usr/local/cuda-<span>6.5</span>/<span>samples
</span><span>sudo</span> <span>make</span>
Copy after login

 全部编译完成后, 进入 samples/bin/x86_64/linux/release, sudo下运行deviceQuery

<span>sudo</span> ./deviceQuery
Copy after login

如果出现下列显卡信息, 则驱动及显卡安装成功:

ubuntu14.04+cuda6.5+opencv2.4.9+cuda

./<span>deviceQuery Starting...

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

Detected </span><span>1</span><span> CUDA Capable device(s)

Device </span><span>0</span>: <span>"</span><span>GeForce GTX 670</span><span>"</span><span>
  CUDA Driver Version </span>/ Runtime Version          <span>6.5</span> / <span>6.5</span><span>
  CUDA Capability Major</span>/Minor version number:    <span>3.0</span><span>
  Total amount of global memory:                 </span><span>4095</span> MBytes (<span>4294246400</span><span> bytes)
  ( </span><span>7</span>) Multiprocessors, (<span>192</span>) CUDA Cores/MP:     <span>1344</span><span> CUDA Cores
  GPU Clock rate:                                </span><span>1098</span> MHz (<span>1.10</span><span> GHz)
  Memory Clock rate:                             </span><span>3105</span><span> Mhz
  Memory Bus Width:                              </span><span>256</span>-<span>bit
  L2 Cache Size:                                 </span><span>524288</span><span> bytes
  Maximum Texture Dimension Size (x,y,z)         1D</span>=(<span>65536</span>), 2D=(<span>65536</span>, <span>65536</span>), 3D=(<span>4096</span>, <span>4096</span>, <span>4096</span><span>)
  Maximum Layered 1D Texture Size, (num) layers  1D</span>=(<span>16384</span>), <span>2048</span><span> layers
  Maximum Layered 2D Texture Size, (num) layers  2D</span>=(<span>16384</span>, <span>16384</span>), <span>2048</span><span> layers
  Total amount of constant memory:               </span><span>65536</span><span> bytes
  Total amount of shared memory per block:       </span><span>49152</span><span> bytes
  Total number of registers available per block: </span><span>65536</span><span>
  Warp size:                                     </span><span>32</span><span>
  Maximum number of threads per multiprocessor:  </span><span>2048</span><span>
  Maximum number of threads per block:           </span><span>1024</span><span>
  Max dimension size of a thread block (x,y,z): (</span><span>1024</span>, <span>1024</span>, <span>64</span><span>)
  Max dimension size of a grid size    (x,y,z): (</span><span>2147483647</span>, <span>65535</span>, <span>65535</span><span>)
  Maximum memory pitch:                          </span><span>2147483647</span><span> bytes
  Texture alignment:                             </span><span>512</span><span> bytes
  Concurrent copy and kernel execution:          Yes with </span><span>1</span><span> copy engine(s)
  Run </span><span>time</span><span> limit on kernels:                     Yes
  Integrated GPU sharing Host Memory:            No
  Support host page</span>-<span>locked memory mapping:       Yes
  Alignment requirement </span><span>for</span><span> Surfaces:            Yes
  Device has ECC support:                        Disabled
  Device supports Unified Addressing (UVA):      Yes
  Device PCI Bus ID </span>/ PCI location ID:           <span>1</span> / <span>0</span><span>
  Compute Mode:
     </span><span>

deviceQuery, CUDA Driver </span>= CUDART, CUDA Driver Version = <span>6.5</span>, CUDA Runtime Version = <span>6.5</span>, NumDevs = <span>1</span>, Device0 = GeForce GTX <span>670</span><span>
Result </span>= PASS
Copy after login
至此cuda6.5安装就完成了.
Copy after login
<span>有时间再把安装opencv和cuda-convnet2的配置的技术总结下!</span>
Copy after login

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template