目次
Table of Contents |
---|
...
MathWorksアカウント画面へ
MATLAB(Individual)の右の下矢印を押してダウンロード画面へ
※この際に画面左のリリースを選択からR2022aを選択します。{Windows, Mac, Linux}用ダウンロードを押してMATLAB R2022aのダウンロードを開始します。
...
Parallel Serverを使用するには、インストール時の製品の選択ではMATLABの他にParallel Computing Toolboxを選択してください。
...
準備3-
...
クラスター構成
Info |
---|
MATLAB Parallel Server はVPNを含む学内ネットワークのみの利用となっています。 |
...
Info |
---|
クラスタープロファイルは学内でのみ使用可能です。学外の場合はVPN接続で使用してください。 |
例
6. クラスタープロファイルの切り替え(localとa9 Server)
localとa9 Serverの切り替えは、それぞれのクラスタープロファイルについて既定の設定を切り替えて行います。
...
7. 並列処理ありとなしの切り替え
並列処理ありとなしの切り替えは、コマンドにおける'UseParallel',trueを'UseParallel',falseに書き換える。
...
Code Block |
---|
tic % Start stopwatch timer % Input image input_img = "input_img.jpg"; % Add image path % Initialize Edge detection function fun = @(block_struct) edge(block_struct.data,"canny"); % Covert source image from RGB to GRAY input_image= rgb2gray(imread(input_img)); % Perform Parallel Block Process result = blockproc(input_image,[25 25],fun, ... 'UseParallel',false); toc % Terminate stopwatch timer % Show ouput image imshow(result |
並列処理の例
例1:大きな画像に対するブロック処理
input_img.pngをC:\Users\ユーザー名\Documents\MATLABに移す。
...
並列処理なし | 並列処理あり | |
---|---|---|
windows (Local) | windows (Local) 8 workers | Red Hat Enterprise Linux (a9 Server) 12 workers |
11.97 | 3.30 | 2.79 |
例2:グローバルミニマムの探索
並列処理ありの場合
Code Block tic % Start stopwatch timer % Consider a function with several local minima. fun = @(x) x.^2 + 4*sin(5*x); fplot(fun,[-10,10]) rng default % For reproducibility opts = optimoptions(@fmincon,'Algorithm','sqp'); problem = createOptimProblem('fmincon','objective',... fun,'x0',3,'lb',-5,'ub',5,'options',opts); ms = MultiStart('UseParallel', true); %To search for the global minimum, run MultiStart on 2000 instances of the problem using the fmincon 'sqp' algorithm. [x,f] = run(ms,problem,2000) toc % Terminate stopwatch timer
並列処理なしの場合
Code Block tic % Start stopwatch timer % Consider a function with several local minima. fun = @(x) x.^2 + 4*sin(5*x); fplot(fun,[-10,10]) rng default % For reproducibility opts = optimoptions(@fmincon,'Algorithm','sqp'); problem = createOptimProblem('fmincon','objective',... fun,'x0',3,'lb',-5,'ub',5,'options',opts); ms = MultiStart('UseParallel', false); %To search for the global minimum, run MultiStart on 2000 instances of the problem using the fmincon 'sqp' algorithm. [x,f] = run(ms,problem,2000) toc % Terminate stopwatch timer
処理時間の比較(単位:秒)
並列処理なし | 並列処理あり | |
---|---|---|
windows (Local) | windows (Local) 8 workers | Red Hat Enterprise Linux (a9 Server) 12 workers |
6.20 | 1.70 | 1.52 |
例3:SVM分類器による最適化
並列処理ありの場合
Code Block tic % Start stopwatch timer load ionosphere % Load the ionosphere data set. rng default % Find hyperparameters that minimize five-fold cross-validation loss by using automatic hyperparameter optimization. For reproducibility, set the random seed and use the 'expected-improvement-plus' acquisition function. Mdl = fitcsvm(X,Y,'OptimizeHyperparameters','auto', ... 'HyperparameterOptimizationOptions',struct('UseParallel',true)) toc % Terminate stopwatch timer
並列処理なしの場合
Code Block tic % Start stopwatch timer load ionosphere % Load the ionosphere data set. rng default % Find hyperparameters that minimize five-fold cross-validation loss by using automatic hyperparameter optimization. For reproducibility, set the random seed and use the 'expected-improvement-plus' acquisition function. Mdl = fitcsvm(X,Y,'OptimizeHyperparameters','auto', ... 'HyperparameterOptimizationOptions',struct('UseParallel',false)) toc % Terminate stopwatch timer
処理時間の比較(単位:秒)
並列処理なし | 並列処理あり | |
---|---|---|
windows (Local) | windows (Local) 8 workers | Red Hat Enterprise Linux (a9 Server) 12 workers |
32.38 | 8.23 | 7.86 |
例4:並列処理によるデータのクラスタリング
並列処理ありの場合
Code Block Mu = bsxfun(@times,ones(20,300),(1:20)'); % Gaussian mixture mean rn300 = randn(300,300); Sigma = rn300'*rn300; % Symmetric and positive-definite covariance Mdl = gmdistribution(Mu,Sigma); % Define the Gaussian mixture distribution rng(1); % For reproducibility X = random(Mdl,10000); % Specify the options for parallel computing. stream = RandStream('mlfg6331_64'); % Random number stream options = statset('UseParallel',1,'UseSubstreams',1,... 'Streams',stream); % Cluster the data using k-means clustering. Specify that there are k = 200 clusters in the data and increase the number of iterations. Typically, the objective function contains local minima. Specify 10 replicates to help find a lower, local minimum. tic; % Start stopwatch timer [idx,C,sumd,D] = kmeans(X,200,'Options',options,'MaxIter',10000,... 'Display','final','Replicates',10); toc % Terminate stopwatch timer
並列処理なしの場合
Code Block Mu = bsxfun(@times,ones(20,300),(1:20)'); % Gaussian mixture mean rn300 = randn(300,300); Sigma = rn300'*rn300; % Symmetric and positive-definite covariance Mdl = gmdistribution(Mu,Sigma); % Define the Gaussian mixture distribution rng(1); % For reproducibility X = random(Mdl,10000); % Specify the options for parallel computing. stream = RandStream('mlfg6331_64'); % Random number stream options = statset('UseParallel',false,'UseSubstreams',1,... 'Streams',stream); % Cluster the data using k-means clustering. Specify that there are k = 200 clusters in the data and increase the number of iterations. Typically, the objective function contains local minima. Specify 10 replicates to help find a lower, local minimum. tic; % Start stopwatch timer [idx,C,sumd,D] = kmeans(X,200,'Options',options,'MaxIter',10000,... 'Display','final','Replicates',10); toc % Terminate stopwatch timer
処理時間の比較(単位:秒)
...