Running parfor on multiple nodes using Slurm
Show older comments
Hello everyone,
What I really like to do is to take advantage of running a Matlab script (written to be run in parallel on multiple cores using "parfor" concept) remotely on a supercomputer. The issue is not to run the script on just one node (ex. the node includes 48 cores) but is to run it on multiple nodes (more than 48 cores).
Attached you can find a simple 10-line Matlab script (parEigen.m) written by the "parfor" concept. I have attached the corresponding shell script I used, and the Slurm output from the supercomputer as well. From the Slurm output, you clearly see that I could succeed to run the script on 48 cores (1 node) on the supercomputer. However, I am looking for a solution to run the Matlab script remotely on more cores (multiple nodes) on the supercomputer.
I really appreciate any help you could provide with this. Please consider that I am a normal user of the supercomputer. I do not have access to the Matlab GUI and the parallel computing toolbox setting.
My Matlab script:
function [elapsedTime] = test_for()
nworker = str2double(getenv('SLURM_NTASKS')) - 1
defaultProfile = parallel.defaultClusterProfile
myCluster = parcluster(defaultProfile);
parpool(myCluster, nworker)
N = 1000;
A = zeros(N,1);
tic;
parfor i = 1 : N
E = eig(rand(100))+i;
A(i) = E(1);
end
elapsedTime = toc;
end
My shell script:
#!/bin/bash
#SBATCH --job-name="pforTest"
#SBATCH --time=00:15:00
#SBATCH --ntasks=48
#SBATCH --cpus-per-task=1
#SBATCH --partition=compute
#SBATCH --mem-per-cpu=1GB
#SBATCH --account=researcher
module load matlab
matlab -r parEigen
Slurm output:
MATLAB is selecting SOFTWARE OPENGL rendering.
< M A T L A B (R) >
Copyright 1984-2021 The MathWorks, Inc.
R2021b (9.11.0.1769968) 64-bit (glnxa64)
September 17, 2021
To get started, type doc.
For product information, visit www.mathworks.com.
defaultProfile =
'local'
Starting parallel pool (parpool) using the 'local' profile ...
Connected to the parallel pool (number of workers: 47).
ans =
ProcessPool with properties:
Connected: true
NumWorkers: 47
Cluster: local
AttachedFiles: {}
AutoAddClientPath: true
IdleTimeout: 30 minutes (30 minutes remaining)
SpmdEnabled: true
ans =
0.9884
1 Comment
Abdolrazzagh
on 8 Dec 2023
Dear Siamak, I am facing with this problem too. I would like to know how did you solve this problem?
Accepted Answer
More Answers (0)
Categories
Find more on Third-Party Cluster Configuration in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!