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

在Ubuntu14.04系统中,安装CUDA Toolkit 8.0.61时遇到驱动版本不匹配的问题,导致CUDA样例无法运行。尝试更换驱动后出现黑屏。解决方案涉及使用nvidia-prime进行显卡切换,但系统默认选择nouveau驱动,禁用nouveau尝试无效。问题包括CUDA驱动与runtime版本不匹配、新CUDA安装文件校验失败以及nvidia-settings无法识别显卡。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

  安装环境:ubuntu14.04 + Hasee K550-i7 d1。独显:Nvidia GTX950。 还有一个集成显卡。

1. 安装cuda

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

  1. Run `sudo sh cuda_8.0.61_375.26_linux.run`
  2. 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-select 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.youkuaiyun.com/masa_fish/article/details/51882183

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值