在查看一篇論文公布的Matlab源代碼時,有這么一行代碼:
matlabpool('open',8);
代碼運行到此時,會出現錯誤:
Failed to open matlabpool. (For information in addition to the causing error, validate the configuration 'local' in the Configurations Manager.)
此錯誤提示並不太明晰,但是matlab命令行窗口又會提示:
Caused by:
Error using distcomp.interactiveclient/start (line 88)
Failed to start matlabpool.
This is caused by:
You requested a minimum of 8 workers, but the scheduler's ClusterSize property is currently set to allow
a maximum of 6 workers. To run a parallel job on more workers than this,increase the ClusterSize property setting in the 'local' configuration using the Configurations Manager. The default value for ClusterSize with a local scheduler is the number of cores on the local machine.
至此,問題已經很清楚,默認最大只有6個worker(不知道准確的翻譯應該是什么),而此時需要8個worker.
二:解決方法
打開菜單Parallel--->Manage Configurations,選中local,右鍵選擇Properties,會出現如下窗口:
圖中紅色圈出的就是我們需要更改的地方,此處我們填上8,之后一切正常。
三:題外話
如何直觀的看出並行,我做了一個測試:
在未開啟matlabpool時,查看進程管理,只有一個MATLAB.exe,但是在開啟matlabpool后,有9個MATLAB.exe.!!!如下圖所示:
每個都是將近100多M,看樣子,落后的機器真是跑不起來了啊。
而且在主窗口的右下角還有一個圖標,如下圖所示:
鼠標放上去之后會提示:MATLAB pool open with 8 labs.
注:matlab環境:Win 7 64 bit + Matlab R2011b.
四:關於matlabpool
查看matlab的幫助,有如下一段:
Open or close a pool of MATLAB sessions for parallel computation matlabpool enables the parallel language features within the MATLAB language (e.g., parfor) by starting a parallel job that connects this MATLAB client session with a number of labs.