# Failed code 7052 with optixDeviceContextCreate

**URL:** <https://forums.developer.nvidia.com/t/failed-code-7052-with-optixdevicecontextcreate/238373>\
**Category:** OptiX\
**Created:** [January 2, 2023, 2:31am UTC](https://forums.developer.nvidia.com/t/failed-code-7052-with-optixdevicecontextcreate/238373 "2023-01-02T02:31:58Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![sway](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@sway](https://forums.developer.nvidia.com/u/sway)\
**Post date:** [January 2, 2023, 2:31am UTC](https://forums.developer.nvidia.com/t/failed-code-7052-with-optixdevicecontextcreate/238373/1 "2023-01-02T02:31:58Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![dhart](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/dhart/32/14043_2.png) [@dhart](https://forums.developer.nvidia.com/u/dhart)\
**Post date:** [January 2, 2023, 5:35am UTC](https://forums.developer.nvidia.com/t/failed-code-7052-with-optixdevicecontextcreate/238373/2 "2023-01-02T05:35:25Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![sway](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@sway](https://forums.developer.nvidia.com/u/sway)\
**Post date:** [January 2, 2023, 8:15am UTC](https://forums.developer.nvidia.com/t/failed-code-7052-with-optixdevicecontextcreate/238373/3 "2023-01-02T08:15:26Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/system/32/68080_2.png) [@system](https://forums.developer.nvidia.com/u/system)\
**Post date:** [August 6, 2023, 8:39am UTC](https://forums.developer.nvidia.com/t/failed-code-7052-with-optixdevicecontextcreate/238373/4 "2023-08-06T08:39:28Z")

</div>

Closed on August 6, 2023, 8:39am UTC

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