Merge pull request #1464 from KayGuoWhu/master

[Translated]20140804 How to install and configure Nvidia Optimus driver on Ubuntu.md
This commit is contained in:
Xingyu.Wang 2014-08-07 19:19:54 +08:00
commit edafac9df6
2 changed files with 104 additions and 109 deletions

View File

@ -1,109 +0,0 @@
[translating by KayGuoWhu]
How to install and configure Nvidia Optimus driver on Ubuntu
================================================================================
Nvidia Optimus is a hybrid GPU system which utilises what is known as "discrete switching" and has been long associated with headaches and limitations on Linux systems. After years of wait, Ubuntu 14.04 with its shiny new kernel finally shipped with proprietary driver compatibility that can be installed easily. This article will guide you through the installation process after quick background of Nvidia Optimus for the unfamiliar readers. For the seasoned destroyer of Xorg configuration, you can quickly jump to the installation section below.
### Background ###
To those who aren't aware of Nvidia Optimus, it essentially alternates between using the onboard Intel graphics chipset and the more powerful NVIDIA card on demand using a process referred to as "GPU switching". Its purpose is to prolong battery life in notebooks, allowing the Nvidia GPU to switch off when there is no need for it. The benefits are obvious, allowing say 8 hours of battery life if simply typing in a word processor, or 3 hours if watching HD videos. That is if you are using Windows.
![](https://farm6.staticflickr.com/5581/14612159387_2e89a52085_z.jpg)
A couple of years ago I purchased a netbook (Asus VX6), and made the stupid mistake of not checking for Linux driver compatibility because it had never really been an issue before - especially for a netbook sized device. Even if a driver didn't work straight out of the box, I could always get it working one way or another whether installing a proprietary module or using backports. This was a first for me - my device came equipped with an Nvidia ION2 graphics card.
At the time Nvidia's Optimus hybrid GPU hardware was a relatively new thing, and I did not foresee the limitations I encountered running Linux on this machine. If you're reading this, are experienced with Linux systems and have purchased a notebook in the past for years, you might be familiar with this pain also.
The [Bumblebee][1] project was until recently as good as it gets in terms of Linux support for hybrid graphics. It was actually possible if configured correctly to utilise the Nvidia card for a desired application via CLI (i.e. 'optirun vlc'), but getting things like HDMI to work was a different story.
I used the phrase 'if configured correctly' because actually getting it working more often than not just broke your Xorg configuration on first few attempts. If you hadn't used ppa-purge or run 'dpkg-reconfigure -phigh xserver-xorg' before, then I can assure you that tinkering with Bumblebee taught them to you pretty quickly.
[![](https://farm6.staticflickr.com/5588/14798680495_947c38b043_o.png)][2]
It's been a very long wait for Nvidia to release Linux driver support for Optimus, and we still don't have the actual support for discrete switching. However, now with Ubuntu 14.04, nvidia-prime and the nvidia-331 driver, one can choose between the Intel or Nvidia card easily. Unfortunately it is still limited further by requiring restarting X11 (achieved by logout and login) for the change to take effect.
To make this slightly less inconvenient, there is an applet for quick switching, which can I'll get to later, but installation of the driver is a breeze and HDMI works so that's enough to satisfy me.
### Install Nvidia Optimus Driver ###
To run through the process quickly, I'll be assuming you've got a fresh install of Ubuntu 14.04 or Mint 17 ready to go.
Working as a sysadmin, I find 90% of Linux tasks these days quicker via CLI, but this time I recommend simply using the 'Additional Drivers' application that you're probably familiar with for installing proprietary NIC or sound drivers.
![](https://farm4.staticflickr.com/3886/14795564221_753f9e2d99_z.jpg)
**NOTE: All commands shown below preceded by ~# need to be run as root. Be sure to either 'sudo su' before running commands, or run with sudo at beginning of command.**
You can also do it via CLI by installing:
~# apt-get install nvidia-331 nvidia-settings nvidia-prime
followed by a reboot. Make sure you don't have any packages like Bumblebee or other loaded Nvidia drivers, otherwise it'll probably just break your X11. In case you aren't working with a clean install and did previously install Bumblebee etc, run the following before installing nvidia-331 and nvidia-prime:
~# apt-get purge libvdpau-va-gl1 bumblebee* nvidia*
### Switch between Nvidia non-Nvidia Cards ###
You can switch between Nvidia and non-Nvidia (e.g., Intel) cards by pressing Alt+F2 or typing from terminal:
~$ nvidia-settings
#### NOTE: ~$ means do not run as root user. ####
Chose the desired card, then log out and log back in.
![](https://farm4.staticflickr.com/3921/14796320814_de5c9882c2_z.jpg)
You can also use CLI to set which card to use as default:
~# prime-select intel (or nvidia)
As well as switch cards using:
~# prime-switch intel (or nvidia)
Both commands require restarting X11 to take effect, which can also be achieved by simply logging out and back in. A reboot will also suffice.
For Ubuntu users:
~# service lightdm restart
For Mint users:
~# service mdm restart
To verify which card is running:
~# prime-select query
And lastly you can install the prime-indicator package from ppa:nilarimogard/webupd8 which allows for a quick switch from the tool bar which restarts your Xserver session for you as well. To install it, simply run:
~# add-apt-repository ppa:nilarimogard/webupd8
~# apt-get update
~# apt-get install mesa-utils prime-indicator
### Summary ###
In conclusion, it's still not ideal, but at least it's nice and simple with proper proprietary support. Many people often still opt for Bumblebee over this setup because they find using the Nvidia driver only runs their battery dead in no time. For my personal usage this setup is the better way to go as I only use the Nvidia card for HDMI out, which implies that I will have it plugged into power. Otherwise Intel suffices for my portable usage as I don't require anything beyond LibreOffice, Chromium and Terminator on the go.
If you would prefer the idea of running Intel as default and specifying to run specific applications utilising Nvidia card, instead direct your reading to the many Bumblebee tutorials out there. I advise in the instance of Bumblebee once you finally get it working properly to document the commands and process used to configure for your device as there is nothing worse than doing a clean install 9 months later and forgetting what was done to get it working last time.
It may also be worthwhile checking out [this script][3] I stumbled across, which serves to easily switch between Bumblebee and Nvidia-Prime, but I must stress that I have not tested it myself.
Finally, I feel it is a massive shame that it's taken this long to get proprietary support for this cards on Linux and still no support for discrete switching, considering that hybrid graphics appear to be the future for portable devices. Normally AMD are associated with dropping the ball for driver support on Linux, but in my eyes Optimus is by far the worse hardware support issue I have encountered.
Regardless of whether this is ideal for your usage, it is the easiest way to go utilising that NVIDIA card. Try running the newest Unity on the Intel card alone and decide for yourself whether 2-3 hours battery life is worthy trade off.
--------------------------------------------------------------------------------
via: http://xmodulo.com/2014/08/install-configure-nvidia-optimus-driver-ubuntu.html
作者:[Christopher Ward][a]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
[a]:http://xmodulo.com/author/christopher
[1]:http://bumblebee-project.org/
[2]:http://xkcd.com/963
[3]:https://devtalk.nvidia.com/default/topic/705993/easy-switch-between-bumblebee-and-nvidia-prime/

View File

@ -0,0 +1,104 @@
在Ubuntu上安装和配置Nvidia Optimus驱动
================================================================================
Nvidia Optimus是一款利用“双显卡切换”技术的混合GPU系统但长期以来受限于Linux系统上的诸多不便与限制。在数年的等待之后搭载这全新内核的Ubuntu 14.04最终实现了非常容易安装的专用驱动的兼容性。这篇文章首先为不熟悉Nvidia Optimus的读者简介相关背景然后展示整个安装过程。对于对Xorg有着丰富配置经验的老手可以直接跳到安装部分。
### 背景知识 ###
对那些不熟悉Nvidia Optimus的读者在板载Intel图形芯片组和使用被称为“GPU切换”、对需求有着更强大处理能力的NVIDA显卡这两者之间的进行切换是很有必要的。这么做的主要目的是延长笔记本电池的使用寿命以便在不需要Nvidia GPU的时候将其关闭。带来的好处是显而易见的比如说你只是想简单地打打字笔记本电池可以撑8个小时如果看高清视频可能就只能撑3个小时了。使用Windows时经常如此。
![](https://farm6.staticflickr.com/5581/14612159387_2e89a52085_z.jpg)
几年前,我买了一台上网本(Asus VX6)犯的最蠢的一个错误就是没有检查Linux驱动兼容性。因为在以前特别是对于一台上网本大小的设备这根本不会是问题。即便某些驱动不是现成可用的我也可以找到其它的办法让它正常工作比如安装专门模块或者使用反向移植。对我来说这是第一次——我的电脑预先配备了Nvidia ION2图形显卡。
在那时候Nvidia的Optimus混合GPU硬件还是相当新的产品而我也没有预见到在这台机器上运行Linux会遇到什么限制。如果你读到了这里恰好对Linux系统有经验而且也在几年前买过一台笔记本你可能对这种痛苦感同身受。
[Bumblebee][4]项目直到最近因为得到Linux系统对混合图形方面的支持才变得好起来。事实上如果配置正确的话通过命令行接口如“optirun vlc”为想要的应用程序去利用Nvidia显卡的功能是可能的但让HDMI一类的功能运转起来就很不同了。(译者注Bumblebee 项目是把Nvidia的Optimus技术移到Linux上来。)
我之所以使用“如果配置正确的话”这个短语是因为实际上为了让它发挥出性能往往不只是通过几次尝试去改变Xorg的配置就能做到的。如果你以前没有使用过ppa-purge或者运行过“dpkg-reconfigure -phigh xserver-xorg”这类命令那么我可以向你保证修补Bumblebee的过程会让你受益匪浅。
[![](https://farm6.staticflickr.com/5588/14798680495_947c38b043_o.png)][2]
等待了很长一段时间Nvidia才发布了支持Optimus的Linux驱动但我们仍然没有获取对双显卡切换的真正支持。然而现在有了Ubuntu 14.04、nvidia-prime和nvidia-331驱动任何人都可以在Intel芯片和Nvidia显卡之间轻松切换。不幸的是为了使切换生效还是会受限于要重启X11视窗系统通过注销登录实现
为了减轻这种不便有一个小型程序用于快速切换稍后我会给出。这个驱动程序的安装就此成为一件轻而易举的事了HDMI也可以正常工作这足以让我心满意足了。
### 安装Nvidia Optimus驱动 ###
为了更快地描述这个过程我假设你已经安装好Ubuntu 14.04或者Mint 17。
作为一名系统管理员最近我发现90%的Linux通过命令行执行起来更快但这次我推荐使用“Additional Drivers”这个应用程序你可能使用它安装过网卡或声卡驱动。
![](https://farm4.staticflickr.com/3886/14795564221_753f9e2d99_z.jpg)
**注意:下面的所有命令都是在~#前执行的需要root权限执行。在运行命令前要么使用“sudo su”切换到root权限要么在每条命令的开头使用速冻运行。**
你也可以在命令行输入如下命令进行安装:
~# apt-get install nvidia-331 nvidia-settings nvidia-prime
接下来是重启。确保你没有安装类似于Bumblebee或其他已加载的Nvidia驱动否则很可能会破坏你的X11。万一你没有进行全新安装之前有安装过Bumblebee程序那么在安装nvidia-331和nvidia-prime前运行下列命令
~# apt-get purge libvdpau-va-gl1 bumblebee* nvidia*
### 在Nvidia和非Nvidia显卡之间切换 ###
你可以通过按下Alt+F2或者从命令行键入下列命令实现Nvidia和非Nvidia如Intel显卡之间的切换
~$ nvidia-settings
#### 注意:~$表示不以root用户身份执行。 ####
![](https://farm4.staticflickr.com/3921/14796320814_de5c9882c2_z.jpg)
你也可以使用命令行设置默认使用哪一块显卡:
~# prime-select intel (or nvidia)
使用这个命令进行切换:
~# prime-switch intel (or nvidia)
两个命令的生效都需要重启X11可以通过注销和重新登录实现。重启电脑也行。
对Ubuntu用户键入命令
~# service lightdm restart
对Mint用户键入命令
~# service mdm restart
键入这个命令确认哪一块显卡在运行:
~# prime-select query
最后你可以通过添加ppa:nilarimogard/webupd8来安装叫做prime-indicator的程序包实现通过工具栏快速切换来重启Xserver会话。为了安装它只需要运行
~# add-apt-repository ppa:nilarimogard/webupd8
~# apt-get update
~# apt-get install mesa-utils prime-indicator
### 总结 ###
总而言之这个方法仍不完美但至少它能简单易用地提供合适的专门驱动支持。很多人不会使用这个安装方法来设置Bumblebee因为他们发现使用Nvidia驱动会很快耗完电池。对我个人的使用来说这是一个更好的方法因为我使用Nvidia只为了满足HDMI输出这表示我必须把电脑插上电源才行。不然的话Intel的显卡对我的笔记本来说够用了因为除了频繁地使用Libreoffice、Chromium和Terminator这几个软件我别无所求。
如果你宁愿选择在默认情况下使用Intel显卡为运行特定的应用程序使用Nvidia显卡你应该去阅读那些Bumblebee教程。一旦你得以让Bumblebee正常工作起来我建议你记录下用来配置电脑的命令和过程。因为没有什么比9个月之后再来一次全新安装但忘记了上次是如何成功安装更糟糕的事情了。
也可以花时间查看一下这个我偶然发现的[脚本][3]用来方便地在Bumblebee和Nvidia-Prime之间进行切换但我必须强调并没有亲自对此进行实验。
最后我感到非常惭愧写了这么多才得以为Linux上的显卡提供了专门支持但仍然不能实现双显卡切换因为混合图形技术似乎是便携式设备的未来。一般情况下AMD会发布Linux平台上的驱动支持但我认为Optimus是目前为止我遇到过的最糟糕的硬件支持问题。
不管这篇教程对你的使用是否完美但这确实是利用这块Nvidia显卡最容易的方法。你可以试着在Intel显卡上只运行最新的Unity然后考虑2到3个小时的电池寿命是否值得权衡。
--------------------------------------------------------------------------------
via: http://xmodulo.com/2014/08/install-configure-nvidia-optimus-driver-ubuntu.html
作者:[Christopher Ward][a]
译者:[KayGuoWhu](https://github.com/KayGuoWhu)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
[a]:http://xmodulo.com/author/christopher
[1]:http://bumblebee-project.org/
[2]:http://xkcd.com/963
[3]:https://devtalk.nvidia.com/default/topic/705993/easy-switch-between-bumblebee-and-nvidia-prime/