Appropriate usage of Parallel Pool
이전 댓글 표시
Hi. I have two related questions:
Question 1: Which of the following 4 is best to use in order to take advantage of my PC's multi-core setup? Or if instead any other method would be more appropriate (e.g. using gcp), please let me know. Methods 1&2 are identical to 3&4 with the exception of how I have treated the loop: 'for' vs 'parfor'.
Question 2: My PC also has a NVIDIA Quadro P3200 GPU. Could you please possibly also provide an additional script (for the same CV-lasso setup) potentially utilising the GPU, too?
%Method 1
for i = 1:10
pool = parpool('local',5)
opts = statset('UseParallel',true);
b = lasso(X(:,:,i),y,'CV',10,'Options',opts);
delete(pool)
end
%Method 2
pool = parpool('local',5)
for i = 1:10
opts = statset('UseParallel',true);
b = lasso(X(:,:,i),y,'CV',10,'Options',opts);
end
delete(pool)
%Method 3
parfor i = 1:10
pool = parpool('local',5)
opts = statset('UseParallel',true);
b = lasso(X(:,:,i),y,'CV',10,'Options',opts);
delete(pool)
end
%Method 4
pool = parpool('local',5)
parfor i = 1:10
opts = statset('UseParallel',true);
b = lasso(X(:,:,i),y,'CV',10,'Options',opts);
end
delete(pool)
Thank you for your time and help!
PS: Btw, I wrote my GPU model (not to show off, but) just in case some tech-savvy pal says something like 'Your GPU is not powerful enough, and it's not worth the trouble. Stick to utilising your multi-core setup, instead'. I am really looking for the strategy that provides me with the lowest possible runtime given the resources.
채택된 답변
추가 답변 (1개)
Question 1: Which of the following 4 is best to use
I'm sure it depends on the dimensions of X(:,:,i), but here's what I would try first,
pool = parpool('local',5)
opts = statset('UseParallel',true);
clear b
for i = 10:-1:1
b{i} = lasso(X(:,:,i),y,'CV',10,'Options',opts);
end
I would probably then compare that to parfor without UseParallel
parfor i = 1:10
b{i} = lasso(X(:,:,i),y,'CV',10);
end
Question 2: My PC also has a NVIDIA Quadro P3200 GPU. Could you please possibly also provide an additional script (for the same CV-lasso setup) potentially utilising the GPU, too?
It doesn't look like lasso() supports gpuArray input, unfortunately.
댓글 수: 3
카테고리
도움말 센터 및 File Exchange에서 Parallel Computing Fundamentals에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!