CUDA Pro Tip: Kepler Texture Objects Improve Performance and Flexibility

Originally published at: https://developer.nvidia.com/blog/cuda-pro-tip-kepler-texture-objects-improve-performance-and-flexibility/

The Kepler architecture introduces texture objects, a new feature that makes textures easier to use and higher performance. Texture References Textures are likely a familiar concept to anyone who’s done much CUDA programming. A feature from the graphics world, textures are images that are stretched, rotated and pasted on polygons to form the 3D graphics…

Hi,

There are a couple of bugs in this code: viz. the case of token cudatextureObject_t should actually be cudaTextureObject_t, there are invalid symbols such as a double quote in kernel launch code.

Importantly, upon trying this code my compiler complains :

error: more than one instance of overloaded function "tex1Dfetch" matches the argument list:
Making a similar setup for 2D texture, I get:
error : more than one instance of overloaded function "tex2D" matches the argument list:

My platform is:

Windows 7, Visual Studio 2012, NVIDIA Nsight 3.2, CUDA 5.5 Runtime Project, Debug Compile, compute capability set to compute_35,sm_35
GK110 Card (GTX 780), Intel i7.

Hi,

After I added a template type to "tex1Dfetch", I could compile the code above.

I mean,

float x = tex1Dfetch(tex, i);

should be

float x = tex1Dfetch<float>(tex, i);

I hope this helps you :-)

My platform is:

Windows 7, Visual Studio 2012, CUDA 5.5, Release Compile, compute capability set to compute_35,sm_35

The code snippets in the blog post have now been rectified. Thanks for posting.

Hey,

We just bought a PC with NVIDIA card and are trying to run different example code from different sources. We ran into trouble now with the command:

cudaCreateTextureObject(&tex, &resDesc, &texDesc, NULL);

It seems that in our computer the function fails to assign a value to "tex".
When adding an assertion in the next line:
assert(tex != 0);

the assertion fails.
We have also tried to surround the object creation command with checkCudaErrors() in hope to get more information, but it gives no error message (so the program thinks everything is fine).

Could you help us sort it out? We really have run out of ideas here and we have not found any hints online either.

Our system specs:
Ubuntu 14.04
GeForce GTX 750
Driver Version: 331.62
Cuda toolkit 6.0
compiling with parameter "--gpu-architecture sm_50"

PS! Also worth mentioning that we have a large-scale example using Cuda via
python/pylearn2/Theano running without problems. So in other cases out Cuda works fine and thus it seems a very specific issue.

I have the same problem on MacBook Pro with GTX 750M. Cuda 6.5

Submitted a bug report in Cuda Zone, also mentioned that it does not work on your system. I will let you know if we get help from there. Hope for the best.

Can you provide the bug ID number?

Bug ID is 1562891

I looked at the bug, and our QA was able to reproduce the problem. It is now being investigated. Sorry for the inconvenience, we'll resolve it as soon as we can.

Please inform us as soon as any progress is made on fixing the bug, so we could plan our work.