CUDA 4.0, Ubuntu 11.04 on a hybrid Intel/Nvidia laptop

I spent enough time over the past couple of days trying to get CUDA working on my new Asus U31SD laptop, that I thought I’d share what ended up working. The thing that made the endeavor a challenge (at least for a knuckle-dragging mechanical engineer like me) was the hybrid (a.k.a Optimus) Intel/Nvidia graphics setup.

Since the system came with Windows 7, the first thing I did was install Ubuntu 11.04 in a dual-boot configuration (32-bit is what I selected, so I can’t make any statement about 64 bit). I then downloaded the latest CUDA developer drivers. I did the normal “sudo service gdm stop” followed by Ctrl-Alt-F1 to get a prompt. I ran the install script and it said some of the pre-install scripts failed, and asked if I wanted to continue. I figured “what the heck?” and said yes. The rest of the install seemed to go just fine, up till it asked if I wanted to modify my X server settings. Feeling lucky, I said yes, and was subsequently unable to restart the xserver.

I rebooted in recovery mode, and went back to the default graphics. I installed the rest of the toolkit and SDK (and gcc 4.4, with appropriate symlinks and modifications to nvcc.profile) and, not feeling too optimistic, tried to compile and run a simple test. It compiled just fine, but crashed when I tried to run it. Feeling defeated, I dinked around trying to get Visual C++ Express 2010 to work under my Windows 7 boot, and while I had limited success, I really didn’t want to do development under Windows (I was able to get the SDK examples to compile and run, but I never could figure out how to start a project from scratch - all the posts I could find seemed to be for a different combination of compiler/CUDA versions),

I did some more Googling and found the bumblebee project (https://github.com/MrMEEE/bumblebee) which aims to allow some degree of hybrid graphics support under linux. I followed the directions for Ubuntu in the README that’s on the main project page, and everything installed just fine. Using the “optirun” command before my CUDA executable (e.g. “optirun hellocuda”), I was then able to run my CUDA programs. I can even run cuda-gdb (unlike on my desktop that has only a single Nvidia card), which made me feel that my tinkering had been worth it.

Hope this is of some help to others trying to get CUDA, Optimus and Linux to work.

Thanks for the info! I’ve been wondering if/when Optimus would be working for CUDA programs.

Thanks man, this worked for me! Had to use the most recent version of Bumblebee (found at https://github.com/Bumblebee-Project/Bumblebee), but now it works perfectly :)

I also have the similar problem.

I have a hybrid laptop and I want to use some matlab parallel computing functions, such as gpuArray()

but I get an error like this

Error using gpuArray (line 28)

No device supporting CUDA was found.

What can be the solution?

I have Acer 4830tg with nvidia 540m. I managed as well to get cuda working. Following the original poster. I did the following. First install the latest version of bumblebee and check it is working. Next I installed the 4.4 compiler. I did not uninstall the 4.6 compiler because it results in uninstalling bumblebee. I made links gcc --> gcc-4.4 and and g++ --> g+±4.4. I followed the other step which are require to install cuda on ubuntu 11.10 and installed all the other stuff required. At the end I installed the nvidia developer driver ( I got errors like device not supported, but I just passed over). At the end I did not update the X configuration files. Now install the cudatoolkit and compile the examples. Run the cuda programs with optirun.

I had to reinstall 4 time ubuntu today (lucky me i have an ssd) because I messed up the nvidia driver installation and the compilers. the latest version of bumblebee si somehow linked to gcc-4.6. removing gcc-4.6 will uninstall the bumblebee. So I kept it and install aside the 4.4 versions and used symbolic links to those. The commands gcc -v and g++ -v should give 4.4 in order to compile cuda programs.

For bumblebee follow this tutorial: http://www.ivegotavirus.com/blog/2012/01/23/installing-bumblebee-3-0-tumbleweed-on-ubuntu/ . Some instructions about installing cuda I took from here: http://blog.ryant.org/2011/12/installing-cuda-toolkit-on-ubuntu-1110.html and the main idea from the original poster.