[Help] cudaBindTexture forever returns 'InvalidTexture'

Hi~~
here is my test program:

#include <cuda.h>
texture tex;
int main()

{

unsigned char* pArray;

int size = 100 * 100 * 4;

cudaError error = cudaMalloc(&pArray,size);

size_t offset = 0;

error = cudaBindTexture(&offset,tex,pArray,size); //Here returns 'invalid texture'

error = cudaUnbindTexture(&tex);

cudaFree(pArray);

return 0;

}

And it was compiled by the following command:
(CUDA_BIN_PATH)\nvcc.exe" -ccbin "(VCInstallDir)bin” -c -arch sm_13 -D_DEBUG -DWIN32 -D_CONSOLE -D_MBCS -Xcompiler /EHsc,/W3,/nologo,/Wp64,/Od,/Zi,/RTC1,/MTd -I…/SDK/CUDA/include -I…/ -I…/Include -I…/GPU -I./ -o (ConfigurationName)\main.obj (SolutionDir)\cudaTexTest\main.cu

However, the cudaBindTexture function forever returns InvalidTexture. How can I resolve this problem? thanks!

Your code works for me, no errors.

I compiled it with nvcc test.cu -I/usr/local/cuda (linux)

With this error, you might want to check if you are compiling for the correct hardware architecture, i.e. not computing for sm_11 with sm_10 hardware.