台式机ubuntu,使用intel核显作显示输出,nvidia独显做cuda运算

问题来源:

将显示线插到独显上安装完ubuntu之后装完nvidia显卡驱动,使用nvidia-smi命令会发现Xorg和compiz两个服务占用了一部分显存,随着ubuntu不关机使用越来越久,甚至会占用1G左右的显存,这就大大浪费了本来就很奢侈的显存资源,因此经过搜索和探索折腾,形成了这篇博客以解决这个问题。目的很简单:单纯的让intel核显作显示输出,nvidia独显单纯的做cuda运算,两个显卡各司其职。

0. 硬件预准备

首先使用lspci | grep VGA命令查看输出中是否有intel,如果没有的话就按以下硬件设置。

将显示器连接线插到主板核显输出口,进入bios进行如下设置(以华硕主板为例):

高级—北桥—显示设置—首选显卡(默认为auto自动)—更改为igfx(即核显),同时将iGPU设置中改为enable(重要!!!此项操作为核显分配显存,若只打开igfx而不打开iGPU,则核显没有显存,bios仍然会选中独显作为显示!!!)

(可能会考虑的一种较优做法):先保持显示线插在独显上不动,修改bios为核显,然后再将显示线插到核显上

1. 卸载原有nvidia显卡驱动
sudo apt-get remove --purge nvidia*
sudo apt-get autoremove nvidia*
sh ./nvidia.run --uninstall
2. 安装nvidia显卡驱动without openGL

下载.run安装包,网址:https://www.nvidia.com/Download/Find.aspx?lang=en-us
ctrl+alt+F1进入文本模式:
关闭图形界面:

sudo /etc/init.d/lightdm stop

运行.run文件:

chmod a+x NVIDIA.run  # a.run为驱动文件
sudo ./NVIDIA.run --no-opengl-files

–no-opengl-files:表示只安装驱动文件,不安装OpenGL文件。

!注意:安装过程中会提示如下警告:
WARNING: Unable to find a suitable destination to install 32-bit compatibility libraries. Your system may not be set up for 32-bit compatibility. 32-bit compatibility files will not be installed; if you wish to install them, re-run the installation and set a valid directory with the --compat32-libdir option.

安装几个32位的包即可:

sudo dpkg --add-architecture i386
sudo apt update
sudo apt install libc6:i386

弹窗install nvidia 32-bit compatibility libraries?这个笔者选择的No,暂时影响未知
Would you like to run the nvidia-xconfig utility to automatically update your X Configuration file so set the NVIDIA X driver will be used when you restart X?这个笔者也选择的No,暂时影响未知

3. 安装cuda without openGL
sudo ./cuda.run --no-opengl-libs

–no-opengl-libs:表示只安装驱动文件,不安装OpenGL文件。注意:不是-no-opengl-files。

大功告成!此时用nvidia-smi或者nvtop命令查看显卡占用显存占用,发现显卡完全空载,任务完成!

参考内容:

Intel for display, NVIDIA for computing
Use integrated graphics for display and NVIDIA GPU for CUDA on Ubuntu 14.04
Ubuntu下Nvidia驱动安装

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值