Group Abstract Group Abstract

Message Boards Message Boards

How to use Mathematica in a high-performance computing (HPC) environment

Posted 9 years ago
POSTED BY: Kevin Daily
13 Replies
Posted 4 years ago

Dear Kevin,

Thanks for your reply.

Yes, there are 40 cores on atulya049 as well.

Ok, I will do one heavy calculation and get back to you.

With thanks, Sachin.

PS- In your First post, You suggested to remove the Wolfram controlling kernel from the list of available resources. So in my program, Out of requested cores (80), 79 are going into the calculation.

Could you tell us why do we need to remove the controlling Wolfram kernel ?

POSTED BY: Sachin Kumar
POSTED BY: Kevin Daily
Posted 4 years ago
POSTED BY: Sachin Kumar
POSTED BY: Kevin Daily
Posted 5 years ago

Hi Kevin,

I'm using a linux cluster of my insititute, we recently installed gridMathematica on it, and I'm pretty sure the first assumption you mentioned is well satisfied. However, our cluster has a dedicated login node as well as about 40 dedicated computing nodes, we users are only allowed to SSH to the login node, but don't have the previlage to SSH to the computing nodes, so the second assumption you mentioned is not satisfied in our case. The cluster is managed with SLURM, and mpi-based parallelization works well without the necessity of freely SSH among the nodes. So I just wonder if Mathematica has some mechanism to support large-scale parallelization if freely SSH is not allowed.

Many thanks for your help!

Zhe

POSTED BY: zhe duan

In practice, you only need to log in to the head node via SSH. Having no direct SSH access to the compute nodes from outside the cluster is a good thing!

My understanding is that once a job is running on the cluster, that job's resources (the compute nodes provided to the job) can freely communicate with one another. Considering that MPI parallelization works on the cluster, I would be surprised that you could not also use my described method to have Mathematica run on the SLURM cluster.

You first need to truly test your SSH issues before going any further. I suggest starting an interactive session so you have access to the command line, but request more than one compute node. In the following $> represents the terminal input. Echo the cluster manager commands e.g.

$> !scontrol show hostname $SLURM_JOB_NODELIST
$> echo $SLURM_TASKS_PER_NODE

Then try a simple SSH command from your main node to one of the other compute nodes you've requested. Something like

$> ssh remote-compute-node-name pwd

If password-less SSH is available then this will display the remote compute node's working directory (via the 'pwd' command). If the nodes use a cloned file system then the working directory should be your home directory on the cluster. Resolve any issues before moving on.

POSTED BY: Kevin Daily
Posted 5 years ago

Hi Kevin,

Thank you for your prompt reply! The attached file contains some of my previous test results. Since the cluster is very busy now, I will test the commands you suggest later on.

I confirmed with our cluster manager, and was told that normal users cannot SSH to the computing nodes, only root users can.

As to why MPI could still work in our cluster, I found some relevant information from the official website of SLURM: https://slurm.schedmd.com/quickstart.html.

It is stated that:

MPI use depends upon the type of MPI being used. There are three fundamentally different modes of operation used by these various MPI implementation.

Slurm directly launches the tasks and performs initialization of communications through the PMI2 or PMIx APIs. (Supported by most modern MPI implementations.)

Slurm creates a resource allocation for the job and then mpirun launches tasks using Slurm's infrastructure (older versions of OpenMPI).

Slurm creates a resource allocation for the job and then mpirun launches tasks using some mechanism other than Slurm, such as SSH or RSH. These tasks initiated outside of Slurm's monitoring or control. Slurm's epilog should be configured to purge these tasks when the job's allocation is relinquished. The use of pamslurmadopt is also strongly recommended.

I think your implementation of Mathematica working with SLURM follows the third approach, while MPICH we are using in the cluster follows the first approach and does not require SSH. Now I wonder if Mathematica could be somehow configured to work with SLURM using the first two approaches so that SSH is not necessary.

Your further comments and suggestions are highly appreciated!

Best,

Zhe

POSTED BY: zhe duan
Posted 4 years ago
POSTED BY: zhe duan
Posted 4 years ago

@zhe duan , Hi, Thanks for replying, I will take a look at attachment and get back to you.

POSTED BY: Sachin Kumar

People who are looking at this might find this independent implementation, made for SGE and a specific HPC cluster, useful: https://bitbucket.org/szhorvat/crc/src

An issue specific to this system was that ssh would not work, and rsh (a specific version of rsh!) had to be used.

POSTED BY: Szabolcs Horvát
Posted 4 years ago

Your shared link is broken, Could you share it again. It might be helpful to me.

POSTED BY: Sachin Kumar

I can't comment on how the Mathematica book (do you mean Elementary Introduction to the Wolfram Language?) presents how to use the command line, but yes, this method has been around since Mathematica's inception.

I have seen the method I presented above carried out on a SLURM managed cluster, and I used a Torque/PBS managed cluster in my previous employment. From a user's point-of-view I am familiar with how managed clusters work. However, I have not used all cluster managers, thus why I requested community support. My goal was to have instructions in how to use Mathematica with the most common cluster managers, documented in one place.

As a follow up, one common-use scenario is to

  1. log in to the cluster's head node with X-windows forwarding enabled
  2. submit an "interactive session" to the cluster
  3. wait for the resources to be provided and control of the terminal returned to the client
  4. launch a Mathematica front end

Keep in mind, though, that all commands must be sent back-and-forth from the remote cluster to your screen. This can have a pretty annoying delay. The benefit is that most clusters have nodes with more CPU cores than your desktop, and each CPU core may be more powerful than those in your desktop.

The downside (besides the lag) is that if you've requested multiple nodes, then you don't know which node is acting as the head node. And if you use LaunchKernels[], then only the local kernels (on the head node) will launch. Because interactive jobs are intended as debugging sessions, one approach is to just exclusively request a single node.

Alternatively, you can query the environment variables of the job session and launch remote kernels like I showed earlier.

POSTED BY: Kevin Daily

enter image description here - Congratulations! This post is now Staff Pick! Thank you for your wonderful contributions. Please, keep them coming!

POSTED BY: EDITORIAL BOARD
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard