Sharing Cuda contexts among Linux processes


Is it possible to share (to some extent) cuda contexts among linux processes? I am interested in attaching a 3rd party profiling process to a cuda context (similarly to what can be done in the linux perf_event API with processes/threads) so that the profiling process can make cupti calls on the shared context. From what I can tell by reading documentation this is not possible. Is my assessment correct? If it is, is there any plan to allow this sort of behaviour in the future?


I’m not aware of any method to do this. I generally can’t comment on future plans on these forums. The only “sharing” that is possible is via CUDA IPC, which does not facilitate an external process to run cupti calls.

You can make feature requests through the bug reporting mechanism.

Since these two terms were casually thrown together here: Processes and threads are very different things. Processes own system resources and are protected from each other, while threads share the resources of the process they belong to. Sharing between processes can only happen in very limited form using special APIs. By design, CUDA contexts are the equivalent of Linux processes.

Thank you for the answer Robert.