1

A library that I link to uses the cuda runtime API. Thus it implicitly creates a cuda context when first calling a cuda function.

My code (that uses the library) should use the driver API. Now, how can i get both (runtime and driver API) to work at the same time?

The library calls the cudaSetDevice function upon library init. (There's no way i can change this).

Can I somehow determine the context and tell the driver API to use that one?

einpoklum
  • 118,144
  • 57
  • 340
  • 684
ritter
  • 7,447
  • 7
  • 51
  • 84
  • Is it necessary to run the two in the same context? That is, can't you just ignore the fact that the library also uses CUDA? – Roger Dahl May 07 '12 at 16:23
  • It is strongly discouraged to use separate contexts. It seems that is is an expensive operation to switch contexts. – ritter May 07 '12 at 16:39

1 Answers1

3

cuCtxGetCurrent() gets the currect context (that might be created by the runtime)

ritter
  • 7,447
  • 7
  • 51
  • 84