OptiX 7 Samples using NVRTC

I attempted to enable CUDA_NVRTC_ENABLED in the CMake config but the .cu files do not build (cannot find “optix.h”). Would it be possible to get a sample that compiles and runs an OptiX .cu file using NVRTC instead of the cmake build step?

I did attempt to add the OptiX headers in sampleConfig.h and also the “-std=c++11” option which seems to be required but I run into more issues from there.

I am having the same problem once I added the “-std=c++11” option. I’m trying to compile Ingo Wald’s example #2 devicePrograms.cu file

I included the directories I found in the vs2019 Custom Build Tool/Additional Dependencies for a .cu file.

#define INCLUDE_DIRS
“C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.22.27905/include”,
“C:/Program Files (x86)/Windows Kits/10/Include/10.0.17763.0/ucrt”,
“C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v10.1/include”,
“C:/ProgramData/NVIDIA Corporation/OptiX SDK 7.0.0/include/internal”,
“C:/ProgramData/NVIDIA Corporation/OptiX SDK 7.0.0/include”

And I get a lot of errors like this

C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.22.27905/include/sal.h(708): warning: unrecognized #pragma
C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.22.27905/include/sal.h(1472): warning: unrecognized #pragma
C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.22.27905/include/vcruntime.h(83): error: this declaration has no storage class or type specifier
C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.22.27905/include/vcruntime.h(83): error: identifier “push” is undefined
C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.22.27905/include/vcruntime.h(83): error: identifier “pack” is undefined
C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.22.27905/include/vcruntime.h(83): error: expected a “;”
C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.22.27905/include/vcruntime.h(184): warning: parsing restarts here after previous syntax error

I avoided including all those Windows and std headers. I made a local stddef.h for the .cu file to find when it includes optix.h:
#pragma once
#define LP64

Defining LP64 allows the use of 64 bit pointers. The samples will crash without it being defined.

That worked. Thank you for the help!

I tried to compile the OptixDemandTexture sample cuda files and hit another barrage of errors like the ones above because of the Windows and std headers.

There’s got to be a better way than to hack header files. Anybody know how it is that cmake can get around all this?. I’m not a fan of cmake to put it mildly … I poked around a bit in the .cmake files but couldn’t find anything that helped me understand how to make this work.

@Bird33, are you also trying to compile optixDemandTexture with CUDA_NVRTC_ENABLED? And it’s the OptiX 7 sample you’re building, not one of the OptiX 6 “DemandLoad” samples, correct?

We haven’t tried VS2019 on the OptiX team. Do you have access to VS2017?


David.

@dhart The samples don’t compile or run when CUDA_NVRTC_ENABLED is set in the cmake UI options. I am using VS 2015. However I have now been able to get the mesh rendering sample to work in my own project with the changes I mentioned. I have not tried the OptiX Demand Texture sample. The problem with the cmake .cu file compilation is that it obfuscates the options used to compile them and includes dozens of std and Windows headers that are unrelated to the files being compiled.

Hi David

I knocked off a Optix7Sandbox repository that shows the problems we’re having

https://github.com/Hurleyworks/Optix7Sandbox

Once you’ve got everything compiled, try running the sandbox/HelloPtx app and you’ll see all the compile errors because optix_7_types.h includes <stddef.h> and that brings in a bunch of windows and std headers that won’t compile

I made a little gui based tool for offline compiling using NVCC so one can compile Optix 7 programs without using camke, if anyone is interested.

It’s in the tools section here: https://github.com/Hurleyworks/Optix7Sandbox

It would be great to get the NVRTC issues straightened out though. Anybody have any luck?

Hey @Bird33,

We are working on this and getting it straightened out. The SDK will get an update at some point in the near future that adds support for building the OpitX 7 samples using NVRTC for the OptiX programs. Unfortunately, the fixes needed were a bit extensive and they probably aren’t going to make it out for the first official OptiX 7 release, but the next one should contain the updates. Thank you very much for reporting it, and also for your reproducer and your workaround samples, I’m sure others are going to find that very helpful!


David.