You are not logged in.

#1 2012-02-02 15:06:24

kyoko
Member
Registered: 2012-01-06
Posts: 18

[SOLVED] Debugging CUDA with Nvidia Optimus

Hello everybody.
I use my laptop with nvidia optimus technology for CUDA coding. Applications run fine with bumblebee/optirun but debugger (cuda-gdb) doesn't work. I guess the issue is that bumblebee connects discrete adapter to some X server but cuda-gdb requires a device which is not used for display. So I wonder is there some way to activate discrete nvidia adapter without starting X server?
P.S. I'm relatively new in linux so my question may by dumb.

Last edited by kyoko (2012-02-02 18:48:18)


Sorry for my English

Offline

#2 2012-02-02 18:47:43

kyoko
Member
Registered: 2012-01-06
Posts: 18

Re: [SOLVED] Debugging CUDA with Nvidia Optimus

It looks like I've found some dirty trick that allows debugging:
On virtual console 1: optirun cuda-gdb some-executable -tui
On virtual console 2: killall X
Then switch back to virtual console 1 and run application.  My question was dumb as predicted tongue


Sorry for my English

Offline

#3 2012-02-07 04:38:30

santiagordgz
Member
Registered: 2012-02-07
Posts: 2

Re: [SOLVED] Debugging CUDA with Nvidia Optimus

Another Solution

Hi,

I look into this issue today and I found another solution. As long as you have Bumblebee installed (http://www.bumblebee-project.org/) and you know you can attach optirun to an executable (try with glxgears for example) you can attach it to cuda-gdb.

What I did is create a script:

#!/bin/bash
optirun /usr/local/cuda/bin/cuda-gdb $*

And save it to /usr/local/cuda/bin or somewhere else it doesn't matter, with the appropriate permissions for execution (755).
What it does is very simple, it runs optirun cuda-gdb args where args is whatever the command line sends it.
In terminal just run opti_cuda-gdb with o without arguments.

For example I named it opti_cuda-gdb and placed it in the afore mentioned directory (which conveniently is added to the path if CUDA is properly configured).
If you use an IDE to develop, like say Netbeans, point the debbuger executable to that script.
I've been successfully compiled and debbuged code using CuSparse and CuBlas with Netbeans running in a SAMSUNG SF410 with Nvidia Optimus and Ubuntu 11.04 and 11.10.

I'm open to provide further details if you think I ommited something.

I just find a way arround and couldn't find a better place to post this in case anybody needs it.

Offline

#4 2012-02-07 07:25:35

kyoko
Member
Registered: 2012-01-06
Posts: 18

Re: [SOLVED] Debugging CUDA with Nvidia Optimus

Hi, santiagordgz.
First of all thanks for replying. But I'm a bit surprised that your script works smile. Do I understand correctly that it just spawns cuda-gdb with optirun?
In my case the issue was with message: "fatal:  All CUDA devices are used for display and cannot be used while debugging. (error code = 24)".
Can you post versions of your cuda toolkit and bumblebee?

P.S. I've made little script for killing bumblebee X server:
#!/bin/bash
kill $(ps ax|grep /usr/bin/X|grep bumblebee|cut -d " " -f2)


Sorry for my English

Offline

#5 2012-03-02 22:44:10

santiagordgz
Member
Registered: 2012-02-07
Posts: 2

Re: [SOLVED] Debugging CUDA with Nvidia Optimus

Sorry for the late late answer

I see.
According to the CUDA-GDB documentation debugging cannot take place on a device driving the X11 display. It makes a lot of sense.

In my setup the intel card is driving the X11 display and the nvidia card is always idle unless I start it with the optirun spawner.

Right now I have the 4.1 but it worked equally well on 4.0.
My bumblebee version is the one from The Bumblebee Project 3.0.
http://bumblebee-project.org/

What I did to setup both Intel and Nvidia working (because the NVIDIA developer driver overwrites some libraries needed by DRI) is install Nvidia Developer Driver, bumblebee and then reinstall DRI.

I don't remember exactly which packages to reinstall in order to make DRI work again, I'm at the lab right now, as soon as I get home I can provide that information.

Offline

Board footer

Powered by FluxBB