您的位置:首页 > 编程语言

(gpu并行编程)cuda环境搭建中的问题

2017-06-22 10:44 225 查看
  安装环境:ubuntu14.04 + Hasee K550-i7 d1。独显:Nvidia GTX950。 还有一个集成显卡。

1. 安装cuda

  1. 在nvidia官网下载cuda toolkit,例如下载runfile类型。安装步骤。根据参考资料完成选择:

Run `sudo sh cuda_8.0.61_375.26_linux.run`
Follow the command-line prompts
  2. 因为在linux系统中默认安装了nouveau驱动(nvidia开源驱动),会与cuda使用的驱动冲突,所以需要禁用nouveau驱动。按照参考资料-4.1.2.2. Runfile
Installer来进行。

Q1:按照教程安装CUDA环境后可以编译样例,但无法运行,报错为驱动版本对运行版本无效,更换驱动后黑屏,删除驱动重装无效。原因在于我的笔记本为双显卡,需要使用nvidia-prime,来执行默认驱动选取。(当dpkg中有nvidia-settings,也可以执行它来切换)。

  安装nvidia-prime和nvidia-settings后发现默认驱动是nouveau,手动更改无效,还是会自动选取nouveau,改blacklist.conf将其加入黑名单也无效,所以问题变成了如何禁用nouveau驱动而使用安装的nvidia驱动。

问题列表:

  1.运行编译好的cuda样例出现问题:CUDA driver version is insufficient for CUDA runtime version

  2.下载新的cuda8.0安装文件 检验checksum又不一致。damn

  3. 安装的nvidia-settings中无法识别管理我的N卡和集成显卡。

 重新安装

  1. 改变默认驱动为X.Org Xserver(在系统设置->软件和更新->附加驱动;或搜索driver->附加驱动),在本机上可以看到 应当设为nouveau.

  2. 转入命令行模式(ctrl+alt+f1, aka tty1模式),log in; sudo service lightdm restart。if restart to lightdm,open a terminal and use the next step,if not,use tty1, as before;

  

  3. 删除Nvidia相关文件。
sudo apt-get remove --purge nvidia-*

  4. 检查是否有nvidia相关文件残余
dpkg --get-selection | grep nvidia  确保没有任何nvidia残留

  5. 再次查看附加驱动,选择最高可用的驱动。

  6. Go back to tty1 and issue sudo service lightdm restart,Lightdm should restart and you should have the latest driver, for your system. 

___

  7. 因为我的笔记本是双显卡,是一个非常蛋疼的事情,需要安装nvidia-prime和nvidia-settings才能切换显卡。(安装时还专门再去youtube听Linus再说一次:“So fuck you, Nividia!”)

###(已尝试,闪屏黑屏) 附:还有一种被提到禁用nouveau的方式是在grub中改变启动方式。方式为:

 编辑/etc/default/grub文件.

----

For Ubuntu 12.04 the setting is stored in /etc/default/grub . You add it to the line titled GRUB_CMDLINE_LINUX_DEFAULT. If the line says:

GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"

you would change it to:

GRUB_CMDLINE_LINUX_DEFAULT="quiet splash nomodeset"

After adding NOMODESET to this line you should run sudo update-grub to allow grub2 to see it the next time you boot.

------

### 在nvidia-settings中改变使用显卡后报错信息:
ERROR: NVIDIA driver is not loaded

ERROR: Error querying enabled displays on GPU 0 (Missing Extension).

ERROR: Error querying connected displays on GPU 0 (Missing Extension).

** Message: PRIME: Requires offloading

** Message: PRIME: is it supported? yes

ERROR: nvidia-settings could not find the registry key file. This file should

       have been installed along with this driver at

       /usr/share/nvidia/nvidia-application-profiles-key-documentation. The

       application profiles will continue to work, but values cannot be

       prepopulated or validated, and will not be listed in the help text.

       Please see the README for possible values and descriptions.

 执行prime-se
8d0c
lect query 得到信息: unknow

 最后通过prime-select nvidia完成了选择N卡 编译运行cuda样例通过。

————

cuda安装

验证安装前的条件,如是否支持该gpu,是否支持该OS等。需要注意的是本机为双显卡,在安装教程特意有提到:

  If the target system includes both an integrated GPU (iGPU) and a discrete GPU

(dGPU), the --no-opengl-libs option must be used. Otherwise, the openGL library used

by the graphics driver of the iGPU will be overwritten and the GUI will not work. In

addition, the xorg.conf update at the end of the installation must be declined.

安装文件:cuda-tookit和Nvidia驱动和官方资料放在移动硬盘里了。

参考教程:

1. runfile安装和禁用nouveau驱动: http://blog.csdn.net/masa_fish/article/details/51882183
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: