NVRTC Compilation failed

Hi!

I am working on an OptiX 7.5-based wrapper library. However, adding the library in cmake project, the build is success but whenever I am running the code-base and calling functions from the library it is returning error:

/home/UserDirectory/Desktop/rt_mpi_viewer/cmake-build-release/bin/rt_mpi_viewer
[ 4][       KNOBS]: All knobs on default.

[ 4][  DISK CACHE]: Opened database: "/var/tmp/OptixCache_luciaUserDirectoryno/optix7cache.db"
[ 4][  DISK CACHE]:     Cache data size: "204.4 MiB"
terminate called after throwing an instance of 'std::runtime_error'
  what():  NVRTC Compilation failed.
/home/UserDirectory/Desktop/rt_mpi_viewer/rt_mpi_viewer/cuda/../../prayground/prayground.h(45): catastrophic error: cannot open source file "optix.h"

1 catastrophic error detected in the compilation of "/home/UserDirectory/Desktop/rt_mpi_viewer/rt_mpi_viewer/cuda/raygen.cu".
Compilation terminated.

System Configuration:

OS: Ubuntu 22.04 LTS
Driver Version: 515.65.01   
CUDA Version: 11.7
GPUs: RTX 3080 + RTX 3090

Any Suggestion?

Hi @_Bi2022,

It looks like your run-time compilation needs to specify the include path to the OptiX SDK?

Here are some docs to the compile options you can pass to nvrtc: NVRTC (Runtime Compilation) :: CUDA Toolkit Documentation


David.

1 Like

Sorry to bother. It was somehow CMake error. I wondered because I could see the library could have the optix.h header, and it build success. Now I have solved this problem and working fine. Thanks for your suggestion.

I start getting another error now:

[ 4][  DISK CACHE]: Opened database: "/var/tmp/OptixCache_luciano/optix7cache.db"
[ 4][  DISK CACHE]:     Cache data size: "210.2 MiB"
terminate called after throwing an instance of 'std::runtime_error'
  what():  NVRTC Compilation failed.
/home/luciano/NVIDIA-OptiX-SDK-7.5.0-linux64-x86_64/include/optix_7_device.h(36): catastrophic error: #error directive: Device code for OptiX requires at least C++11. Consider adding "--std c++11" to the nvcc command-line.

1 catastrophic error detected in the compilation of "/home/luciano/Desktop/rt_mpi_viewer/rt_mpi_viewer/cuda/raygen.cu".
Compilation terminated.

I found one relevant problem here , unfortunately didn’t help me.

I have a prayground_config.h.in file which indicated in the CMakeLists root as configure_file(prayground_config.h.in prayground_config.h ) The prayground_config.h.in looks like this:


#pragma once

#define RT_MPI_VIEWER_PTX_DIR "@RT_MPI_VIEWER_PTX_DIR@"
#define RT_MPI_VIEWER_CUDA_DIR "@RT_MPI_VIEWER_CUDA_DIR@"

// Include directories
#define RT_MPI_VIEWER_RELATIVE_INCLUDE_DIRS @RT_MPI_VIEWER_RELATIVE_INCLUDE_DIRS@
#define RT_MPI_VIEWER_ABSOLUTE_INCLUDE_DIRS @RT_MPI_VIEWER_ABSOLUTE_INCLUDE_DIRS@

// Signal whether to use NVRTC or not
#cmakedefine01 CUDA_NVRTC_ENABLED

// NVRTC compiler options
#define CUDA_NVRTC_OPTIONS @CUDA_NVRTC_OPTIONS@

The Build is a success, but I cannot see the -std c++11 in prayground_config.h in build folder. I Guess that is the problem. It looks like this:

...
// NVRTC compiler options
#define CUDA_NVRTC_OPTIONS  \
 "-arch", \
 "compute_60", \
 "-use_fast_math", \
 "-lineinfo", \
 "-default-device", \
 "-rdc", \
 "true", \
 "-D__x86_64",

To add the "--std c++11" in #define CUDA_NVRTC_OPTIONS \ , in CMakeLists Root file I did something like this, especially see the second code snippet:

if(NOT PASSED_FIRST_CONFIGURE)
	list(FIND CUDA_NVCC_FLAGS "-arch" index)
	if(index EQUAL -1)
		list(APPEND CUDA_NVCC_FLAGS -arch sm_60 )
		set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} CACHE STRING "Semi-colon delimit multiple arguments." FORCE)
	endif()

	# bm (c++11 for cuda nvcc command line )
	set(flag "--std c++11")#"--std c++11")
	list(FIND CUDA_NVCC_FLAGS ${flag} index)
	if(index EQUAL -1)
		list(APPEND CUDA_NVCC_FLAGS ${flag})
		set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} CACHE STRING "Semi-colon delimit multiple arguments." FORCE)
	endif()


	set(flag "--use_fast_math")
	list(FIND CUDA_NVCC_FLAGS ${flag} index)
	if(index EQUAL -1)
		list(APPEND CUDA_NVCC_FLAGS ${flag})
		set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} CACHE STRING "Semi-colon delimit multiple arguments." FORCE)
	endif()

	set(flag "-lineinfo")
	list(FIND CUDA_NVCC_FLAGS ${flag} index)
	if(index EQUAL -1)
		list(APPEND CUDA_NVCC_FLAGS ${flag})
		set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} CACHE STRING "Semi-colon delimit multiple arguments." FORCE)
	endif()

	if (CUDA_VERSION VERSION_LESS "3.0")
		set(flag "--keep")
		list(FIND CUDA_NVCC_FLAGS ${flag} index)
		if(index EQUAL -1)
			list(APPEND CUDA_NVCC_FLAGS ${flag})
			set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} CACHE STRING "Semi-colon delimit multiple arguments." FORCE)
		endif()
	endif()

...

#  ERROR: catastrophic error: #error directive: Device code for OptiX requires at least C++11. Consider adding "--std c++11" to the nvcc command-line.
	if(CMAKE_CXX_STANDARD GREATER 20)
		set(RT_MPI_VIEWER_NVRTC_CXX "-std=c++20")
	else()
		set(RT_MPI_VIEWER_NVRTC_CXX "")
	endif()
	set(CUDA_NVRTC_FLAGS ${RT_MPI_VIEWER_NVRTC_CXX} -arch compute_60 -std c++11 -use_fast_math -lineinfo -default-device -rdc true -D__x86_64 CACHE STRING "Semi-colon delimit multiple arguments." FORCE)
endif(NOT PASSED_FIRST_CONFIGURE)

mark_as_advanced(CUDA_NVRTC_FLAGS)

...
# Build a null-terminated option list for NVRTC
set(CUDA_NVRTC_OPTIONS)
foreach(flag ${CUDA_NVRTC_FLAGS})
	set(CUDA_NVRTC_OPTIONS "${CUDA_NVRTC_OPTIONS} \\\n \"${flag}\",")
endforeach()
set(CUDA_NVRTC_OPTIONS "${CUDA_NVRTC_OPTIONS}")

Any suggestion?

Have you searched the OptiX SDK 7.5.0 files for CUDA_NVRTC_FLAGS and CUDA_NVRTC_OPTIONS?
None of them is using a space between -std and c++11.

Are you perhaps just missing the = in -std=c++11?

I mean this in OptiX SDK 7.5.0\SDK\CMakeLists.txt

  if(CMAKE_CXX_STANDARD EQUAL 11)
    set(SAMPLES_NVRTC_CXX "-std=c++11")
  else()
    set(SAMPLES_NVRTC_CXX "")
  endif()
  set(CUDA_NVRTC_FLAGS ${SAMPLES_NVRTC_CXX} -arch ${CUDA_MIN_SM_COMPUTE_TARGET} -use_fast_math -lineinfo -default-device -rdc true -D__x86_64 CACHE STRING "Semi-colon delimit multiple arguments." FORCE)

Here’s a similar definition of the CUDA_NVRTC_OPTIONS with the -std=c++11
https://forums.developer.nvidia.com/t/compile-error-failed-to-create-pipeline-optix-with-no-further-information-in-logs/205189/3

1 Like

Nope, I made a very silly mistake. See here in the code, I thought it is the general C++ version I am using will work with NVRTC

if(CMAKE_CXX_STANDARD GREATER 20)
		set(RT_MPI_VIEWER_NVRTC_CXX "-std=c++20")
	else()
		set(RT_MPI_VIEWER_NVRTC_CXX "")
	endif()

I also redefined the same in earlier snippet,

	set(flag "--std c++11")#"--std c++11")
	list(FIND CUDA_NVCC_FLAGS ${flag} index)
	if(index EQUAL -1)
		list(APPEND CUDA_NVCC_FLAGS ${flag})
		set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} CACHE STRING "Semi-colon delimit multiple arguments." FORCE)
	endif()

That did not work. So, redefine these so far working for now. Thanks for your suggestions.

-if(CMAKE_CXX_STANDARD GREATER 20)
-set(RT_MPI_VIEWER_NVRTC_CXX "-std=c++20")
+if(CMAKE_CXX_STANDARD GREATER 11)
+set(RT_MPI_VIEWER_NVRTC_CXX "-std=c++11")

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.