# \[Help\] cudaBindTexture forever returns 'InvalidTexture'

**URL:** <https://forums.developer.nvidia.com/t/help-cudabindtexture-forever-returns-invalidtexture/12996>\
**Category:** CUDA Programming and Performance\
**Created:** [October 28, 2009, 6:51am UTC](https://forums.developer.nvidia.com/t/help-cudabindtexture-forever-returns-invalidtexture/12996 "2009-10-28T06:51:31Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![xiaoshun](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@xiaoshun](https://forums.developer.nvidia.com/u/xiaoshun)\
**Post date:** [October 28, 2009, 6:51am UTC](https://forums.developer.nvidia.com/t/help-cudabindtexture-forever-returns-invalidtexture/12996/1 "2009-10-28T06:51:31Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![gshi](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@gshi](https://forums.developer.nvidia.com/u/gshi)\
**Post date:** [November 3, 2009, 3:09pm UTC](https://forums.developer.nvidia.com/t/help-cudabindtexture-forever-returns-invalidtexture/12996/2 "2009-11-03T15:09:31Z")

</div>

Your code works for me, no errors.

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

> [@](#):
>
> 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!

---

<div class="post-metadata">

**Author:** ![Ailleur](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@Ailleur](https://forums.developer.nvidia.com/u/Ailleur)\
**Post date:** [November 3, 2009, 4:57pm UTC](https://forums.developer.nvidia.com/t/help-cudabindtexture-forever-returns-invalidtexture/12996/3 "2009-11-03T16:57:15Z")

</div>

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.
