我想验证我的群集配置是否正确,我想发出以下命令将运行以下脚本并将poolsize输出到文本文件以及我的屏幕输出定向的位置(由批处理管理环境) 。相反,我只看到输出结尾,错误文件中也没有任何内容。我该如何做到这一点?
命令:
matlab -nosplash -nodesktop < test.m
脚本:
clear;
delete(gcp);
parpool;
poolsize = poolobj.NumWorkers
save poolsize.txt poolsize -ascii
exit();
poolobj = gcp('nocreate'); % If no pool, do not create new one.
if isempty(poolobj)
poolsize = 0;
else
poolsize = poolobj.NumWorkers
end
save poolsizefile poolsize;
poolsize
exit();
(下半场从未奏效,所以我甚至停止了尝试,因此第一次退出。)
输出:
>> >> Starting parallel pool (parpool) using the 'local' profile ... Warning: Found 1 pre-existing communicating job(s) created by pool that are
running, and 3 communicating job(s) that are pending or queued. You can use
'delete(myCluster.Jobs)' to remove all jobs created with profile local. To
create 'myCluster' use 'myCluster = parcluster('local')'.
答案 0 :(得分:0)
首先,我建议使用MATLAB的-r
选项来运行你的脚本,因为在你正在进行管道输入时偶尔会出现一些奇怪的现象,例如
matlab -nodisplay -r test
然后,我会将第2行更改为状态
delete(gcp('nocreate'))
确保您不创建池只是为了删除它。然后,下一位应该是
poolobj = parpool;
poolsize = poolobj.NumWorkers;