0

Now I'm using ROS to develop a CUDA Project. There are two nodes corresponding to 2 host threads that need to launch 2 different CUDA kernels concurrently.

So I'm wondering:

  1. Can a single GPU be called by two host threads concurrently, if I didn't use CUDA Stream?(let's say the GPU resources are enough for launching these two kernels simutaneously.)
  2. If not, Why?
  3. If I didn't use cuda stream, are these two kernels bound to a single CUDA context or two?
  4. If I use CUDA stream, are these two kernels bound to a single CUDA context or two?
  5. If they are in two different CUDA context, how does the GPU handle their launching/operations as they are called concurrently?

I am now using a RTX 3090 with CUDA 11.0, and i9-10900k, which has 10 cores.

1 Answer 1

2
  1. Can a single GPU be called by two host threads concurrently, if I didn't use CUDA Stream?

Basically no. Threads from the same process share a common context. Contexts only expose concurrency when using streams. You might be able to get some degree of concurrency if you build your code to use a per thread default stream, but that is still using streams, just implicitly rather than explicitly.

  1. If not, Why?

Because that is how NVIDIA designed it.

  1. If I didn't use cuda stream, are these two kernels bound to a single CUDA context or two?

One. Since CUDA 4 the model is one context per process per device.

  1. If I use CUDA stream, are these two kernels bound to a single CUDA context or two?

See above

  1. If they are in two different CUDA context, how does the GPU handle their launching/operations as they are called concurrently?

They are not, so this is moot.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.