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.


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.

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 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.

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.

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.

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


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 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.

Subscribe to Xmodulo

Do you want to receive Linux FAQs, detailed tutorials and tips published at Xmodulo? Enter your email address below, and we will deliver our Linux posts straight to your email box, for free. Delivery powered by Google Feedburner.

Support Xmodulo

Did you find this tutorial helpful? Then please be generous and support Xmodulo!

The following two tabs change content below.

Christopher Ward

Christopher Ward is a largely self taught Linux and FOSS enthusiast which begun as hobby 5 years ago, turned into passion and became a career. He currently works for a couple of companies contacting as a Linux SysAd as well as a Support Technician.

Latest posts by Christopher Ward (see all)

30 thoughts on “How to install and configure Nvidia Optimus driver on Ubuntu

  1. The only issue encountered by me is that with the nvidia driver, the system temperature is about 55-60 degrees Celsius as reported by gkrellm. However, with bumblebee, it stays at a much lower 44-48 degrees Celsius. This is on a Lenovo Z580 laptop.

  2. Regretfully this does not work on my Thinkpad W520, it gets stuck on Intel.
    This is a Kubuntu install that never saw Bumblebee.
    But during install nVidia was fixed in the BIOS, I changed the BIOS setting to Optimus and rebooted but the laptop will only boot into Intel, no way to change to nVidia.
    I also did a purge and reinstall of nVidia-331 and nvidia-prime, still stuck on Intel.

    And it overwrote my xorg.conf so screenbrightnes could no longer be controled...

    • Sorry to hear. I'm not a KDE kid so can't comment. Have successfully tried on 2 different machines with lightdm, mdm and gdm3. Gdm with gnome3 was trickier to get working than gnome3 on top of lightdm I will add.

      Out of curiosity did you test it with lightdm instead of kdm? Be good to know whether it's hardware or the display manager that caused your issues.

      • Yes it was with lightdm, tomorrow I'll give it a try with kdm, thanks for the suggestion ;)

        I would imagine the selection is made at a fairly early time in the process that starts up X, I mean before a windows manager is called.

    • Well, I'm running Lubuntu 14.10 on my W520, and this is exactly the procedure I use to install nvidia-prime and it works just fine. Right now I'm having problem with dual-monitor setup. It used to work on Ubuntu 14.04, but it's not working on Lubuntu14.10

  3. From a clean Linux Mint 17 install, when running "Device Manager" for the first time, it comes up blank. I think you should mention that people need to add a repository to their list in order to be presented with the NVIDIA driver options.
    > sudo apt-add-repository ppa:xorg-edgers/ppa
    > sudo apt-get update

    Once this is done, the Device Manger will display the NVIDIA drivers to be installed.

    Thanks for a good post.

  4. I have just tried your tip, and found that as soon as lightdm starts, everything runs smoothly. However, as soon as I log in, with either Unity or KDE, my screen goes blank, only with the mouse pointer. If I revert to Intel, my session works normally.

    I get some strange errors when I run prime-switch, saying that /etc/modprobe.d is not a directory. Well, I think it is supposed not to be a directory... ;)

  5. Thanks a lot for the guide, really helpful! Really nice to finally have a optimus support without having to rely on bumblebee. No slight to bumblebee, which for a long time proved very useful.

    And finally hdmi support! That is really great. Did you happen to get hdmi audio working as well?


  6. Dear Christopher Ward,
    Kodos to you. After struggling with all other options, I am able to enable and use Nvidia Optimus GPU in my Dell XPS L502X in Ubuntu Studio 14.04. Thanks for your straight forward method.

  7. Folks,

    I have an ASUS NV46M laptop with these graphics controllers:
    00:02.0 VGA compatible controller: Intel Corporation 3rd Gen Core processor Graphics Controller (rev 09)
    01:00.0 VGA compatible controller: NVIDIA Corporation GF108M [GeForce GT 630M] (rev a1)

    I had Bumblebee and removed it, Ubuntu 14.04 updated and installed nvidia related packages as mentioned on the post.

    But my HDMI out is not working (it is working on Windows).

    And my VGA output has issues when using different resolutions for the built-in monitor and external monitor.

    Can some help me on how to get this working?

    • I've got HDMI out working.
      I had do plug in HDMI cable when the laptop was powered up. It's not plug and play.

      But I still have problems with resolutions. I cannot use both displays (built-in and HDMI) at the same time.
      Is someone able to get this working?

  8. I'm running Ubuntu 14.10 on W520 and almost everything is fine. The only exception is that I can't use a second display on the vga port. I can use the internal display and the external display on the display port - so the same situation as ail mentioned several weeks ago.

    Does anyone (ail?) have a solution for this?

    Thanks vor this how to and hopefully thanks in advance for the vga port problem.

  9. I was just playing around with this on my new Dell M3800 Developer Edition (= factory-installed Ubuntu 14.04), and I found that:

    - prime-select query returns "unknown"
    - Using nvidia-settings to try to switch from Intel (what it thinks I'm using) to the nvidia GPU fails, but the dialog box with OK in it that might be telling me why is tiny and unresizable, so I have no idea why it doesn't work.

    I installed prime-indicator, and it says "Using Mesa DRI Intel(R) Haswell Mobile" which bears out what nvidia-settings says about which GPU it's using.

    I don't view this as a huge problem, since the Intel GPU meets my needs, but would like to figure out why it doesn't work, anyway. Has anyone else encountered/solved this issue?

    • Hi, I've the same issue but the solution is quite easy:

      If you switch from nvidia to intel, it works after a logout
      If you switch from intel to nvidia, it works after a reboot

    • hi, i've the same issue. The switch to nvidia card works only after a reboot, the switch to intel card works after a logout.

  10. Hi, thank you for your useful guide, I've the same hardware (ION2 GT218) but when I run glxgears ... intel driver reach 600 fps, nvidia driver 125 fps. Sounds weird but seems the intel driver performs better. I'm quite confused.

  11. What if your 'Additional Drivers' section has never returned anything, even with a fresh download?

  12. Hi, thank you very very much.
    The simple line:
    "sudo apt-get install nvidia-331 nvidia-settings nvidia-prime"
    (Linux Mint Rebecca (17.1) Cinnamon (64bit) allows me now to use the
    GeForce GTX Nvidia 850M instead of the onboard
    Intel Graphics (Notebook Acer VN7-571G-74YL).
    However, seems as if I need a reboot after change of graphics card in both directions (Intel->NVIDIA and NVIDIA->Intel).

  13. Thank you so much for this! I've been able to get my graphics card working with Bumblebee multiple times in the past, but it takes forever to get everything straight because I guess a random number generator determines whether it will work or not. And then when you're lucky enough to get Bumblebee working finally, a week or two later, you update your system and then graphics don't works again. Your solution is waaaay better.


    I tried the Bumblebee method... didn't work. This method worked PERFECTLY and my frame-rates on steam are way better now since I am using the Nvidia GPU(GT 650M) instead of the Intel GPU.
    I spent HOURS trying the Bumblebee method... wish I had seen this first!!!!

    Linux Mint 17.1 (Cinnamon), Dell Inspiron, i7 3630QM


  15. Hey, I did what you wrote here and everything seems to work. The problem is that now when I use the intel it's always at 50-70%. So I only get around 2h of battery life (before I used bumblebee and I had around 4-6h. Any ideas what went wrong?

    I'm using Ubuntu 14.04 LTS on an Acer Aspire TimelineX (GeForce GT 540M)

  16. Thanks for this article.
    Any idea to install the latest nvidia driver from xorg edgers (3.49) that can still work with prime? I tried lots of tricks but still no success.
    As you said it's a shame that canonical doesn't work harder on this task or at least put in official ppa with the latest driver release.

  17. Hi Christopher,
    Thank you for putting this information up. I've been thrashing around with how/when to enable the Nvidia graphics adapter on my Lenovo Y50 laptop with hybrid Intel/Nvidia graphics.

    I have performed the purge as suggested and then installed "nvidia-331 nvidia-settings nvidia-prime" packages on Mint 17.1. Driver Manager shows no proprietary drivers. nvidia-settings shows the choice for Intel or Nvidia usage but is unable to make the Nvidia selection stick. I have verified that the nvidia module is loaded:

    hbarta@yggdrasil ~ $ lsmod|grep nvidia
    nvidia 10744943 0
    drm 303102 7 ttm,i915,drm_kms_helper,nvidia,nouveau

    and probably the must useful feedback is:
    hbarta@yggdrasil ~ $ sudo prime-select nvidia
    Error: alternatives are not set up properly
    Error: nvidia mode can't be enabled
    hbarta@yggdrasil ~ $

    'prime-switch nvidia' exits with no message. prime-select query gets:
    hbarta@yggdrasil ~ $ prime-select query

    Do you have any suggestions to get this working? I would not be averse to installing proprietary drivers if that would help. I see 346.47 available from Nvidia.


  18. I know this is an old post, but I've been trying to figure out this Optimus/Bumblee thing for what feels like forever off and on, and finally ... after purging and following your instructions, prime-indicator shows Nvidia as the selected GPU. Uh-mazing. Even if it still doesn't work, this is the closest I've ever got. This optimus/Linux nonsense is ridiculous. Urgh.

    :~$ prime-select query


    Ubuntu 14.04 Utopic Unicorn
    MSI GT70 Nvidia GTX675mx / Intel whatever

Leave a comment

Your email address will not be published. Required fields are marked *