MATLAB: Select a GPU to be used by a function running in parallel(parfeval)

gpuguiimaqtoolMATLABparfeval

Hello,
I am using two GPUs in a GUI postprocessing images live.
I am using the 'FramesAcquiredFcn' as a hub to transfer data from the buffer to the CPU RAM memory ('getdata') and launch a 'parfeval' function on GPU postprocessing these data. I have 1 pool with 3 workers initialized (one for the 'FramesAcquiredFcn' and one for each GPU). I can check that when the 'parfeval' function is not finished at the next iteration the second GPU is used instead. Now, I know that using 'wait' I can force the first GPU to be used.
However, I would like to split my postprocessing between these two GPUs because one is more powerful than the other. Hence, I would need the first 'parfeval' function to use the GPU1 pass the outputs (using 'afterEach'?) to an other parfeval function using the GPU2.
I have read the 'help selectGPU' but could not figure out how to modify it for my purpose.
Any help will be welcome.

Best Answer

I'd have to know what kind of postprocessing you're doing - please post some code. On the face of it, the answer is simply to use gpuDevice(i) to select a particular device for each of your parfeval calls.