Saturday, November 9, 2013

Getting NVidia Optimus + Intel HD 4600 + NVidia 740M on Linux Mint 15 (64-bit) Working

I've been postponing this (fixing up the graphics drivers) step of my Linux dual-boot setup on my HP Envy 17-j007tx process for a few weeks, but today I finally got around to sorting out these issues.

This had been put off several times already, given the various tight deadlines I was facing and the fact that apart from some minor inconvenient issues (i.e. heat issues + shortened battery life + a few OpenGL rendering glitches) there weren't any really pressing issues for which it was essential that I got my NVidia card working (especially considering the price of failure: a non-functioning Linux setup, potentially with a forced return to Windows 8).

There are many different variants of this procedure out there. In the end, I ended up picking and choosing bits and pieces from several sources as necessary. These were:
I ended up clobbering together the core parts that all of them required, and tried to mix in the configuration settings for using newer version of the NVidia propriety driver (319 vs 304 provided by the distro default repos) needed to work with the 740M (which apparently only 319.xx support).

The exact set of steps I did were as follows.

A) Add package sources
1) sudo add-apt-repository ppa:xorg-edgers/ppa      # for nvidia-319 drivers
2) sudo add-apt-repository ppa:bumblebee/stable    # for bumblebee
3) sudo apt-get update

B) Install all the necessary packages in one go (and let the package-manager figure out how to handle all this)
4) sudo apt-get install bumblebee bumblebee-nvidia nvidia-319 nvidia-settings-319 virtualgl

(Notably, I've skipped the linux-headers-generic stuff, since I've probably had these installed anyway by something or other. laptop-mode-tools I ended up installing later for good measure, but it isn't necessary)

C) Edit bumblebee.conf so that it finds things correctly
5) gksu gedit /etc/bumblebee/bumblebee.conf

6) Find and ensure that the following lines in this file are as follows:
# You need to explicit the driver used by Bumblebee server.
# colon-separated path to the nvidia libraries

# comma-separated path of the directory containing and the
# default Xorg modules path
(Note: the highlighted bits are the things you have to add or replace relative to the existing configuration, which refers to "nvidia-current")

D) Restart computer
Hopefully after restarting everything booted up alright. Those were some tense moments there as I waited for it to boot up successfully...

E) Test that everything works fine
7) glxgears   =>  60fps
8) optirun glxgears => 1192fps

9) optirun blender => Card used is NVidia 740M running on nvidia-319.17, and none of the graphical glitches seen when using the Intel

F) Add shortcut in Menu for Nvidia Settings
This particular installation procedure doesn't seem to allow for the Nvidia Settings application to be added to the Mint Menu. Instead, by default, you must invoke it from the command-line (nvidia-settings).

If you run this without prefixing it with "optirun" though, it will throw a warning about the NVidia card not being configured correctly to work with XServer. IGNORE THIS WARNING!

To get things working correctly, you don't want to run the suggested command, or else it could very well end up corrupting your display configuration. Instead, use the following gem from the Bumblebee FAQ:
optirun -b none nvidia-settings -c :8
To make things easier to use, create a custom launcher in your menu for accessing the Nvidia Settings (with the command above as the command for that launcher). This simplifies the process of quickly checking your config settings and/or the temperature of the GPU.


  1. I follow your tutorial, but resolution is 640 x 480 help please.

    Thanks and sorry for my english

    1. Hi,

      From what I understand about all this (which really isn't that much), there are 2 possibilities here:
      1) For whatever reason, your system has thinks that whatever monitor is hooked up is the secondary output (which seems to default to that value)
      2) There's a config file somewhere (try the bumblebee file again, or maybe your X11 config is - /etc/X11/...) which probably has a block or some lines describing output resolutions.

      Beyond this, there's not much I can do to help :(

    2. Thanks for your answer.
      I'll try again before installing

  2. Thank You so much! I have tried many other solution I can find on the internet but only yours worked for me! My laptop is Thinkpad Edge E431 with NVIDIA 740M

  3. Aligorith,

    Wow you have given me some optimism. I also have a HP Envy Touchsmart m7-j078ca Notebook for the past month and I have tried like many others dozens of NVidia driver installs with a dozen linux re-install (I now even have a second root partition to try things) with no success. I had tried for 2 years with my previous HP Envy 17-1075? 3D Laptop which had muxless drivers as well with ATI Radeon and No Luck using any form of proprietary drivers.

    SO I thought NVidia would be different, especially seeing so much success with bumblebee.

    Anyway, finally someone with my almost exact laptop and exact video cards.

    Still after all your steps, the dreaded:
    $ optirun glxgears
    [50586.888336] [ERROR]Cannot access secondary GPU - error: [XORG] (EE)
    NVIDIA(GPU-0): Failed to initialize the NVIDIA GPU at PCI:1:0:0. Please

    [50586.888373] [ERROR]Aborting because fallback start is disabled.

    I will tell you about a few differences or glitches I ran into, to help you troubleshoot this with me (I HOPE).

    First, when I ran:
    sudo apt-get install bumblebee bumblebee-nvidia nvidia-319 nvidia-settings-319 virtualgl
    It also installed nvidia-331. Though thankfully with no Kernel errors like I had with ./ So I was optimistic.

    I was leery that in Step 6,
    KernelDriver=nvidia-graphics-drivers-319 would work, and it didn't.
    I had never noticed any one changing the
    so I looked for the file and I only have /usr/lib/nvidia and nvidia-331 and nvidia-331-prime
    and /usr/lib32/nvidia-331 ONLY

    and for - XorgModulePath=/usr/lib/nvidia-graphics-drivers-319/xorg,/usr/lib/xorg/modules
    the only one with an xorg folder is /usr/lib/nvidia-331/xorg
    so I am guessing my /usr/ paths should all be the -331 paths, so that's what I used.

    As well I am using Linux Mint16 Petra, and have also upgraded my kernel to the newest stable linux kernel .

    Please Help as it seems I am getting so close after so long.

    Thanks, Mark

    However, when

  4. Works for me! Last time I tried and gave up. Now I can finally leave win8.

    Infinitely many thanks!