WOLFRAM

How do I use Mathematica in a managed high-performance cluster?

Background information

Larger computing clusters consist of many nodes where each node is made up of many CPU cores. Moreover, special software such as Mathematica is often available on the cluster. Users request these resources by logging into a head node and submitting batch jobs to the cluster manager. The job executes when the resources become available. Two common cluster managers include TORQUE and Slurm.

Parallelization in Mathematica uses the hub-and-spoke model where a controlling kernel manages a number of subordinate kernels (subkernels). In a cluster environment, the client runs the controlling kernel and the hosts provide subkernels. The cluster manager determines which node acts as the client and which nodes act as hosts.

The benefits of running Mathematica on a cluster are twofold: The number of available CPU cores, even on a single node, is usually more than on a desktop computer. Also, the speed of each CPU core is individually faster than those in a desktop computer.

Running a remote Mathematica front end

A remote front end requires the user to remain in control of the job’s resources. This is known as an interactive session.

Though there is usually a benefit in CPU speed over using a desktop computer, the front end via an interactive session is slower than running a local version of the front end. This is because the front end runs on the cluster while the interface is forwarded to the remote user’s computer.

An interactive session is not intended to run CPU-intensive calculations, but rather it is used to test and diagnose code. It is typical to request only one node’s resources.

  1. Log in to the head node via SSH with X-windows forwarding enabled.
  2. Launch an interactive session, requesting all of the resources on a single node.
  3. Start a Mathematica session.

From a Mathematica notebook, using the LaunchKernels[] command, or any other parallel functionality, will now include subkernels running from the cluster.

Running a remote Mathematica script

It is assumed that

  • you are familiar with launching remote subkernels
  • the cluster is a Unix environment
  • the cluster uses a cloned file system such that Mathematica is run by the same executable on all nodes

If any of the above assumptions are not true, then the following will need to be modified, but the general outline remains:

  1. query the system to find the names of the nodes that are assigned to the job, and how many cores per node are available
  2. manually launch remote kernels

For example, on a Torque managed cluster, in a Mathematica or Wolfram Language script you would have:

(*get association of resources, name of local host and remove local host 
from available resources*)
hosts = Counts[ReadList[Environment["PBS_NODEFILE"], "String"]];
local = First[StringSplit[Environment["HOSTNAME"],"."]];
hosts[local]--;

(*launch subkernels and connect them to the controlling Wolfram Kernel*)
Needs["SubKernels`RemoteKernels`"];
Map[If[hosts[#] > 0, LaunchKernels[RemoteMachine[#, hosts[#]]]]&, Keys[hosts]];

At this point, parallel functions can now be used that utilize the whole set of available resources. When the parallel code is complete, it is good practice to close the Wolfram kernels.

CloseKernels[];
この項目は役に立ちましたか?
はい
いいえ

ご意見・ご提案がおありでしたらお書きください.

フィードバックをありがとうございました.

送信

サポートへのお問合せ

お支払い,アクティベーションに関する質問から技術的な質問まで,お気軽にお問い合せください.

販売代理店 (ライセンスをお持ちの方は、ご購入された代理店にお問い合わせください)

Hulinks

電話:03-5642-8380
Fax:03-5642-8381

soft.sales@hulinks.co.jp
Webサイト

日本電子計算株式会社

電話:03-5210-0184
Fax:03-5210-0229

math_info@cm.jip.co.jp
Webサイト

亘香通商株式会社

電話:045-320-2711
Fax:045-320-9342

sales@senko-corp.co.jp
Webサイト

株式会社シーエムディーラボ

電話:03-3408-8406
Fax:03-3408-8406

info@cmdlab.co.jp
Webサイト