Ubuntu – Can’t switch anymore from Intel to NVIDIA GPU


[Ubuntu 14.04 64bit]

After switching between Intel / NVIDIA graphics and the different NVIDIA drivers I am now suddenly stuck with the Intel GPU. It used to be no problem at all switching between the two – I cannot say for sure what is suddenly causing the issue. I think the last thing I did was switching to the "X.Org X server" driver – then something broke. The switching was part of me trying to troubleshoot issues with setting up a secondary screen.

enter image description here

Every time I try to switch to NVIDIA I get this very expressive error message and then it switches back to Intel :/

I could use some assistance with troubleshooting or suggestions on what to try.

So far I (un/re)installed the various packages "nvidia-settings" / "nvidia-current" / "nvidia-current-updates" / "nvidia-331" / "nvidia-331-updates". To no avail.

> lspci | grep VGA
00:02.0 VGA compatible controller: Intel Corporation 3rd Gen Core processor Graphics Controller (rev 09)
01:00.0 VGA compatible controller: NVIDIA Corporation GK107GLM [Quadro K2000M] (rev a1)

/etc/apt/sources.list: may be found at pastebin.com

Regarding suggestion by Qasim:

raffael@raffael-GT60~> sudo prime-select nvidia
[sudo] password for raffael: 
Error: alternatives are not set up properly
Error: nvidia mode can't be enabled
raffael@raffael-GT60~> sudo prime-select intel
Error: alternatives are not set up properly
Error: intel mode can't be enabled

Regarding 2nd suggestion by Qasim:

sudo apt-get purge nvidia*
sudo apt-get install nvidia-319-updates nvidia-settings-319-updates nvidia-prime
[tried to switch to NVIDIA]

Weird thing is – this actually worked the first time !? Then I switched back to Intel – log off/on – Switched back to NVIDIA – log off/on -> system crashed – error as described above.

Regarding suggestion by Louis Matthijssen:

raffael@raffael-GT60:~$ sudo update-alternatives --set /etc/ld.so.conf.d/x86_64-linux-gnu_GL.conf /usr/lib/nvidia-331-updates-prime/ld.so.conf
update-alternatives: error: alternative name (/etc/ld.so.conf.d/x86_64-linux-gnu_GL.conf) must not contain '/' and spaces
raffael@raffael-GT60:~$ ls -la /usr/lib/nvidia-331-updates-prime
total 44
drwxr-xr-x   2 root root  4096 Mai  2 22:45 .
drwxr-xr-x 196 root root 32768 Mai  3 10:57 ..
-rw-r--r--   1 root root     0 Apr  4 11:50 alt_ld.so.conf
-rw-r--r--   1 root root    60 Apr  4 11:50 ld.so.conf

Repeated algo twice – didn't work again :/

Now it seems to work:

raffael@raffael-GT60:~$ sudo update-alternatives --set x86_64-linux-gnu_gl_conf /usr/lib/nvidia-331-updates-prime/ld.so.conf 
update-alternatives: using /usr/lib/nvidia-331-updates-prime/ld.so.conf to provide /etc/ld.so.conf.d/x86_64-linux-gnu_GL.conf (x86_64-linux-gnu_gl_conf) in manual mode

raffael@raffael-GT60:~$ sudo update-alternatives --set i386-linux-gnu_gl_conf /usr/lib/nvidia-331-updates-prime/alt_ld.so.conf
update-alternatives: using /usr/lib/nvidia-331-updates-prime/alt_ld.so.conf to provide /etc/ld.so.conf.d/i386-linux-gnu_GL.conf (i386-linux-gnu_gl_conf) in manual mode

Afterwards I could switch to NVIDIA – but wasn't offered the extended "NVIDIA X Server Settings" – will reboot now and see what happens.
Follow up: It switched back to Intel after reboot and cannot switch to NVIDIA as usual. To me it seems that your method, Louis, tricks the OS into believing it uses NVIDIA while this is actually not the case.

Best Answer

As you get the following error:

Error: alternatives are not set up properly

You may try to set the alternatives yourself.

When I switch to Intel I see:

update-alternatives: using /usr/lib/nvidia-331-prime/ld.so.conf to provide /etc/ld.so.conf.d/x86_64-linux-gnu_GL.conf (x86_64-linux-gnu_gl_conf) in manual mode
update-alternatives: using /usr/lib/nvidia-331-prime/alt_ld.so.conf to provide /etc/ld.so.conf.d/i386-linux-gnu_GL.conf (i386-linux-gnu_gl_conf) in manual mode

When I switch to NVIDIA I see:

update-alternatives: using /usr/lib/nvidia-331/ld.so.conf to provide /etc/ld.so.conf.d/x86_64-linux-gnu_GL.conf (x86_64-linux-gnu_gl_conf) in manual mode
update-alternatives: using /usr/lib/nvidia-331/alt_ld.so.conf to provide /etc/ld.so.conf.d/i386-linux-gnu_GL.conf (i386-linux-gnu_gl_conf) in manual mode

So you could try this to switch to Intel:

sudo update-alternatives --set x86_64-linux-gnu_gl_conf /usr/lib/nvidia-331-prime/ld.so.conf
sudo update-alternatives --set i386-linux-gnu_gl_conf /usr/lib/nvidia-331-prime/alt_ld.so.conf

Obviously you should replace 331 by your own version.

Now you could try a few things to trigger the switch:

  • Log out and log in again

    to restart the X server as you normally would do

  • Reboot your whole PC

    for the same purpose of the above

  • Execute sudo prime-select nvidia

    as your alternatives are now set for Intel, I hope this will also fix any other settings so that everything is as it should be again (obviously you should still restart the X server)

I hope that I've interpreted the error right.

Also, you could use prime-select query to check which card is currently selected, and fix the alternatives for that card (for example NVIDIA) as you may somehow have set alternatives for the other card (for example Intel), but the tool is still thinking that you're using the other card (for example NVIDIA), thus giving an error saying that the alternatives are not set up properly.