Warning not being suppressed during parfor loop

1 次查看(过去 30 天)
I'm running a parfor loop. Within the loop, occasionally the following error is thrown:
Warning: File not found or permission denied
I've attempted to disable this warning on each core (I deal with the cause of the error separately) as follows:
spmd
warning('off', 'MATLAB:DELETE:PermissionDenied');
end
...
parfor
do stuff
end
But the warning still occurs.
Does anyone have any thoughts on how I'm going wrong?
Cheers

采纳的回答

Nikilesh Chilkuru
Nikilesh Chilkuru 2018-11-1
I have tried to reproduce this issue using a known warning:'MATLAB:rmpath:DirNotFound'
Reproduction Code:
parpool(2) % creating a parallel pool of two workers
spmd
warning('off','MATLAB:rmpath:DirNotFound')
end
parfor i = 1:2
rmpath('folderthatisnotonpath')
end
Turning off a warning in spmd suppresses the warning in workers successfully. I believe that the warning you are turning off might be incorrect. To see the identifier of the last issued warning
w = warning('query','last') % put these two lines in the parfor loop after the line that causes this error
w.identifier % this contains the warning identifier
You can see the identifier of the warning from the field 'identifier' of struct'w' returned by above command. This is the warning you should turn off to suppress that warning. To get more information on how to suppress warnings, refer: Suppress Warnings

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Parallel for-Loops (parfor) 的更多信息

标签

产品


版本

R2018a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by