Help me get started with OptiX (InvalidValue error when trying to run sample)

edit: See my latest post for my latest problem in my quest to get OptiX running.

I am trying to get started with OptiX, and trying to do so with the tutorial, but I am unable to get it to compile. I have simply imported the tutorial folder into Visual Studio as a project, and when trying to build it I get the error “Cannot open file GLUTDisplay.h : No such file or directory.”

Where should this file be? From searching the filename on google I get the impression that it is part of OptiX, (or at least something created by NVIDIA) but perhaps it is part of something else that I am missing? I do have CUDA, which I thought was the only OptiX prerequisite, but perhaps I am still missing something else? It isn’t a simple question of adding the right include directory, as the file isn’t anywhere on my machine.

GLUTDisplay.h is part of the OptiX SDK. Search your disk, that should turn up a GLUTDisplay.cpp and GLUTDisplay.h inside OptiX’ “SDK/sutil” folder. If not, something is not right with your OptiX installation.
It’s used by the OptiX SDK example framework to display ray traced images via an OpenGL texture.

The recommended way to build the OptiX SDK examples yourself is described inside the topmost CMakeLists.txt file you find in your OptiX SDK installation under “OptiX SDK /SDK/CMakeLists.txt”.
Do not use the individual CMakeLists.txt files inside SDK examples’ sub-folders to generate a solution. Those will miss the global setup done in that topmost SDK/CMakeListst.txt file.

If you use CMake and point it to that file, that should produce a solution for the compiler you selected with all provided examples inside. (Maybe ignore the ones using Cg, that’s discontinued anyway and those examples should be ported to GLSL at some time.)

GLUTDisplay.h is distributed with OptiX, and you can find it in C:\ProgramData\NVIDIA Corporation\OptiX SDK 3.8.0\SDK\sutil.

How did you go about importing the tutorial folder to Visual Studio? Did you use Cmake?

Edit: Detlef and I seem to have posted more or less the same thing simultaneously.

As the file definitely wasn’t there, I went through the OptiX installation process again, and this time I noticed the version of CUDA I have installed is incompatible with the Visual Studio version I’m forced to use (2008), which causes the building of OptiX-Samples to fail. I should have paid more attention to errors. Thanks for pointing me in the right direction, as I’m setting up a new PC and I was rather lost in figuring out where the missing file should have come from.

However, I have now found out that there does not seem to be a version of CUDA that works with Visual Studio 2008 (this seems to be CUDA versions up to 6.0) and supports my GTX 970 (CUDA versions from 6.5). Is there any workaround, or am I stuck hoping for my employer to upgrade Visual Studio?

I have tried to install CUDA 6.0 anyway, and while I can install it I still get errors (although different ones) when trying to build OptiX-Samples, presumably because of the incompatibility with my GPU, although it doesn’t state so as clearly as in the other case of incompatible VS. I’ve pasted a sample of the errors I get below (I get a long list of similar errors), just in case it might be something else. This is what I get when I open the solution Optics-Samples (as in step 7 of INSTALL_WIN.txt) and ask it to build.

48>------ Build started: Project: buffersOfBuffers, Configuration: Debug x64 ------
42>CMake Error at heightfield_generated_pinhole_camera.cu.ptx.cmake:235 (message):
42> Error generating C:/ProgramData/NVIDIA Corporation/OptiX SDK
42> 3.8.0/SDK/build/lib/ptx/heightfield_generated_pinhole_camera.cu.ptx
42>Project : error PRJ0019: A tool returned an error code from “Building NVCC ptx file lib/ptx/heightfield_generated_pinhole_camera.cu.ptx”
43>CMake Error at glass_generated_triangle_mesh_iterative.cu.ptx.cmake:235 (message):
42>Build log was saved at “file://c:\ProgramData\NVIDIA Corporation\OptiX SDK 3.8.0\SDK\build\heightfield\heightfield.dir\Debug\BuildLog.htm”

“Is there any workaround, or am I stuck hoping for my employer to upgrade Visual Studio?”

You can translate CUDA files to PTX with older toolkit versions.
It’s not necessary to match the streaming multiprocessor (SM) target version to your installed hardware.
OptiX parses the PTX code and rewrites it as long as the SM target inside the source PTX is lower than what OptiX supports, which is what the CUDA version supports OptiX itself was built with.
Which one that is, can be found inside the OptiX Release Notes, which is mandatory to be read before setting up an OptiX development environment.

In short, you could use SM 2.0 as PTX target instead of the SM 5.2 version your Maxwell board supports and still develop OptiX programs.
Though I would recommend to get an MSVS 2012 or 2013 for OptiX 3.8.0 development work.
MSVS 2015 is not supported by any released CUDA Toolkit version, yet, so if you upgrade, don’t go too far.

I can’t say what the errors are you list. There shouldn’t be “CMake Errors” at that point.

The instructions in that INSTALL-WIN.TXT are what I would have given as well, except for the 32-bit builds. Just don’t use 32-bit targets. The current CUDA Toolkit don’t support that for most configurations, it doesn’t make sense for ray tracing on the GPU anymore, and won’t be supported in the next major OptiX version.

What if you unload all projects from the solution except sample5 and sample5pp. Do they build and run?

If yes, you have a working setup.
The errors in the heightfield example would need to be analyzed individually.

Thanks for the help. Luckily, it turned out that my company is about to switch to Visual Studio 2013, and unbeknownst to the person I asked last week we already have some licenses. I am now able to compile without errors, but still cannot get any of the samples to run, and I still don’t really know where to look for the problem.

I am still simply following the INSTALL_WIN instructions (so I opened the OptiX-Samples solutions file from my build directory in VS). I’ve chosen sample 5 as my ‘start up project’, and everything seems to compile fine, but when I try to run it I get a bunch of errors. When I start debugging, I first get a popup telling me that ‘sample 5 - debug x64’ is out of date, asking me whether I want to build it. Regardless of my choice, I then briefly see a terminal window pop up, but it disappears again very quickly. The debug output looks as follows:

First I get a large number of “Cannot find or open PDB file” errors, which the internet tells me isn’t anything to worry about. Towards the end of these a couple of threads exit with code 0 (seems fine to me), then I get this error, which seems to be the real problem:
First-chance exception at 0x000007FEFD8CB16D in sample5.exe: Microsoft C++ exception: optix::shared::InvalidValue at memory location 0x000000000026D820.
After that a couple of threads quit with exit code 1, and finally the program quits with exit code 1.

Trying a different sample gives the same results (although sometimes exit codes 1 are replaced by 2), as does onloading all projects except sample5 and 5pp

I don’t really have any clue on where to start with this invalid value error, since this is supposed to be working code, and I was just hoping to start with something that already works and then play around with it to start learning the basics of OptiX / CUDA. But please let me know if I’m missing an obvious way to get more information - I only recently started working with Visual Studio in the first place, and I’m more physicist than developer.

Now that you’re using MSVS 2013, which CUDA Toolkit did you install?
I would recommend to use CUDA Toolkit 7.0 or 6.5 with OptiX 3.8.0.
CUDA 6.0 doesn’t support MSVS 2013. CUDA 7.5 is not yet supported by released OptiX versions.

Taking a step back.
Is your system capable to run the original OptiX SDK-precompiled-samples binaries?
Open a command prompt and change directory to that, run sample3.exe, which is similar to the deviceQuery.exe example which ships with the CUDA Toolkits.
It gives information about the installed GPU(s).

Now run the pre-compiled sample5.exe.
That should ray trace a sphere with shading according to the normal vector.

If that is not working there is an issue with your system setup.
What is your system configuration?
OS version and bitness, installed GPU(s) display driver version?

If this is on an Optimus capable laptop (GTX 970M?), make sure to use the discrete NVIDIA GPU.
Check if there is an option in the NVIDIA display driver control panel to force the discrete GPU then.

If all is working with the pre-compiled binaries, please follow the instructions inside the topmost SDK/CMakeLists.txt to build the examples and add own in the future, esp. the part of copying the necessary DLLs.

Build sample3 and sample5 yourself as release build first.
Open another command prompt and change directory to your executable’s folder.
Try to run your sample3.exe and sample5.exe there.
If there is any message about missing DLLs, copy the respective DLLs from OptiX SDK-precompiled-samples into your folder until these errors are gone.

Does it run now?

Repeat the same steps with the debug builds.

Now try to start own sample3.exe and sample5.exe debug and release builds from the debugger.
Do they work now?
If not, step through the program with F11 and F10 to find the line which fails.
Again, if this is an Optimus system, the executables need to be run on the discrete NVIDIA GPU.

Other things which won’t work is accesseing the system via standard Remote Desktop. That won’t have access to the GPU.

This is all I can think of with the given information. This is really meant to work when following the SDK/CMakeLists.txt instructions exactly.

It turns out I’m an idiot - after getting the newer version of Visual Studio I just installed the newest version of CUDA without looking at the requirements of OptiX again. Thanks for your extremely thorough help - if I get any more errors I don’t understand I’ll be sure to read back through your posts here for pointers.

Too easy! ;-)

My recommended approach to learn the OptiX API by working through the SDK examples is described in this post: https://devtalk.nvidia.com/default/topic/550862/?comment=3847704

Happy coding!