Is it possible to have more than one Optix context active in a single program ?

I have an existing working Optix program, and another working straw-man program adding new features, they cooperate in a loose fashion using CPU shared memory and can run on the same GPU or different ones, (each tied to just one GPU).

I am looking at bringing these closer together and started by writing a single program initialising two Optix contexts, but at a context compile stage i get error.

Unknown error assertion failed “cudaCTX->getInterop() == Interop” .

I get no search hits for this type of error and wonder if anyone here can shed light on the what the issue is.

I suppose the question boils down to “Is it possible to have more than one Optix context active in a single program”. I naively thought that as everything is tied to one context or other that it would be possible.

On a broader point, what would experts advise / what is possible, if I want a cooperating two Optix system, that can be run on one or two GPUs, so that buffers are only mapped to one GPU or other.

  • Two separate programs as I have now, possibly transferring data via DMA GPU copies.
  • A single program two threads, each thread tied to different Optix context/GPU s.
  • A single program one thread, two Optix contexts

The reason i am quite wedded to a two Optix context system is that I suspect will max out memory on a single GPU, and thus need to break the problem up, but again also want the design to work if both run on the same GPU.

Thanks for taking the time to read this.

The recommendation has always been to use only one OptiX context per process.

The programming guide is not really elaborate on that question.
Chapter 3.1 Context says “While multiple contexts can be active at one time in limited cases, this is usually unnecessary as a single context object can leverage multiple hardware devices.”

The first statement “in limited cases” needs to be read as “are generally not working”.
The rest of the sentence is about using multi-GPUs as handled by OptiX internally, which is not your case of breaking up the problem into custom digestible chunks per GPU.

Note that OptiX 4.0 has changed the multi-GPU implementation to allow more heterogeneous combinations as well. Using both GPUs in one context but breaking up the problem into digestible chunks overall would be another approach to get more performance out of multiple GPUs in the system.

Also see chapter 12. Caveats “Currently, OptiX is not guaranteed to be thread-safe. While it may be successful in some applications to use OptiX contexts in different host threads, it may fail in others. OptiX should therefore only be used from within a single host thread.”

Have a look at the chapter 7. Interoperatbility with CUDA in the programming guide to get a glimpse of how some things are structured underneath.

Detlef,

Thanks for the response, (i would have responded earlier but the site kept logging me out.)

Yes i had missed the line Chapter 3.1 “possible in limited cases” - if i had read it i would have been more curious as to why i am getting an error.

The error is happening at construction time so still a little curious to what it is down too,
i.e. might expect it to fail at a later due to it “not generally working” but early on at a rtCompile.

So should i wait for Optix 4.0 and use features that allow more complex combinations.
Alternatively does Optix Prime give me more flexibility.

Just read that Optix 4.0 removes sm 2.X support which is bit of a bummer as my main mobile machine has such a card.

Cheers.