Results

nVidia CUDA, nVidia Optimus, Linux & their complex relationship


After months of brainstorming on whether to get a Macbook or a Win7 laptop, how and where to buy it, what configuration to choose etc, I finally got my new Alienware M14x (Win 7) last week. Unfortunately I got my hands on it last Monday, which in my opinion left me no choice but to reduce my sleeping hours to 3-4hrs a day. With all those extra ‘sleepless’ hours I managed to find, I could accomplish quite a lot of things I had in my rather long TODO list by the end of the week, or so I thought. But I still haven’t completely set up my system, the way I wanted – lots of games, a Linux development environment etc.

The culprit is none other than the most important component in the laptop (for me) - the GPU. Since gaming, photo editing and GPU programming (nVidia CUDA) are the three things I am looking forward to focus on for most of my time, I wanted to make sure I made the right choice in selecting the GPU. The M14x comes with an nVidia GeForce GT 555M and it boasts the nVidia Optimus technology which uses switchable graphics (with Sandy Bridge integrated GPU) for power saving. All the reviews explained a lot about how this laptop takes full advantage of Optimus. But what none of the posts (I read) mentioned was, just like any other new technology, there is no support for Optimus in Linux till date, not by nVidia, not by Linux or not even by the manufacturer (in my case, Dell/Alienware).

What this means is, even though I will be able to use the nVidia GPU in Linux for CUDA programming, I won’t be able to use the nVidia GPU for any graphics applications in Linux. For example, I will be able to do computations on the GPU as a coprocessor, but it cannot be used for display in Linux environment. It doesn’t affect me a lot as I am not looking forward for any graphics programming in Linux in the short term, I already have my hands full with the TODO list I mentioned earlier. But it sure is a bummer considering I wanted to try out some graphics/game programming in the long term in the Linux environment. Hopefully there will be support for the Optimus technology in Linux soon.

I learned this fact the hard way, after spending long hours trying to setup my system to use the nVidia GPU. This post may/may not offer any solutions to any particular problem, but just a few observations and links to some of the sites/forums that helped me in the process.

To begin with, my requirement was to be able to do CUDA programming on a Linux environment in my M14x (GT 555M). On a side note, I have done CUDA setup & programming in the past and was familiar with it. My first step was to choose one of the Linux distributions supported by CUDA. I chose Ubuntu 10.10 and installed it. During my first boot, it asked me to upgrade to 11.04, which I did not accept because I knew that gcc 4.5 or above is not supported by CUDA at the moment. Ubuntu also asked me to activate the nVidia driver which I did it. Then I downloaded the CUDA dev driver, toolkit 4.0 and the code samples. I rebooted the machine and the Xserver failed to start. So, from the command prompt, I removed the ubuntu supplied driver.

sudo apt-get --purge remove nvidia*

Then I installed the dev driver downloaded from nVidia site.
Chmod +x "filename"
./"filename"

I also installed the toolkit (also set the path), samples and the required libraries for building them as specified in the CUDA Getting Started Guide (Linux). I rebooted the machine and again the Xserver failed to start. I poured through support forums & blog entries, tried the black listing method, reinstalled various drivers etc. None of them worked. Ubuntu was unable to load Xserver. So I decided to reinstall Ubuntu and start from step 1.

This time I was more cautious, I did one step at a time. But the moment I installed the dev driver and reboot, Xserver stopped working. What perplexed me more was, I was still able to run the CUDA binaries, which means the driver is installed properly. For a moment, I considered giving Fedora 13 a try.

That’s when I realized that I am using Optimus technology and the thought crossed my mind that what if Linux is trying to use the integrated GPU and nvidia driver is conflicting. My heart sank when I found out that there is no support for Optimus in Linux. There is third party software called bumblebee, which didn’t work for me. Some of the posts talks about a BIOS setting which can force either of the GPUs rather than switching them dynamically. But M14x BIOS doesn’t have that option, yet. So, I was out of options and that when this post helped me. It helped me deactivate the nVidia driver and use the integrated GPU for Xserver. Also the GPU is detected as a coprocessor so that I can do my CUDA programming as long as I am not playing with graphics. Remember to update the Intel graphics driver.
sudo apt-get install xserver-xorg-video-intel

In a nutshell, if your laptop is equipped with Optimus, better use the integrated graphics as of now for Linux. It’s a shame that so much GPU power is simply wasted.

6 comments:

Amogh said...

I had a very wierd experience, but related to Optimus and Linux as well. I have an Acer Aspire 4741G with nVidia GT420M.

As you mentioned, the nVidia driver and Ubuntu weren't playing well with my laptop's nVidia card. I kept getting errors very similar to the Optimus issue.

That lead me to read up on Ubuntu, Optimus and finally Bumblebee. My BIOS also had no option to switch between cards or disable the nVidia GPU.

It was only much later that I realised...(and I felt very stupid then) that the laptop never had an integrated GPU! (To be fair to myself, there was another model in the same series of laptops that did have Optimus, so I kept thinking I had Optimus too). But inspite of that the system was behaving very similar to the problems faced by Optimus users.

What resolved the issue was a BIOS update from Acer. The nVidia driver and Ubuntu stopped complaining and I could get Unity to work in Ubuntu.

Not connected to your solution..but just sharing a similar issue :)

Dragonfly said...

I hope Dell will provide a BIOS update soon using which I can force the nvidia GPU to be used in gdm. And nvidia to release Optimus support in the near future :)

Adil said...

What kind of programming do you do on CUDA? Any game programming?

Dragonfly said...

No game programming, just trying to optimize a computationally intensive signal processing operation called beamforming. Something I picked up from my old lab. ;)
Even if I want to do some game programming (in Linux), I wont be able to, cos there is no support for optimus in Linux

Anonymous said...

I've a Dell L502x with GT525M adapter which also uses the Optimus technology.

In Xorg, I'm using the intel driver to use the integrated graphics adapter by default.

I also installed the Bumblebee project but that only helps when I want to run specific applications on the Nvidia adapter (still can't figure out how Bumblebee uses the NVIDIA adapter if the nvidia driver isn't loaded at all, oh well).

I've given up and I'll use the Intel adapter exclusively for graphics. Now I'm trying to find how the CUDA binaries will contact the NVIDIA adapter...

Wayward4now said...

Have you tried CUDA 5.0?? After doing the setting of the paths and removing my old nVidia drivers, that was about it. I'd give that a whirl. Everything is included in the one package. You DO have to let it install their driver though. The ?Ubuntu driver installed through Jockey wasn't new enough. You will need to be in text mode with the desktop stopped.
sudo service gdm stop
THEN install the run file as root using sudo after you chmod +x

Once you've done that, answering yes to all the questions and taking the defaults, I found that it just used my original /etc/X11/xorg.conf file.

Then restart gdm (or whatever you're using) with sudo service gdm start.

Crank up nautilus and go to /usr/local/bin/cuda/doc/pdf and you'll find the Linux setup notes in a PDF file to properly configure everything, before you start compiling the examples.
Set correctly, and a reboot, should have you running. Just make sure you HAVE a /etc/X11/xorg.conf file.