hello, I’m relatively new to CUDA and am having trouble using textures.
Specifically, my code compiles just fine, but during runtime, a call to cudaBindTextureToArray fails with the error: “invalid texture reference”.
The code up to that point is as follows:
texture<float, 2, cudaReadModeElementType> inputTexture; // located near beginning of file after #includes and #defines
… // code below located inside a function declared extern “C”
unsigned int timer = 0;
//Copy image data to a texture on the GPU
channelDesc = cudaCreateChannelDesc();
zeroArray = (float *) calloc ((ImgHeight + 2) * (ImgWidth + 2), sizeof (float));
CUDA_SAFE_CALL (cudaMallocArray(&cuArray, &channelDesc, (ImgWidth + 2) , (ImgHeight + 2)));
CUDA_SAFE_CALL (cudaMemcpy2DToArray(cuArray, 0, 0, zeroArray, (ImgWidth + 2) * 4, (ImgWidth + 2) * 4, ImgHeight + 2, cudaMemcpyHostToDevice));
CUDA_SAFE_CALL (cudaMemcpy2DToArray(cuArray, 4, 1, input, ImgWidth * 4, ImgWidth * 4, ImgHeight, cudaMemcpyHostToDevice));
CUDA_SAFE_CALL (cudaBindTextureToArray (inputTexture, cuArray)); // Program fails HERE!!
Previously, I had very similar code working just fine, but for some reason, it’s not working any more.
things that have changed since I had working code:
- I’ve bought a larger monitor, a 23 inch LCD display with a 2048x1152 resolution. (I’m not sure if this has anything to do with my problems.)
- I’ve installed the CUDA Wizard for Visual Studio (available via a link somewhere in the CUDA forums.)
I would appreciate any advice, hints, thoughts…