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
0 个评论
采纳的回答
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 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Parallel for-Loops (parfor) 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!