Failed code 7052 with optixDeviceContextCreate

Hi there,
I came across with a weird error after upgrading the driver from 495.46 to 515.76 on RTX 3060. The error code says OPTIX_ERROR_CUDA_NOT_INITIALIZED, but it confuses me cause’ I have a CUDA context already. Is there something wrong with my following code? Thanks.

Sway

cudaSetDevice(0);//using device 0 for cuda context
CHECK_CUDA_ERROR()     
CUresult  cuRes = cuCtxGetCurrent(&cudaContext);
if( cuRes != CUDA_SUCCESS ) {
  printf("failed to get CUDA context!\n");
}
OptixDeviceContextOptions options = {};
options.logCallbackFunction       = &context_log_cb;
options.logCallbackLevel          = 1;
OPTIX_CHECK( optixDeviceContextCreate( cudaContext, &options, &optixContext ) );

Other info:
Ubuntu 20.04, CUDA 11.5, OptiX 7.3~7.5

Hi @sway, welcome!

Does this code work as-is with the older driver? (You can re-install the old one if you need.) You’re mixing the CUDA runtime API and the driver API here, it might be worth double-checking that it breaks if you switch to only runtime API CUDA calls. In our SDK samples, the CUDA initialization is typically done via a call to cudaFree(0) before using OptiX- does that style of CUDA initialization work for you?

Do you have multiple GPU devices in your system? (Looking at the cudaSetDevice(0) call, I’m curious if the hard-coded 0 is guaranteed to be correct on your system, or if the device ordering could have changed.)

Are you able to run a CUDA kernel before trying to initialize OptiX?


David.

Hi David,

Thanks for your suggestions. Finally, I found the issue. I wanted to ship my executable with the shared libs, so I put libcuda.so.515.76 and its symbolic link libcuda.so.1 alongside my executable. Now, I am sure the error is related to the module loading. But I didn’t find any major difference when I tried to ‘strace’ the lib loading.

The error can be reproduced by just copying libcuda.so.xxx and its symbolic link to the lib directory of SDK samples.

best,
Sway

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