Question about cudaSetDevice and multiple host threads

Suppose you have 2 GPUs and two host threads (0 and 1), and these two threads interleave in the following way:

thread 0: cudaSetDevice(0)
thread 1: cudaSetDevice(1)
thread 0: cudaMalloc(…)

Is cudaMalloc going to be performed on GPU 0 or 1?

1 Like

Nevermind. It’s GPU 0. The documentation explains it: http://docs.nvidia.com/cuda/cuda-runtime-api/group__CUDART__DEVICE.html#group__CUDART__DEVICE_1g418c299b069c4803bfb7cab4943da383

1 Like