1
$\begingroup$

I'm hoping to parallelise my Mathematica script across multiple nodes on an HPC, but I can't get it to work. My code has the following schematic form:

(* ::Package:: *)

(* ::Input::Initialization:: *)  

Needs["SubKernels`RemoteKernels`"];
       numCore=32; 
       PBSKernel[host_String]:= LaunchKernels[RemoteMachine[host,"ssh -x -f -l `3` `1` /cm/shared/apps/Mathematica_10.0.1/Executables/math-mathlink -linkmode Connect `4` -linkname '`2`' -subkernel-noinit",numCore]];
       hostfile = Environment["PBS_NODEFILE"];

(* ::Input::Initialization:: *)

ParallelEvaluate[ 

 "initialising variables"

];


(* ::Input::Initialization:: *)

Do[

    b1 = ParallelTable[NIntegrate[func[x,i,j],{x,0,20}],{i,1,100},Method->"FinestGrained"];

    b1interp = Interpolation[b1];
    ParallelEvaluate[ToString[b1interp]];
    DistributeDefinitions[b1interp];

    b2 = ParallelTable[NIntegrate[b1interp[x,i,j],{x,0,20}],{i,1,100},Method->"FinestGrained"];
     .
     .
     .

   ,{j,1,100}

]


(* ::Input::Initialization:: *)

Exit[]

The problem I'm finding is that the initial bit of code doesn't seem to launch any kernels - if I get it to simply Print the output Print[$KernelCount] and it returns 0.

Furthermore, if I simply work on a single node and use LaunchKernels[] instead, I find that on the HPC from the terminal the Mathematica code runs slower than it does if I run it in a notebook with the same number of cores (same processors and RAM), specifically it takes about twice as long.

What am I doing wrong?

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.