Home › Tools › Raspberry Pi cluster

Building a Raspberry Pi cluster.

A 26-node Raspberry Pi 4 cluster we built in the lab for embarrassingly parallel jobs and as a teaching platform. This page documents the parts list, the physical build, and the OS and network configuration so that another lab or a student could replicate it. It was never intended to rival a real HPC system. It exists because some jobs fit badly on shared university clusters and because putting hands on the hardware is a legitimate way to learn.

26
Raspberry Pi nodes
104
Total cores
108 GB
Aggregate RAM
$2,147
All-in hardware cost

Why build one

Rationale Cheap parallelism and a teaching platform in the same box Not a substitute for a real HPC, but a good complement.

Single-board computers are not suitable for every analysis. They have limited memory and are slower than a contemporary workstation CPU. But they are cheap, they parallelize well for jobs that fit the model, and they make sense for fitting many models to the same dataset, running many iterative simulations, and the rest of the embarrassingly parallel category. A cluster under our own ceiling also lets students experiment with scheduling, MPI, and systems administration in ways that a university HPC does not. The physical cluster is a teaching surface as much as a compute resource.

Hardware and supplies

Parts list Full bill of materials, 26 Pis and supporting gear Most of it from Amazon and CanaKit. Total hardware: $2,146.66.

Most components were sourced from Amazon. With careful shopping or repurposed equipment the costs could be reduced further.

Qty Description Source Unit Total
25 Raspberry Pi 4 B with 4 GB RAM canakit $55.00 $1,375.00
1 Raspberry Pi 4 B with 8 GB RAM canakit $89.95 $89.95
5 Rack and fan setups amazon $25.00 $125.00
6 Micro SD 32 GB, 5-pack amazon $33.00 $198.00
1 24-port Gigabit Ethernet switch amazon $65.90 $65.90
5 CAT6 cables 1 foot, 6-pack amazon $12.99 $64.95
8 USB-C power cords 8", 3-pack amazon $8.99 $71.92
6 USB 60 W charging stations, 6-socket amazon $25.99 $155.94
Total project cost $2,146.66

Not included are items already on hand and donated to the project: a 1 TB SSD external hard drive, monitor, keyboard, mouse, an 8-port Gigabit Ethernet switch, and miscellaneous cables.

Power configuration. Six 6-port chargers were purchased for 36 total ports for 26 Pis. After research on power requirements, most power packs run only 4 Pis each to ensure adequate power delivery, especially when USB devices are connected.

Total system specs: 104 cores (26 quad-core processors) with 108 GB of RAM.
References Builds that shaped this one Two excellent tutorials worth reading before starting.

Part 1, physical assembly

Mechanical build Heatsinks, fan plates, standoffs, three towers Two towers of 8 Pis, one tower of 9 Pis, plus a separate head node.

Assembling the Pi racks was straightforward:

  1. Install heatsinks on all Pis.
  2. Attach fans to mounting plates, designed for five Pis each.
  3. Combine plates into three towers: two with 8 Pis and one with 9 Pis.
  4. Mount each Pi on standoffs and stack plates in towers.
  5. Connect fans to pins on the Pi below each plate.

The head node is a separate Raspberry Pi 4 (8 GB RAM version) housed in a standard case. This design lets us later replace the head with a more powerful Linux machine from System76 without disrupting worker nodes. At this stage, cabling, disk setup, and software installation remain.

Part 2, operating system and software

OS selection Raspbian Buster over Ubuntu Server 20.04 Lower RAM overhead and more responsive on the Pi 4.

Initial testing compared Ubuntu Server 20.04 with a desktop (LUBUNTU) to the standard 32-bit Raspbian (Buster, based on Debian 10). Ubuntu is more general-purpose, but Raspbian was more responsive with lower RAM overhead and was ultimately chosen for all nodes.

Head node setup R from source, OpenMPI, the usual dependencies Compile R, install libraries, install MPI, then clone.

The installation process on the head node follows these steps:

  1. Install Raspbian Buster with system updates.
  2. Compile R from source (version 4.0.2).
  3. Install required system libraries and R packages.
  4. Install OpenMPI for distributed computing.

R compilation. Compiling R requires installing multiple dependencies. If the configure script fails, search for the missing library using patterns like "how to install libXXX on raspberry pi". Solutions are typically found in the first few results.

# Install OpenMPI for message passing sudo apt install openmpi-bin openmpi-common libopenmpi3 libopenmpi-dev -y

Note. PDF man pages failed to build (texi2any version conflict), but base R and all packages installed successfully.

SD card cloning Clone the head node 25 times for workers About 20 minutes per card. Attach HDMI before first boot.

After head node configuration, use Raspbian's built-in SD card clone utility to create 25 copies, about 20 minutes per card. To enable headless SSH setup, add an empty file named ssh to the boot folder before first boot. Still, connecting a monitor during initial setup is recommended to verify HDMI detection.

HDMI detection issue. If Pis boot without HDMI cables connected, they don't start the X11 windowing system, producing no video output even after plugging in a monitor. Always connect HDMI cables before the first boot.

Node configuration Hostname, static IP, SSH, reboot Four quick steps per node, done on first boot.

Configure each node (head first, then workers) by performing these steps on boot:

1. System configuration

Open the Pi configuration application and:

  • Change the hostname: head node "stevens"; worker nodes "node1", "node2", and so on.
  • Update the default password if desired.
  • Select "No" when prompted to reboot. We'll reboot after additional changes.

Naming convention. All lab computers are named after great scientists. The head node is named "stevens" after Nettie Stevens, a pioneer in genetics who wrote the pioneering Studies in Spermatogenesis volumes (1905, 1906) on sex chromosomes.

2. Static IP configuration

Set up static IP addresses so that node identities stay consistent across reboots:

sudo nano /etc/dhcpcd.conf

Add these lines to the file (increment the third octet for each node):

interface eth0 static ip_address=10.0.0.1/24

For example, head node uses 10.0.0.1, node1 uses 10.0.0.2, and so on, up to 10.0.0.26.

3. Enable SSH

SSH is disabled by default and does not persist after reboot when enabled through the GUI. Enable it from the command line:

sudo systemctl enable ssh sudo systemctl start ssh

Verify SSH status:

sudo service ssh status

4. Reboot and verify

After reboot, verify the hostname change and confirm SSH is running.

SSH key exchange Passwordless logins across all nodes Generate keys, copy to head, then copy head's key to every worker.

Generate SSH keys for passwordless communication between nodes:

ssh-keygen -t rsa

Press Enter through all prompts to use defaults. Configure key sharing:

On worker nodes. Copy the head node's key:

ssh-copy-id 10.0.0.1

On head node. After all nodes are configured, copy the head's key to all workers:

ssh-copy-id 10.0.0.2 ssh-copy-id 10.0.0.3 # ... continue for all nodes up to 10.0.0.26

Verification. From the head node, test passwordless SSH access to a worker:

ssh 10.0.0.4

Part 3, cabling and finalization

Cabling It works, but use longer cables than you think you need Minimal slack is the main regret.

Once all nodes are configured, finalize the physical cabling setup. In hindsight, slightly longer network cables would have provided more flexibility for cable management and rack organization. The current setup works but leaves minimal slack in some cable runs.

Part 4, test run

Benchmarks Distributed computing benchmarks and first job submissions Coming soon.

Coming soon: distributed computing benchmarks and first job submissions.

Last updated: 2024

Question copied. Paste it into the NotebookLM tab.