OptiX 7.3: nvrtcCompileProgram reports all errors with line number 1

I have just started with the OptiX 7.3 triangle example that is using sutil. I want to do the cuda compilation in my own c++ code. I think I am not far from achieving this, but apparently compilation fails with the following log:

OptiX(1): error: this declaration has no storage class or type specifier
OptiX(1): error: expected a “;”
At end of source: warning: parsing restarts here after previous syntax error
2 errors detected in the compilation of “OptiX”.

The .cu file has multiple lines and so does the string containing its content.
How can I get correct line numbers to make some sense of the error messages?
As a side note: the compilation works when going over sutil. I still have to figure out why there is a difference and hopefully more precise errors will help for this.


Please add some more information about your development environment:
OS version, installed GPU(s), VRAM amount, display driver version, OptiX (major.minor.micro) version, CUDA toolkit version (major.minor) used to generate the input PTX, host compiler version.

The CUDA toolkit version number would be crucial for any NVCC or NVRTC errors like this.

1.) If that is CUDA 11.3, please try with CUDA 11.1 which is the version with which OptiX 7.3 has been built. (See the OptiX Release Notes before setting up a development environment.)
I recall issues with CUDA 11.3 in that respect and previous OptiX 7 headers. Not sure if that has been fully solved.

2.) If CUDA 11.1 also failed, try building the OptiX 7.3 SDK examples with the CMake build flag CUDA_NVRTC_ENABLED enabled.
Do the OptiX SDK example fail at runtime when that is enabled?
If yes, then the OptiX headers are still incompatible and need to be changed.

3.) If that worked, then more information would be required about how you setup your NVRTC compiler options.

It has been quite some time since I used NVRTC (before OptiX 7) and there are multiple posts on this forum which explain potential issues like selecting the wrong C++ version. Please have a look though all of these OptiX forum search results for NVRTC

I’m not what sutil has to do with that problem. You mean you’re using getPtxFromCuString() in there?
If you can’t get that code to work in your own application then I would also assume you used the wrong NVRTC compiler options.
You’d need the CUDA includes, the OptiX SDK includes and includes to all your own headers used inside OptiX device programs there plus some options selecting the correct architecture (64 bit only!).
Note that OptiX SDK build environment hardcodes some folder names into the sample executable which means they only work where they have been built (or you need to set two environment variables). That would be important to find the samples’ *.cu and include files.

Translating *.cu to *.ptx code should otherwise be straight forward. This is how I did it in the past: https://forums.developer.nvidia.com/t/optix-compile-error-in-ptxstring/70636/2

If you need an OptiX 7 framework which is not using sutil at all, then maybe have a look into my OptiX 7 examples CMakeLists.txt and *.cmake files. https://github.com/NVIDIA/OptiX_Apps

OS version: Windows 10.0.19041
installed GPU(s): Intel UHD Graphics, Nvidia Quadro RTX 5000
VRAM amount: 16GB
display driver version: 27.21.14
OptiX (major.minor.micro) version: 7.3.
CUDA toolkit version (major.minor): 11.3

  1. So, I will try with CUDA 11.1.
  2. the OptiX SDK CUDA_NVRTC_ENABLED is set in my setup - although I don’t remember having enabled this explicitly

Thanks for the quick reply. I will let you know, if it worked out.

display driver version: 27.21.14

That’s not a display driver version number I would recognize. If that is from some longer Windows information, the last five digits would be the display driver version number. Something like 466.xy for example.

The easiest way to get that, is to open the NVIDIA Control Panel and click on System Information in the lower right.

It is probably the Intel UHD Graphics version, I have it from the windows system information.
The nvidia display driver version is 466.11.

So far, it doesn’t work yet.

I uninstalled CUDA 11.2 and 11.3. Currently I have
CUDA Driver Version / Runtime Version 11.3 / 11.1

How can I downgrade the CUDA Driver version? or should that be unproblematic?

You don’t need to uninstall CUDA toolkit versions. You can have as many CUDA Toolkits installed in parallel on your system as you want.

There is an environment variable CUDA_PATH which points to the CUDA Toolkit you want to use. This is evaluated by most Tools, including CMake. It makes sense to control the PATH variable as well, but in OptiX examples only the CUDA_PATH is responsible for the CUDA toolkit selection and you can control which it picked in the CMake GUI CUDA variables.

When installing CUDA toolkits, I normally use the web based installer and de-select everything related to the display driver included in there because that is always outdated as soon as there is an official display driver available which supports that CUDA toolkit version.
The CUDA drivers inside your installed display driver are backwards compatible, so if you have one installed which supports 11.3, then you can also run programs created with any previous CUDA toolkit.

In this case it’s all about the CUDA toolkit used to translate your *.cu source to *.ptx input for OptiX. No driver involved at that stage.

It wasn’t a problem to uninstall the other cuda versions. I currently don’t need them. Anyway thanks for the info.

Actually, I solved my wrong line numbers problem in the .cu compilation and was also able to fix the reported errors. It was a trivial programming error I overlooked on my side that is not worth reporting here. By the way, I don’t think it had anything to do with the newer versions of the different components. It was just a matter of sleeping over it and simply trying again.

Thanks for moral support and the hint to your examples.

Awesome. Too easy. ;-)