# RT\_CALLABLE\_PROGRAM not found in PTX

**URL:** <https://forums.developer.nvidia.com/t/rt-callable-program-not-found-in-ptx/76462>\
**Category:** OptiX\
**Created:** [June 15, 2019, 2:21am UTC](https://forums.developer.nvidia.com/t/rt-callable-program-not-found-in-ptx/76462 "2019-06-15T02:21:17Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![trevorblueburner](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@trevorblueburner](https://forums.developer.nvidia.com/u/trevorblueburner)\
**Post date:** [June 15, 2019, 2:21am UTC](https://forums.developer.nvidia.com/t/rt-callable-program-not-found-in-ptx/76462/1 "2019-06-15T02:21:17Z")

</div>

Using the cmake files attached to Ingo Wald’s Raytracing In a Weekend repo,  
I’ve been on to later chapters in the series.

When attempting textures, I have them represented as calling ProgramIDs in the materials

typedef rtCallableProgramId\<float3(float, float, float3, int)\> TextureFunction;

When compiling against sm\_30. The Texture functions are not found in the ptx (there is no visible function).

terminate called after throwing an instance of ‘optix::Exception’  
what(): Parse error (Details: Function “RTresult \_rtProgramCreateFromPTXString(RTcontext, const char\*, const char\*, RTprogram\_api\*\*)” caught exception: Function ‘sampleTexture’ not found in PTX)  
Aborted (core dumped)

Any documentation printed claims that an RT\_CALLABLE\_PROGRAM in a stand-alone cuda file should not be compiled away in \>sm\_20. So, I wouldn’t have expected a problem in sm\_30.

Well, the other solution is to create a dummy global function that calls the RT\_CALLABLE\_FUNCTION in the body of the cu file.

```auto
#include <optix.h>

rtDeclareVariable(float3, color, , );

RT_CALLABLE_PROGRAM float3 sampleTexture(float u, float v, float3 p, int i)
{
    return color;
}

rtDeclareVariable(float3, stub_constant_texture_return, , );
__global__ void stub_constant_texture_sample_texture()
{
    stub_constant_texture_return = sampleTexture(0.0f, 0.0f, make_float3(0.0f, 0.0f, 0.0f), 0);
}

```

Which, it no longer throws an error because the RT\_CALLABLE\_PROGRAM is maintained.

However, on further inspection, the code is behaving as if the inputs are always zeros.  
And on even further inspection, the code is behaving as if the inputs are constants set by the dummy global function.

My educated opinion is that the compiler is optimizing with the assumption that all inputs are constants set by the dummy global function.  
This is not what I want. I just want any RT\_CALLABLE\_FUNCTIONs in stand alone cu files to exist post compilation.  
I don’t even WANT the dummy global, but I’m out of ideas at this point.

---

<div class="post-metadata">

**Author:** ![droettger](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/droettger/32/14043_2.png) [@droettger](https://forums.developer.nvidia.com/u/droettger)\
**Post date:** [June 17, 2019, 7:05am UTC](https://forums.developer.nvidia.com/t/rt-callable-program-not-found-in-ptx/76462/2 "2019-06-17T07:05:51Z")

</div>

Please have a look at this thread and check your nvcc compiler options.  
[url][https://devtalk.nvidia.com/default/topic/1000376/optix/loading-callable-program-from-file-fails-with-rt\_invalid\_source/post/5111537/#5111537[/url]](https://devtalk.nvidia.com/default/topic/1000376/optix/loading-callable-program-from-file-fails-with-rt_invalid_source/post/5111537/#5111537%5B/url%5D)

Here is a related thread with compiler options for NVRTC instead of NVCC.  
[url][https://devtalk.nvidia.com/default/topic/1047572/optix/optix-compile-error-in-ptxstring/post/5316118/#5316118[/url]](https://devtalk.nvidia.com/default/topic/1047572/optix/optix-compile-error-in-ptxstring/post/5316118/#5316118%5B/url%5D)

---

<div class="post-metadata">

**Author:** ![trevorblueburner](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@trevorblueburner](https://forums.developer.nvidia.com/u/trevorblueburner)\
**Post date:** [June 18, 2019, 4:25am UTC](https://forums.developer.nvidia.com/t/rt-callable-program-not-found-in-ptx/76462/3 "2019-06-18T04:25:00Z")

</div>

Needed RDC

```auto
"--relocatable-device-code=true"

```

Thank you. But, I’m afraid I figured it out just before seeing this.

---

<div class="post-metadata">

**Author:** ![TomNVIDIA](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/tomnvidia/32/14181_2.png) [@TomNVIDIA](https://forums.developer.nvidia.com/u/TomNVIDIA)\
**Post date:** [June 14, 2022, 9:05pm UTC](https://forums.developer.nvidia.com/t/rt-callable-program-not-found-in-ptx/76462/4 "2022-06-14T21:05:43Z")

</div>


