Limit to the number of contexts created?

Is there a limit to the number of contexts that can exist concurrently? I’m playing around with some multithreading code, and with the way I was thinking about writing it, a context could be created/used, detached (at some later point), and possibly not released for a while (depending on how often my ‘garbage collector’ is called).

I could just put a hard limit on my code to make sure there aren’t any problems, but if it’s all the same to the CUDA driver, I’d like to avoid it.

I don’t know that there’s a hard limit in the driver, but you’ll hit limits on GPU memory long before you hit that. A context takes up a pretty sizable amount of global memory, so creating lots of contexts is not a good idea if you care about how much free memory you have.

Thanks for the quick reply! I’ll just have to find another way to do my multithreading then.