Monday, December 03, 2012

Getting Nvidia Optimus working on my Lenovo Ideapad Y580 Ubuntu/Kubuntu

So I recently got a Lenovo Ideapad Y580 in the hope I could use it to do some CUDA coding at a  conference I recently went to.  Well I got back from the trip and I still hadn't got CUDA or the optimums card working under Linux, finally on a second trip I got frustrated enough to fix it. It took many re-installs and web searches to get it all to work so I though I might outline the steps. I hope it helps someone else....

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

Then try:
  $ glxspheres
and
  $ 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








16 Comments:

Blogger Unknown said...

Great tutorial! I tried almost everything, and your solution was the only one that worked for me. Thanks!

9:00 PM  
Blogger Unknown said...

Happy to make someone's life a bit easier!

11:49 PM  
Blogger Christian said...

ALOT easier ;) thank you so much!

1:55 AM  
Blogger Unknown said...

Perfect! This is the first tutorial I've encountered that actually worked. Thanks so much!

10:45 PM  
Blogger Unknown said...

Perfect! This is the first tutorial I've encountered that actually worked. Thanks so much!

10:47 PM  
Blogger Unknown said...

I've done everything step by step and yet I still got the error. I adjusted it for generic kernel 23 and I don't know why doesn't it work

3:56 PM  
Blogger Unknown said...

This comment has been removed by the author.

1:27 AM  
Blogger Unknown said...

Thanks Chris for this great tutorial. Worked like charm on Ubuntu 12.10.

Hint:
You might also find this link useful:
https://wiki.ubuntu.com/Bumblebee

It helped me :)

1:27 AM  
Blogger Astro Bullz said...

Worked perfectly ! My unity was completely screwed up and this fixed... thanks a ton.

12:50 PM  
Blogger Matt said...

Perfect! Thanks for the post - worked like a charm on my y580 running 12.10x64... This lappy is a beast with a 256Gb mSATA tossed in... Thanks again, Chris!

5:15 PM  
Blogger Matt said...

Perfect! Thanks for the post - worked like a charm on my y580 running 12.10x64... This lappy is a beast with a 256Gb mSATA tossed in... Thanks again, Chris!

5:16 PM  
Blogger Unknown said...

Thank you! Yours was the only solution that worked for me. Will recommend to others.

8:58 AM  
Blogger Unknown said...

Thank you so much dude!

10:18 AM  
Blogger Unknown said...

Thank you so much dude!

10:21 AM  
Blogger Unknown said...

This comment has been removed by the author.

12:53 PM  
Blogger Unknown said...

Thanks

9:44 AM  

Post a Comment

<< Home