AWS Builder Center

Building a Custom Multi-Node HPC Cluster on AWS EC2 with Rocky Linux

A practical, step-by-step guide to provisioning a High-Performance Computing (HPC) cluster on AWS EC2 using Rocky Linux, configuring passwordless SSH, and utilizing OpenMPI to execute parallel C routines across multiple nodes.

Title: Building a Custom Multi-Node HPC Cluster on AWS EC2 with Rocky Linux
Description: A practical, step-by-step guide to provisioning a High-Performance Computing (HPC) cluster on AWS EC2 using Rocky Linux, configuring passwordless SSH, and utilizing OpenMPI to execute parallel C routines across multiple nodes.
Body:
Running complex parallel workloads doesn't always require managed services like AWS ParallelCluster right out of the gate. If you want to understand the underlying mechanics of distributed computing, building a multi-node HPC cluster from scratch on Amazon EC2 is one of the best ways to learn.
This guide walks through setting up a foundational HPC environment using Rocky Linux, OpenMPI, and C.

1. Provisioning the EC2 Instances

To get started, launch two EC2 instances within the same VPC and Subnet.
  • AMI: Search the AWS Marketplace for a Rocky Linux 9 AMI.
  • Instance Type:  t3.medium  (or any instance type that fits your budget).
  • Security Group: Allow inbound SSH (port 22) from your IP address, and critically, allow all TCP traffic between the instances within that specific Security Group to allow OpenMPI communication.
  • Name one instance  hpc-master  and the other  hpc-worker .

2. Configuring Passwordless SSH

OpenMPI requires the master node to communicate seamlessly with worker nodes without prompting for passwords.
  1. SSH into your  hpc-master  node.
  1. Generate an SSH key pair:
ssh-keygen -t rsa -b 4096
(Leave the passphrase empty when prompted.)
  1. Copy the public key to the  hpc-worker  node. You can do this by pasting the contents of  ~/.ssh/id_rsa.pub  from the master into the  ~/.ssh/authorized_keys  file on the worker node.
  1. Test the connection from the master:  ssh hpc-worker-private-ip . It should log
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article