Cluster Mark 2

This is a project that is designed to use the Raspberry Pi as a cluster.  This has been done before by the Exeter Linux user group details of this project can be found here.

Introduction

We are thinking of making a Raspberry Pi supercomputer cluster, with around 5 RPi 2B’s, which of course are around 6 times faster than pi 1’s. This will mean the cluster itself will be 6 times faster than one made with previous pi’s. We may have to modify some code in order for the cluster to work with the full 4 cores per pi, but this should be doable.

If we use 5 pi’s and Ethernet cables, along with a switch I found online, the cost is around £175. However, some parts could be supplied by people who have no further us for them. The cost of 5 pi’s is the main problem, as they themselves are £160, but I believe the cost would be well worth it.

As part of this,  we have so far researched the following

GNU Paralllel

TEST PROGRAM –

The following programs produces the first 1000 prime numbers.   This can be used to test the program and the cluster is working as expected.

#! /usr/bin/env python
count = 1
i = 3
while count != 1000:
    for k in range(2,i):
        if i%k == 0:       
            break
    else:
        print(i)
        count += 1
    i += 2

Using the time command it should be possible to get an idea on how long a program takes to execute :

time ./prime2.py

real 0m1.840s
user 0m1.820s
sys 0m0.000s

While

time parallel ::: ./prime2.py produces

real 0m2.327s
user 0m2.032s
sys 0m0.108s

I do not fully understand what I am doing here, so i need to investigate further thse results.   I am however doing this on a dual core system.

Costings

The cost of 5 pi 2b+’s and network cables, as well as an ethernet switch – £174.73 in total, but well worth it!

ITEM UNIT PRICE QUANTITY TOTAL
Raspberry Pi 2 B+ £27.99 5 TOTAL
PSU 2A 5v x x x
SD card x x x
x x x x
Network cable £1 5 £5
Network Switch ? Free from http://www.wifispark.com/ 1 ?
x x x x
x x x x
x X Grand total x

It is probably possible to mix and match systems in this case,  the Raspberry Pi 2 uses the

PROGRESS REPORTS
 DATE  LINK  TYPE  AUTHOR
 19 / 2 / 2015 http://www.dcglug.org.uk/cluster-progress/  POST  M. lUGG
 –
Parallel Programming with Python
by Jan Palach
Link: http://www.amazon.co.uk/dp/1505492092

Cortex A7 processor (4 core) while the Banana Pi uses the Cortex A7 (2 core) processors.

Comparison of single board computers can be found here.

Banana Pi information can be found here.  This is important as the same code can be run on both units (in theory)

 

OTHER CODING RESOURCES

http://www.parallelpython.com/  – Python library for parallel programming

Parallel Programming with Python
by Jan Palach
Link: http://www.amazon.co.uk/dp/1505492092

 

2 thoughts on “Cluster Mark 2

  1. Pingback: Torbay Raspberry Pi jam – Feb 15 | Devon and Cornwall GNU/Linux Users Group

  2. MuteOn

    Hi,

    I wrote a script to monitor my cluster’s temperature.

    Interested ?

    This is how it works:

    description:

    16 slave PI’s connected to a Master PI (MRPI)
    IP add’s:
    MRPI 192.168.1.70
    slaves 71 — 78 & 81 — 88

    requiered:

    SHH installed on all PI’s and keys shared both ways,
    MRPI to all slaves,
    all slaves to MRPI.

    on each slave copy a script to check the T° and send it to the MRPI:

    #!/bin/bash
    mip=`hostname -I`
    mip=${mip:10:2}
    tfile=”/tmp/”$mip”.txt” #using the IP add to make a file name
    temp=`/opt/vc/bin/vcgencmd measure_temp`
    temp=${temp:5:4}
    echo $temp >$tfile
    #echo $tfile
    #cat $tfile
    scp $tfile pi@192.168.1.70:$tfile # SSH won’t “cat > ” from a script

    #################################################################

    on the MRPI a script to ask the T° of the slaves,
    and graphically display the cluster’s T°:

    #!/bin/bash
    ADD=(71 72 73 74 75 76 77 78 81 82 83 84 85 86 87 88)
    MA=( “/tmp/71.txt” “/tmp/72.txt” “/tmp/73.txt” “/tmp/74.txt” “/tmp/75.txt” “/tmp/76.txt” “/tmp/77.txt” “/tmp/78.txt” )
    MA+=( “/tmp/81.txt” “/tmp/82.txt” “/tmp/83.txt” “/tmp/84.txt” “/tmp/85.txt” “/tmp/86.txt” “/tmp/87.txt” “/tmp/88.txt” )
    HT=15
    LT=65
    SP=”..”
    ST=\|\|

    # Cleaning up previous attempt
    for i in “${MA[@]}”
    do
    if [ -a $i ]
    then rm $i
    fi
    done

    # Each slave send it’s T° to MRPI
    for ind in ${ADD[@]}; do
    VAR=192.168.1.${ind}
    echo $VAR
    ssh $VAR “/mnt/clus/CLUS/ShellScripts/send70temp.sh”
    done

    # Let’s find out the MIN & MAX T°
    for i in “${MA[@]}”
    do
    LL=`cat $i`
    T=${LL:0:2}
    #echo $T ” ” $p
    if [ “$HT” -lt “$T” ]
    then
    WT=$T”+1″
    HT=$((WT))
    fi
    if [ “$LT” -gt “$T” ]
    then
    WT=$T”-1″
    LT=$((WT))
    fi
    done

    # Let’s sound a warning if we have a big T° difference
    WT=$HT-$LT
    DIFF=$((WT))
    echo $DIFF
    if [ “$DIFF” -gt “10” ]
    then
    BEEP
    fi

    clear

    #building a graphical array, x the slaves, y the T°
    for (( p=$HT; p>=$LT; p– ))
    do
    MV=$p” ”
    for i in “${MA[@]}”
    do
    LL=`cat $i`
    T=${LL:0:2}
    #echo $T ” ” $p
    if [ “$p” -gt “$T” ]
    then
    MV=$MV$SP
    else
    MV=$MV$ST
    fi
    done
    echo $MV
    done

    #show the slaves ip tail
    echo -n ” ”
    for i in “${MA[@]}”
    do
    echo -n ${i:5:2}
    done
    echo
    exit

    #############################################

    A sample :

    33 …………………………..
    32 ||…………||…………….
    31 ||…………||….||||….||||
    30 ||||……..||||..||||||….||||
    29 ||||..||||||||||||||||||||||||||
    28 ||||||||||||||||||||||||||||||||
    71727374757677788182838485868788

    Enjoy clustering !!

    MuteOn
    B6180 Belgium

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *