tex2D exits kernel

Hi everyone,

I have gotten my hands on a kernel which worked just fine (or seemed to anyway) on cuda 2.0. However, upon switching to cuda 2.1 calls to tex2D constantly fail - basically the kernel would simply exit (aka: break out/return) at that very function call, without any error flag set.
Unfortunately the kernel is fairly large and I am currently looking for input as to how to debug this.
Has anyone ever heard of something like this happening?

This happens both in emulation & device mode on at least a GeForce 8800 GTX and a Quadro FX 5600. If in device mode, it seems to happen less often - though still quite a few times. Furthermore it happens more often on the Quadro FX 5600 than the GeForce 8800 GTX.

Would love to get any advice on this.

Kind regards,

Are you positive there is no error flag set? Have you explicitly put:


error = cudaGetLastError()

if (error != cudaSuccess)

   print error

after your kernel?

One case where I can think of this occuring would be if your texture is not bound. Or if you bound it with with the wrong bind comand (the one for tex1Dfetch).

Yes, I always check with:

int errorCode = cudaThreadSynchronize();

	if (errorCode != cudaSuccess)

		printf("cuda error: %d\n", errorCode);

Now I’m not sure what tex1Dfetch uses as a bind command, however I use the following for tex2D:

texture<float4, 2, cudaReadModeElementType> myTex;

cudaChannelFormatDesc channelDescFloat4 = cudaCreateChannelDesc(32, 32, 32, 32, cudaChannelFormatKindFloat);

rc = cudaBindTextureToArray(myTex, myCudaArray, channelDescFloat4); assert(rc == cudaSuccess);

[...tex2D here...]


I’m used to get real kernel errors (and not silent failures) when accessing a texture which is unbound though - so I figured thats not it.

I also made sure the texture is defined & bound inside the same compiled unit as its being used from.

Kind regards,


Looks like you have all the bases covered. I don’t have any further ideas.