Two kinds of compiling problem in my program with optix.

Hi I’m pretty immersed in optix, but I don’t know much.

Finally, I reached the final step in my project.
Of course, everything is not perfect until I reach the final stage.
Most of the work was done, but I have two problems.

The problems are:

1. compiling problem with optix.
2. how can I compiling .exe or .dll file without exposure or presence of .cu or .ptx file?

1. compiling problem with optix.

  • First of all, I wrote the code based on the “optix tutorial”.
    So, my program had a lot of dependencies on sutil.

  • Starting with the “load mesh” I asked before, I now implement most of the functions of “sutil” in my program(This is because my program uses a different format than the obj file.). So, I created a “.exe or dll file” that runs well without the “sutil” project. It worked fine on my computer.

  • I moved the exe file and the necessary dlls (optix 6.0.0 and ptx files, etc.) to another computer and ran the program. And It worked fine on my computer.

  • However, I moved the exe file and the necessary dlls (optix 6.0.0 and ptx file) to another computer and ran the program, but the execution failed.

  • My project’s properties are the same as the “optix tutorial” except the runtime library (/MT).

  • another Computer’s GPU is titanX and I used Optix6.0.0.

RE : how can I compiling .exe or .dll file?

2. how can I compiling .exe or .dll file without exposuring or existance .cu or .ptx file?

  • As described above, I wrote the code based on the “optix tutorial” (learned a lot in the optix forum). So I studied two ways to compile .cu files from OptiX SDK examples and OptiX Advanced Samples on github.

  • In detail, I know how to create a program using createProgramFromPTXString and createProgramFromPTXFile.

  • As a result, both of these methods require a “.cu file or a .ptx file”.

RE : I 'd like to know how to run the".exe file" without the presence or exposure of these files.

1.) If you followed this your example shouldn’t have a hard-coded dependency on the absolute folder locations where the OptiX SDK or Advanced Samples have been built anymore.

Your program should be printing errors of what prevents it from running to see what’s going on. Means if your program doesn’t run on another computer it should not be the folder locations but something else, like missing Visual Studio redistributables, but that should result in a message box or an entry inside the application system events. Hard to say without you providing a complete error message.

2.) If you can pre-compile all your *.cu device code to *.ptx input source for OptiX in your project using NVCC, you could store the resulting *.ptx files inside the application resources as strings and use rtCreateProgramFromPTXString instead of rtProgramFromPTXFile.

Or you could use bin2c.exe from the CUDA toolkit to convert them into char arrays in the code.

If you need to compile *.cu code at runtime, maybe because you’re generating high-level shading code in your application as CUDA source, you can use CUDA’s Runtime Compiler NVRTC instead of NVCC to compile the *.cu code to *.ptx input code at runtime.
That will not write any files and is actually faster than NVCC. You input a string and a get a string out.

If there are additional header files required to do that, those can also be stored inside the application’s resource or data segment and provided to the NVRTC as include options.
There is a whole tool to workaround those host header NVRTC issues (never used myself):

Here is an example of how I’m using it, though this is using CUDA, OptiX and my shaders’ headers from disk:

In either case, there is no need to ship *.cu or *.ptx as individual files. You can store them as data inside the application binary.

Unfortunately my code only prints the message “abort” from another computer.

Of course, I checked all the problems of visual studio and thought that it was not a problem of visual studio, but I was not sure.

I also think this problem can only be seen after further progress. Whatever the problem, it is the problem I’ve caused.

I may think that the second problem is also difficult because of the first problem.

  1. The second problem is both what I’m trying, and how I’m thinking in my mind, that’s consistent with the solution you’ve recommended.

To solve this problem, I figured out NVRTC compilation in “sutil.cpp” and “SampleConfig.h”, pulled out these parts separately, declared them as headers, and became dependent on NVRTC64_100.dll (CUDA 10.0).

The result was success.

But I still have questions from that success. Whether it could be run without being on another computer without a * .cu file or a * .ptx file.

I guess, because there are paths to existing files, such as “#define SAMPL_DIR” in “SampleConfig.h”, it seemed like a way to read the corresponding * .cu file every time I run “createProgramFromPtxString”. So I guessed that the * .cu file must be on another computer to run it there.

But I was only guessing because it failed to run on another computer.

My question is:

         [u]If I compiled NVRTC, do I not need the * .cu file on another computer?[/u]