Job management, control flow
1 次查看(过去 30 天)
显示 更早的评论
I work with large (0.2 - 1 Tb) sets of 3D image data. I would like to set up a queue within a function that reads in an 'on-deck' image into RAM while data is being processed on the GPU. I can sort out the details, but would be grateful if someone could help point me in the right direction to do the following:
Read in 2 files run loop1 on file1 ; end loop ; clear file 1
run loop1 on file 2; while running, load file3 into memory.
...and so on.
In other words, i need to essentially be able to send a child process to the gpu, and wait on its return value
0 个评论
采纳的回答
Jon Boerner
2014-10-21
编辑:Jon Boerner
2014-10-21
Hi Benjamin,
The easiest way to do this is probably using either the batch function, or the parfeval function in newer versions. Basically, you would use one of those functions to start a worker which would handle interfacing with the GPU, while the main thread moves on to loading the next file. The code might look something like:
loadedData = loaddata(...);
c = parcluster('local');
c.NumWorkers = 2; % You may want more workers depending on how many GPU's you have, etc.
j = batch(c,@myGPUFcn,1,{loadedData});
while(...)
loadedData = loadnextdata(...);
j.wait(); %Wait for GPU to finish in case file loaded faster
outputs = j.fetchOutputs;
end
function y = myGPUFcn(data)
% make gpuArray and perform operations on it
end
There are some details missing, but that would be the general approach. Using parfeval would be a very similar workflow. loaddata and loadnextdata are just place holders for however you load your files.
Let me know if you have any questions!
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 GPU Computing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!