CUDA-GDB fatal: All CUDA devices are used for X11 and cannot be used while deb

I’m having trouble trying to debug a simple piece of CUDA C code.

#include <stdio.h>

#include <stdlib.h>

#define N 256

__global__ void bitreverse(unsigned int *data)


	unsigned int *idata=data;


	unsigned int x=idata[threadIdx.x];

	x=((0xf0f0f0f0&x) >> 4 | ((0x0f0f0f0f&x) << 4));

	x=((0xcccccccc&x) >> 2 | ((0x33333333&x) << 2));

	x=((0x55555555&x) >> 1 | ((0x55555555&x) << 1));



int main(int argc, char **argv)


	unsigned int *d=NULL;int i;

	unsigned int idata[N],odata[N];


		idata[i]=(unsigned int)i;








	return 0;


I comile the c code :

nvcc -g -G -o test

I have three breakpoints at main, bitreverse and idata[threadIdx.x]=x.And then I run cuda-gdb test:

(cuda-gdb) run

Starting program: /home/uestc609/gdb/gdbtest1 

[Thread debugging using libthread_db enabled]

[New process 5755]

[New Thread -1216379184 (LWP 5755)]

[Switching to Thread -1216379184 (LWP 5755)]

Breakpoint 1, main (argc=1, argv=0xbfcc1584) at

23		unsigned int *d=NULL;int i;

(cuda-gdb) continue


fatal:  All CUDA devices are used for X11 and cannot be used while debugging. (error code = 24)

I am a novice with CUDA .Can someone tell me what the problem is ?

Thank you for the help!

The problem is that you can’t run cuda-gdb on a device while also using the same device to drive the display. (I think because the GPU is not multi-tasking.) There are several ways around this. One is just to shut down X and debug in a text mode console. (It’s said that you can also do this by switching to a text console, but I’ve never tried it.) More convenient, if you’re on a network, is to do a remote login to the CUDA machine (e.g. ‘xterm -e “ssh -X -l {username} {remote-machine}”’), shut down X on that machine (something like “service xdm stop” run as root, though you may be running gdm, kdm, etc as your display manager), and run cuda-gdb from the xterm.