awsdocs / aws-parallelcluster-user-guide

The open source version of the AWS ParallelCluster User Guide.
Other
25 stars 30 forks source link

Explain how to run OpenMPI jobs with Java #66

Closed bkmgit closed 1 year ago

bkmgit commented 2 years ago

The starter documentation is helpful. It would be good to explain how to compile OpenMPI since the default installation may not have all features a user may want. As an example to run a Java application, the following is required after setting up a cluster with SLURM on Ubuntu 20.04.

sudo apt-get install openjdk-11-jdk build-essential
wget https://download.open-mpi.org/release/open-mpi/v4.1/openmpi-4.1.2.tar.gz
tar -xf openmpi-4.1.2.tar.gz
cd openmpi-4.1.2
./configure --prefix=$HOME/openmpi-4.1.2-install --enable-mpi-java --enable-mpi-fortran \
 --with-ofi=/opt/amazon/efa --disable-man-pages
make
make install
cd ..
wget https://download.java.net/openjdk/jdk11/ri/openjdk-11+28_linux-x64_bin.tar.gz
tar -xf openjdk-11+28_linux-x64_bin.tar.gz

Since the home directory is shared to the compute nodes, but software installed using the package manager, apt in this case is not, run time dependencies need to be placed in the home directory or some other shared directory or an AMI created - in this case, the extra required dependency OpenJDK 11 is downloaded directly. To run an example java program, first compile an example program on the head node

cd openmpi-4.1.2/examples
$HOME/openmpi-4.1.2-install/bin/mpijavac Hello.java

then create a SLURM submission script, in this case

nano submit.sh

then place the following in submit.sh:

#!/bin/bash
#SBATCH --job-name=HelloJava
#SBATCH --ntasks=2
#SBATCH --ntasks-per-node=1
#SBATCH --output=%x_%j.out

/home/ubuntu/ompi-install/bin/mpirun -np 2 /home/ubuntu/jdk-11/bin/java Hello

then submit the job

sbatch submit.sh

Further notes

joshbean commented 1 year ago

Closing this issue or pull request in advance of archiving this repo. For more information about the decision to archive this repo (and others in the 'awsdocs' org), see the announcement on the AWS News Blog.