# invalid texture reference on cudaBindTextureToArray

**URL:** <https://forums.developer.nvidia.com/t/invalid-texture-reference-on-cudabindtexturetoarray/10202>\
**Category:** CUDA Programming and Performance\
**Created:** [June 17, 2009, 12:53pm UTC](https://forums.developer.nvidia.com/t/invalid-texture-reference-on-cudabindtexturetoarray/10202 "2009-06-17T12:53:16Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![schildirulez](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@schildirulez](https://forums.developer.nvidia.com/u/schildirulez)\
**Post date:** [June 17, 2009, 12:53pm UTC](https://forums.developer.nvidia.com/t/invalid-texture-reference-on-cudabindtexturetoarray/10202/1 "2009-06-17T12:53:16Z")

</div>

Hi,

I have a weird behavior with my CUDA program.

Running my program in debug mode is all fine.

Running my program in release mode crashes with a invalid texture reference error.

The problem occures at cudaBindTextureToArray:

```auto
bool BindTextureToArray(void*image, unsigned int width, unsigned int height, int imageNumber)

{

	cudaChannelFormatDesc channelDesc = cudaCreateChannelDesc<uchar4>();

	

	cudaMallocArray ( &ImageArray[imageNumber], &channelDesc, width, height ); 

	cudaMemcpyToArray( ImageArray[imageNumber], 0, 0, image, sizeof(unsigned char)* width * height * 4, cudaMemcpyHostToDevice)); 

	cudaBindTextureToArray(image0, ImageArray[imageNumber], channelDesc);

	if(checkCUDAError("BindTextureToArray: cudaBindTextureToArray\n") == false)

		return false;

	return true;

}

```

```auto
cudaArray* ImageArray[NumberOfImages];

void* image points to a unsigned char pointer on the data

```

I can not image why this happens only in release mode.

Could it be because I split my code in several files?

texture global declare in: gpu\_global.h

texture defined in: gpu\_init.cu

BindTextureToArray in: gpu.cu

But i tried to push all my code in one file, but nothing changed.

Should i change to another Cuda Version? 2.0 or 2.2?

Or another driver version?

I would appreciate any advice, hints, thoughts…

thanks!

Hendrik

My computer configuration:

Quadro FX 3600M (notebook graphic card)

DirectX Version: 10

Driver Version: 185.85

compute capability: 1.1

Cuda compilation tools, release 2.1, V0.2.1221
