Getting Nvidia Optimus working on my Lenovo Ideapad Y580 Ubuntu/Kubuntu
So I installed various Ubuntu and Kubuntu versions and kernel and found the one that works is kernel 3.5.0-17 or greater, so I installed Kubuntu 12.10 and updated to the latest kernel.
$ sudo apt-get -y update
$ sudo apt-get -y install linux-headers-generic
$ sudo apt-get -y upgrade
So the Y580 uses NVIDIA's Optimus technology which works great on Windows but is not directly supported on Linux. However using Bumblebee and optirun one can asses the discreet NVIDIA 660M
A possible solution is to install Bumblebee and to access the card with optirun. There is however a bug in the kernel which means Bumblebee will not work, it gives an e=something like:
$ [ 94.384435] [ERROR]Cannot access secondary GPU - error: Could not load GPU driver
$ [ 94.384481] [ERROR]Aborting because fallback start is disabled.
There is however a work around hack, installing the acpi-handle-hack module.
First dl and install the hack (taken from here):
$ git clone git://github.com/Bumblebee-Project/bbswitch.git -b hack-lenovo
$ cd bbswitch
$ sudo mkdir /usr/src/acpi-handle-hack-0.0.1
$ sudo cp Makefile acpi-handle-hack.c /usr/src/acpi-handle-hack-0.0.1
$ sudo cp dkms/acpi-handle-hack.conf /usr/src/acpi-handle-hack-0.0.1/dkms.conf
$ sudo dkms add acpi-handle-hack/0.0.1
$ sudo dkms build acpi-handle-hack/0.0.1
$ sudo dkms install acpi-handle-hack/0.0.1
Next get the hack to load on boot:
$ echo acpi-handle-hack | sudo tee -a /etc/modules
$ sudo update-initramfs -u
Now Install bumblebee and drivers
$ sudo apt-get install -y bumblebee bumblebee-nvidia nvidia-current
Reboot to get it all loaded
$ sudo reboot
Now if you try
$ optirun glxspheres
You should get something like:
$ [ 128.872061] [ERROR]Cannot access secondary GPU - error: [XORG] (EE) NVIDIA(0): Failed to initialize the NVIDIA GPU at PCI:1:0:0. Please
$ [ 128.872091] [ERROR]Aborting because fallback start is disabled.
The answer to this one I got here, and that is to edit /etc/bumblebee/xorg.conf.nvidia and change the Option "ConnectedMonitor" "DFP" line to Option "UseDisplayDevice" "none" and restart bumblebee:
$ sudo restart bumblebee
$ optirun glxspheres
You should see the difference! I go from ~20fps to ~170fps, now that's what I'm talking about!
Now to install CUDA you can see my previous post, noting that you can skip the driver install as it should be already done.
You will have to install gcc 4.4
$ sudo apt-get install -y gcc-4.4 g++-4.4
$ sudo ln -s /usr/bin/gcc-4.4 /usr/local/cuda/bin/gcc
And tell nvcc to use it with the directive: --compiler-bindir=/usr/local/cuda/bin