optixDeviceCreateContext Error code 7051

Good Afternoon,

I am playing around with the SDK/optixPathTracer code using a multiple GPU machine. Everything is going well using DEVICE 0, however if I try and set the context to DEVICE 1 I get error code 7051.

The error output is shown below.

Optix call (optixDeviceContextCreate(cu_ctx, &options, &context)) failed with code 7051

The code where the problem appears to occur is shown below.

void AppScene::createContext() {

    OptixDeviceContext context;
    CUcontext cu_ctx = 0;

    // Set DEVICE:

    OptixDeviceContextOptions options = { };
    options.logCallbackFunction = &context_log_cb;
    options.logCallbackLevel = 4;
    OPTIX_CHECK(optixDeviceContextCreate(cu_ctx, &options, &context));
    state_.context = context;

I created an AppScene class that contains everything that optixPathTracer.cpp has. I did this just as a learning exercise to create the scene renderer as a class.

I am sure this is probably something dumb on my behalf but I cannot seem to find any information regarding the 7051 error.

Can anyone assist?


You can find code 7051 in optix_7_types.h in enum OptixResult :

after CUDA_CHECK(cudaSetDevice(device_id_));
you did not use “CUDA_CHECK”, so did it successfully set the device ?

after that you should also use:
CUresult cuRes = cuCtxGetCurrent(&cu_ctx);

and pass that cu_ctx to optixDeviceContextCreate() instead of 0

1 Like

The OptiX 7 API doesn’t know about multiple GPUs. You need to make sure the proper CUDA context is selected per device before doing any OptiX operation as m001 explained.

For OptiX 7 examples using multiple GPUs, have a look into the SDK examples optixMultiGPU and optixNVlink.

For more advanced OptiX 7 examples explicitly showing multi-GPU workload distribution with different buffer allocation methods, CUDA peer-to-peer data sharing via NVLINK or PCI-E bus, and different OpenGL interop methods detecting which active GPU runs the OpenGL implementation, have a look here and read the repository’s README.md carefully:

1 Like

Hi @m001

Thank you for the response. Sorry I took so long to reply, I got buried under another task.

I had wrapped the cudaSetDevice(device_id_) in the CUDA_CHECK macro but neglected to include it in the code I posted - sorry that was a mistake. The good thing though is that it was successful call.

I will give: CUresult cuRes = cuCtxGetCurrent(&cu_ctx); then passing cu_ctx to optixDeviceContextCreate a try. It is probably the problem.

Thank you again for the assist.

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