Unknown error :rtProgramCreateFromPTXFile caught exception: Assertion failed:[11403396]

When I compile my Optix project, it came out the error described above. I debug the code and found the value of parameter named code to be -1 in function void sutilHandleError(RTcontext context, RTresult code, const char* file, int line).

How can I deal with the problem?

That’s hard to answer without any details about your development environment and the nvcc command line used to generate the PTX code.
Check if your development setup of OS, bitness, GPU(s), driver version, host compiler, OptiX version, and CUDA toolkit version matches the requirements in the OptiX Release Notes.
(For example, CUDA Toolkit 5.5 is not supported with OptiX 3.0.1. Do not let nvcc generate debug output.)
Are you otherwise able to compile and run any of the OptiX SDK examples?

There is nothing wrong with my hardware of software, I have compiled the SDK examples successfully with Visual Studio 2010. In fact what I did is like this.

I copied the SDK example2 code to my project, the project is a new builded one, I changed nothing but the ptx file generated from .cu file, which meant I congfigure the new project to make it can gennerate .ptx files for .cu files. The ptx files appeared when I compiled the project, but the exception described above came out too.
If I copied the ptx files from SDK example2 to my project,there is noting wrong with my new project, which means there may be someting wrong with the ptx files generated by Visual Studio 2010. What’s more, some strange tings happened, not all the ptx files generated with visual studio 2010 are wrong, for example, the ptx files associated with box.cu and constantbg.cu were right, and the ptx files associated with pinhole_camera.cu and phong.cu were wrong. And the ptx file generated from phong.cu was partially wrong, because the closest_hit_program was wrong, but the any_hit_program was right.

Yes, that is why I recomended to provide the CUDA compiler’s (nvcc) command line parameters which generate the PTX files.

Please compare the nvcc command lines used to compile the *.cu files in the original working SDK version and your own project.
Again, if that command line contains the parameter to generate debug information, OptiX might not handle the resulting PTX code. (That’s my current guess about your error.)

If you built your own project by duplicating one of the working SDK examples and used CMake to build the new project inside the SDK samples’ solution, the command line parameters should match.

[quote=“Detlef Roettger”]

Yes, that is why I recomended to provide the CUDA compiler’s (nvcc) command line parameters which generate the PTX files.quote]

I didn’t used command line to generate PTX file, I just used Visual studio 2010 to compile the .cu file. I configured its property of NVCC Compilation type with generate .ptx file. Then when I compile the project, it will generate .ptx file automatically. In this way, how could I solve the problem?

I didn’t used CMake to build the project. What I used is just Visual studio 2010, and I configured the project to make it can build the optix project, in fact I believe there is noting wrong with the configuration, because only the .ptx files were wrong, when I repalced the .ptx files with those from SDK, noting wrong happened.

Although Visual Studio manages the application projects inside its solution, *.cu files must be compiled by the NVIDIA CUDA Compiler named nvcc.exe to generate PTX code, normally in a custom build step.
That nvcc compiler gets a command line with parameters which is the important information here.

As you say you already have *.cu files using rules to generate PTX code, which have been properly added by the CUDA Toolkit 5.0 installation to Visual Studio then.

My guess is still that you have used different (unsupported) parameters than the original SDK build and that needs to be verified first.

If you say the original *.ptx files work and your own compiled *.ptx files don’t, there should be a visible difference between two matching PTX code files. Look at them inside an editor or diff tool. They should also contain some hints about the used command line parameters and the code bitness.

If you right-click on a *.cu file in your project and carefully analyze the build rules for these, you should have other specific nvcc settings available for that build. Only setting PTX output might not be enough. You should also be able to select the Streaming Multiprocessor version and maybe debug output.

If this is failing in the debug build, please check if it works in a release build.

The goal is to match these settings to the ones used in the original SDK example to get matching command line parameters resulting in identical PTX output.

Not all my ptx files generated from my project were wrong, there were four .cu files, they came from SDK example2, and the configuration of the four .cu files were same, and two ptx files were right and the others were wrong, it’s ridiculous. And I have also done the same thing for SDK example1, the ptx file generated sucessfully, and noting wrong with it, I just can’t understand why it happened.

I’m trying to solve the problem for a couple of days, but I didn’t find the answer, which made me depressed, and I have to stop my current work.

Thank you for your answer. I am a new learner, I didn’t know ptx file well, so I don’t know how to find the difference between the right ptx file and wrong ptx file. What’s more, I am not used to using comman line to generate ptx file, and I don’t know what parameters should be used in the command line.

Now I will upload a picture of my configuration for one of .cu file, the others are the same, Would you please help to check whether there is someting wrong. Thank you very much.

Like what Detleff have said,

Host->Generate Host Debug Information: Set it to “No”
Device->Generate GPU Debug Information: Set it to “No”

Thank you very much! The problem is solved.

Hi Detlef,

I have a similar problem.

When I compile ‘path_tracer.cu’ in path_tracer example though VS2010 and use the generated ptx file to run, it generates ‘Unknown error :_rtContextCompile caught exception: Assertion failed:[1312612]’. The original ptx file in SDK generated by cmake works.

The strange thing is that it works (although the result isn’t correct) whenever I comment all sinf() and cosf() calls. But other math functions like powf(), sqrtf() do not generate any exception.

Attached is my nvcc settings.(是=yes 否=no)

Please add --use-fast-math to your nvcc command line.
OptiX doesn’t handle the PTX code generated by the full precision trigonometric functions in all cases.

I tried to set --use-fast-math, but still got the same exception.

In addition, calling sinf(0.5f) does not generate exception, but sinf(phi) does. Where phi is a float variable generated by rnd(current_prd.seed).

It seems that all trigonometric functions only accept argument values that can be evaluated at compile time.

Definitely not. You said yourself “The original ptx file in SDK generated by cmake works.”
If you search for “–use_fast_math” inside the OptiX SDK *.txt files you will find it to be set globally for all nvcc invocations in OptiX SDK \SDK\CMakeLists.txt

Please set that flag on all your *.cu files’ compilation rules.

Thanks, I think I know what the problem is by reading https://devtalk.nvidia.com/default/topic/701674/optix/assertion-failed-quot-instr-gt-modifiers-cc-0-quot-/post/4156926/#4156926.

The command line is as follows after setting ‘use fast math’ option in VS:

(Approximate command-line. Settings inherited from host are not visible below.)

(Please see the output window after a build for the full command-line)

Driver API (NVCC Compilation Type is .cubin, .gpu, or .ptx)

set CUDAFE_FLAGS=–sdk_dir “C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A”
“C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v5.5\bin\nvcc.exe” --use-local-env --cl-version 2010 -ccbin “C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\x86_amd64” --keep-dir x64\Release -maxrregcount=0 --machine 64 -ptx -cudart static -o path_tracer.dir\Release\path_tracer.cu.ptx “D:\swl\Project\code\Optix\path_tracer\path_tracer.cu”

Runtime API (NVCC Compilation Type is hybrid object or .c file)

set CUDAFE_FLAGS=–sdk_dir “C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A”
“C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v5.5\bin\nvcc.exe” --use-local-env --cl-version 2010 -ccbin “C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\x86_amd64” --keep-dir x64\Release -maxrregcount=0 --machine 64 -ptx -cudart static -use_fast_math -Xcompiler "/EHsc /nologo /Zi " -o path_tracer.dir\Release\path_tracer.cu.ptx “D:\swl\Project\code\Optix\path_tracer\path_tracer.cu”

It seem that the option only applied to generating hybrid object or .c files but not ptx files. Do you know how I can actually set -use_fast_math flag in VS? I tried to put it in additional command line options, but it did not apply to ptx file generation.

Ok, I solved the problem by modifying C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\BuildCustomizations\CUDA 5.5.props.
%(BaseCommandLineTemplate) [CompileOut] “%(FullPath)”
=>
%(BaseCommandLineTemplate) [CompileOut] [FastMath] “%(FullPath)”