Difference between revisions of "Setting up the cluster"

From Advanced Projects Lab
Jump to: navigation, search
(Settings and software)
 
(6 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 +
<h1>Building a Beowulf Cluster (MPICH2)</h1>
 +
<h3>Prerequisites</h3>
 +
<ul>
 +
<li>Have computers</li>
 +
<li>Have computers on the same network connected by ethernet. &nbsp;I can't explain that too much because I don't know much about it, but I assume you can just get any sort of server console and hook them up via that.</li>
 +
<li>Be ok with wiping the computers. &nbsp;I installed clean versions of Ubuntu onto the cluster I made.</li>
 +
<li>Also, if you want to look at other sources, these are two sources that were very helpful to me
 +
<ul>
 +
<li>https://www-users.cs.york.ac.uk/~mjf/pi_cluster/src/Building_a_simple_Beowulf_cluster.html</li>
 +
<li>https://help.ubuntu.com/community/MpichCluster</li>
 +
</ul>
 +
</li>
 +
</ul>
 +
<p></p>
 +
<h3>Let's Go</h3>
 +
<ol>
 +
<li>Get a copy of Ubuntu 14.04 <b>Server</b>. &nbsp;If you really want to, you can install a gui interface onto it later, like unity.</li>
 +
</ol>
 +
<h3>1? Install Ubuntu</h3>
 +
<p>This in itself can be a process, and is slow. &nbsp;At least on my computers it was.</p>
 +
<ul>
 +
<li>Make the bootable USB.
 +
<ul>
 +
<li>At the time of writing this, you can download Ubuntu 14.04 Server here.</li>
 +
<li>http://www.ubuntu.com/download/server</li>
 +
<li>I'm sure that if a newer version comes out, it should work as well, although I tried initially with 15.10 (Desktop) and had some trouble with that.</li>
 +
</ul>
 +
</li>
 +
<li><strong></strong>Choose a master node
 +
<ul>
 +
<li>People recommend that the master node be the most powerful. &nbsp;Of course if you are using identical computers just choose whichever. &nbsp;In my case, I had 1 computer with 4 cores, whereas the rest had 2.</li>
 +
</ul>
 +
</li>
 +
<li>Plop the usb into the master node and get to the install screen.
 +
<ul>
 +
<li>If you're not booting from the usb it may be because it is not the top priority in the boot sequence. &nbsp;To change this you'll need to go to the bios setup screen.</li>
 +
<li>While the computer is booting up press f2 or the Delete key. &nbsp;(It could be either or, some manufacturers choose different keys, but that's what it usually is)</li>
 +
<li>Find the settings for something along the lines of "Boot Sequence".</li>
 +
<li>Identify the usb and move it to the top. &nbsp;Save and Reboot.</li>
 +
</ul>
 +
</li>
 +
</ul>
 +
<p>Once you got that all working we can start installing Ubuntu!</p>
 +
<h3>1. Installing Ubuntu For Reals</h3>
 +
<p>The installation is mostly straightforward but just follow along to make sure we're on the same page. &nbsp;There are a few things that need to be done during this process - like not encrypting the home directory.</p>
 +
<ol>
 +
<li>Do not detect keyboard layout - Choose EN - US (or whichever you'd prefer) manually
 +
<ul>
 +
<li>Why? &nbsp;I'm actually not sure, it was just what I was directed to do. &nbsp;Follow directions and stop asking questions. &nbsp;These were directions for installing 12.04, so maybe there was a bug in the autodetect feature.</li>
 +
</ul>
 +
</li>
 +
<li>Set host name to ub&lt;x&gt;, where x is the node number.
 +
<ul>
 +
<li>For example, the master node should be ub0.</li>
 +
</ul>
 +
</li>
 +
<li>Set the name of the new user to "new-user".</li>
 +
<li>Set the account name to "new-user"
 +
<ul>
 +
<li>This might not be an option for you. &nbsp;I don't think I was given this option.</li>
 +
</ul>
 +
</li>
 +
<li>Do not encrypt the home directory.
 +
<ul>
 +
<li>If you do, setting up a shared folder with nfs will be rather difficult.</li>
 +
</ul>
 +
</li>
 +
<li>Partition Method: Guided Use Entire Disk</li>
 +
<li>Remove existing logical volume data
 +
<ul>
 +
<li>Basically just allow it to overwrite whatever it wants.</li>
 +
</ul>
 +
</li>
 +
<li>Leave HTTP proxy information blank</li>
 +
<li>No Automatic Updates</li>
 +
<li>Choose software to install. &nbsp;Just select OpenSSH
 +
<ul>
 +
<li>Note that you actually have to press the spacebar to select the option. &nbsp;If you press enter it will just go on without installing. &nbsp;If you do this, it's ok. &nbsp;You can install it later with sudo apt-get later.</li>
 +
</ul>
 +
</li>
 +
<li>Install GRUB</li>
 +
<li>Hooray!</li>
 +
<li>Repeat this process for your other nodes. &nbsp;You can of course do some now and some later (I did), though it may be easier to just do them all at once.</li>
 +
</ol>
 +
<h3>2. Setting up your hosts file</h3>
 +
<p>You'll want to do this so that you don't have to type in an entire ip address everytime you want to communicate with another node. &nbsp;Write a list of each ip address and which node it corresponds to.</p>
 +
<ul>
 +
<li>Set this up on&nbsp;<em>every&nbsp;</em>node. &nbsp;Go edit the hosts file like so.</li>
 +
</ul>
 +
<p><code>allnodes: sudo nano /etc/hosts/</code></p>
 +
<p>Write to the file so it looks like this</p>
 +
<pre>127.0.0.1 localhost
 +
192.168.1.6 ub0
 +
192.168.1.7 ub1
 +
192.168.1.8 ub2
 +
192.168.1.9 ub3</pre>
 +
<p>&nbsp;Be sure that each name is only used once, and replace the ip addresses with yours. &nbsp;You can find the ip address of each node by using&nbsp;<code>ifconfig</code>in the terminal.</p>
 +
<h3>3. Adding the Cluster User</h3>
 +
<p>Now we'll make a new user that will be our cluster user. &nbsp;This user will have the same name and password on every node. &nbsp;I will call my user "beo", for beowulf. &nbsp;We also need to clarify a user id. &nbsp;Make the id be a number between 900 and 999. &nbsp;That makes it so it is a user that doesn't show up in the usual gui interface.</p>
 +
<p>Take note that I will write which node the command needs to be run on, followed by a colon, before writing the actual command.</p>
 +
<p><code>allnodes: sudo adduser beo --uid 999</code></p>
 +
<h3>4. Sharing Your Home Directory With NFS</h3>
 +
<ul>
 +
<li>Now we need to set up nfs on the master node so that you can share a folder for programs and whatnot. &nbsp;This is so you don't have to install a lot of things on every single node, or put a script on every single computer. &nbsp;As you can imagine that would be quite tedious, especially if you have many nodes.</li>
 +
<li>Install nfs-kernel-server on the master node</li>
 +
</ul>
 +
<p><code>masternode: sudo apt-get install nfs-kernel-server</code></p>
 +
<ul>
 +
<li>And on the children nodes install nfs-common</li>
 +
</ul>
 +
<p><span color="#c7254e"><span>childnode: sudo apt-get install nfs-common</span></span></p>
 +
<ul>
 +
<li>We will need to indicate which folder we want to share in our exports file. &nbsp;Edit it with nano</li>
 +
</ul>
 +
<p><code>masternode: sudo nano /etc/exports</code></p>
 +
<pre>/home/beo *(rw, sync, no_subtree_check)</pre>
 +
<p>Add the above line to the bottom of /etc/exports and restart the server</p>
 +
<p><code>masternode: sudo service nfs-kernel-server restart</code></p>
 +
<ul>
 +
<li>Now here, the york article discusses running a sudo ufw allow from &lt;ipaddress&gt;, but I didn't have to do this. &nbsp;If after you run the next few steps you find that your specified folder is not being shared to your other nodes, you may need to check out the york article I posted near the beginning of this post.</li>
 +
</ul>
 +
<p></p>
 +
<ul>
 +
<li>Now we need to edit our <code>/etc/fstab</code>&nbsp;file and install nfs-common on the child nodes. &nbsp;This will tell us where to copy the incoming shared folder from the master node.</li>
 +
</ul>
 +
<p><code>childnode: sudo apt-get install nfs-common</code></p>
 +
<p><code>childnode: sudo nano /etc/fstab</code></p>
 +
<p>Add this line to the file.</p>
 +
<pre>ub0:/home/beo /home/beo nfs</pre>
 +
<ul>
 +
<li>Now, when the computer boots it should automatically mount the home directory from the master node, to the child nodes' home directories. &nbsp;Check to see with</li>
 +
</ul>
 +
<p><code>childnode: ls /home/beo/</code></p>
 +
<p>This should mirror what is on the master node</p>
 +
<h3>5. Passwordless SSH</h3>
 +
<p>To get communication working smoothly between the nodes, we're going to want to set up passwordless ssh.</p>
 +
<ul>
 +
<li>Get on master node</li>
 +
<li>Change into your cluster user (beo)</li>
 +
</ul>
 +
<p><code>masternode: su beo</code></p>
 +
<p><code>masternode:&nbsp;ssh-keygen</code></p>
 +
<ul>
 +
<li>When asked for a keyphrase, do not enter one. &nbsp;Just leave the field blank, so that it will be "passwordless".</li>
 +
<li>Once that finishes, run the command</li>
 +
</ul>
 +
<p><code>masternode: ssh-copy-id localhost</code></p>
 +
<ul>
 +
<li>Now you should be able to quickly log into the other nodes in your cluster through ssh.</li>
 +
</ul>
 +
<p><code>masternode: ssh ub1</code></p>
 +
<p>If you want to change the default port that is used for ssh, we have to make some changes to config files. &nbsp;Unfortunately we have to do this in all nodes.</p>
 +
<p><code>allnodes: sudo nano /etc/ssh/ssh_config</code></p>
 +
<pre>Port xxxxx</pre>
 +
<p></p>
 +
<p><code>allnodes: sudo nano /etc/ssh/sshd_config</code></p>
 +
<pre>Port xxxxx
 +
PermitRootLogin no</pre>
 +
<p>Note that there is already a line that says "PermitRootLogin". &nbsp;Replace that line with the above.</p>
 +
<h3>6. MPICH</h3>
 +
<p>So there are two main options for setting up a message passing interface on your cluster as far as I can tell. &nbsp;MPICH, and OpenMPI. &nbsp;I am using MPICH. &nbsp;Right before installing mpich2, we might want to install some other software.</p>
 +
<p><code><span>beo@ub0:~$ </span>sudo apt-get install build-essential gfortran gfortran-multilib autoconf</code></p>
 +
<p>Install MPICH2. &nbsp;Now. &nbsp;There are two ways to do this. &nbsp;The easy way, and the way that worked for me. &nbsp;Here's the easy way.</p>
 +
<p><code><span>beo@ub0:~$ </span>sudo apt-get install mpich2</code></p>
 +
<ul>
 +
<li>If this works for you, then great! &nbsp;If not, then you're going to have to do the way that worked for me. &nbsp;I had to install the package manually. &nbsp;See&nbsp;<a href="http://www.mpich.org/static/downloads/3.1.3/mpich-3.1.3-installguide.pdf">this guide</a>&nbsp;for how to install it. &nbsp;Make sure to install it in your shared directory, otherwise you're going to have to install it on every node.</li>
 +
<li>You will need a link to the mpich download. &nbsp;At this time, the download is available at
 +
<ul>
 +
<li>http://www.mpich.org/static/downloads/3.2/mpich-3.2.tar.gz</li>
 +
</ul>
 +
</li>
 +
<li>Use the&nbsp;<code>wget &lt;link&gt;</code> command to download the file and then follow the instructions on the guide.</li>
 +
</ul>
 +
<h3>7. Process Manager</h3>
 +
<p>Once mpich2 is installed we need to set up the machine file so that mpich2 knows how many processes to use in each node. &nbsp;We can make this file somewhere in the shared directory.</p>
 +
<p><code>beo@ub0:~$ sudo nano /home/beo/machinefile</code></p>
 +
<pre>ub0:4
 +
ub1:2
 +
ub2:2
 +
ub3:4</pre>
 +
<p>Where we write the node name and how many processes we want to use separated by a colon.</p>
 +
<p>Great! &nbsp;Now everything is set up and should be working, theoretically. Try to test it with this helloworld program from https://help.ubuntu.com/community/MpichCluster</a>. &nbsp;Place the script in your home directory as "mpi_hello.c"</p>
 +
<pre>#include &lt;stdio.h&gt;
 +
#include &lt;mpi.h&gt;
  
== Installing Ubuntu Server 12.04 ==
+
int main(int argc, char** argv) {
 +
    int myrank, nprocs;
  
Always use default actions except for the following actions:
+
    MPI_Init(&amp;argc, &amp;argv);
 +
    MPI_Comm_size(MPI_COMM_WORLD, &amp;nprocs);
 +
    MPI_Comm_rank(MPI_COMM_WORLD, &amp;myrank);
  
1) Do not use detect keyboard layout. Instead choose English/US manually.
+
    printf("Hello from processor %d of %d\n", myrank, nprocs);
  
2) Set Host name: ubx (where x is the number of the node, e.g., 0 for the master node.)
+
    MPI_Finalize();
 
+
    return 0;
3) Set full name of new user as: apl-admin
+
}</pre>
 
+
<p>You need to compile it and then run it with...</p>
4) Set user name for account as: apl-admin
+
<p><code><span>beo@ub0:~$ mpicc mpi_hello.c -o mpi_hello</span></code></p>
 
+
<p><code><span>beo@ub0:~$ </span> mpiexec -n 8 -f /home/beo/machinefile /home/beo/mpi_hello</code></p>
5) Do not encrypt the home directory.
+
<p>Where -n is the flag for how many processors to use, and -f is the flag for the path to the machinefile.</p>
 
+
<h3>Installing mpi4py</h3>
6) Partition method: Guided-use entire disk
+
<p>If you're like me and you really like using python, you might want to install mpi4py onto your cluster. &nbsp;This was easy enough for me. &nbsp;I just used pip to install the module. &nbsp;</p>
 
+
<ul>
7) Do remove existing logical volume data.
+
<li>Don't use sudo apt-get to install mpi4py. &nbsp;Apparently that has given people problems when being used with mpich2.</li>
 
+
</ul>
8) Leave HTTP proxy information blank
+
<p><code><span color="#c7254e"><span><span>beo@ub0:~$ </span>sudo pip install mpi4py --user</span></span></code></p>
 
+
<ul>
9) Set update management to be: No automatic updates
+
<li>Notice that I added a --user flag in my pip install. &nbsp;This is because if you do not do this, pip will install the module somewhere in the /usr/ folder, but we want it installed in the shared directory.</li>
 
+
</ul>
10) Choose software to install: openSSH (nothing else)
+
<h3>Troubleshooting Errors</h3>
 
+
<p>During this process I had quite a few errors. &nbsp;I'll try to go through the things that happened to me and tell you how I fixed them.</p>
11) Install GRUB: yes
+
<h4>Installing&nbsp;Ubuntu</h4>
 
+
<ul>
12) Once completed update the system.
+
<li>Got an error right off the bat. &nbsp;"Error loading cdrom".
 
+
<ul>
 
+
<li>Moved usb to a new port and hit "retry" and it detected everything fine. &nbsp;Strange Error.</li>
== Settings and software ==
+
</ul>
 
+
</li>
Our cluster is based on this tutorial: https://help.ubuntu.com/community/MpichCluster
+
</ul>
 
+
<h4>Installing mpich</h4>
However, we have the following additions/exceptions:
+
<ul>
 
+
<li>Like I said before, I had problems with using the apt-get install method to install mpich2.
1) To find IP addresses for nodes, log onto the node and type the following command:
+
<ul>
ifconfig
+
<li>Installed manually. &nbsp;Use the guide I posted.</li>
 
+
<li>http://www.mpich.org/static/downloads/3.1.3/mpich-3.1.3-installguide.pdf</li>
Then look for the inet addr in the eth0 section.
+
</ul>
 
+
</li>
1) When prompted to give an SSH-passphrase, leave this field blank.
+
<li>"cannot find hydraproxy file"
 
+
<ul>
2) In all nodes change etc/ssh/ssh_config to have the following line:
+
<li>This file is installed when you install mpich2. &nbsp;What I had to do is add its location to my path variable</li>
    Port 41122
+
<li>When all was said and done, my .bashrc file had these lines added to it</li>
 
+
<li><code>sudo nano ~/.bashrc</code></li>
3) In all nodes change etc/ssh/sshd_config, add the following line:
+
<li>
    Port 41122
+
<pre>export PATH=/home/beo/mpich-install/bin:/home/beo/mpich-install/lib:$PATH
    PermitRootLogin no (NOTE: this should replace the line which previously said "PermitRootLogin yes")
+
export LD_LIBRARY_PATH=/usr/lib:/home/beo/mpich-install/lib:$LD_LIBRARY_PATH
 
+
export LD_LIBRARY_PATH=/home/beo/.local/python2.7/site-packages:$LD_LIBRARY_PATH
4) Before installing MPICH2, run the following commands:
+
export LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu:$LD_LIBRARY_PATH
    sudo apt-get install build-essentials gfortran gfortran-multilib autoconf
+
export HYDRA_HOST_FILE=/home/beo/machinefile
 +
export PYTHONPATH=/home/beo/.local/python2.7/site-packages:$PYTHONPATH
 +
export PYTHONPATH=/home/beo/mpich-install/lib:$PYTHONPATH</pre>
 +
</li>
 +
<li>The HYDRA_HOST_FILE variable didn't actually do what I was hoping it would do, so that line may be unecessary.</li>
 +
</ul>
 +
</li>
 +
<li>Some error about not being able to find libmpich.so files
 +
<ul>
 +
<li><code>sudo apt-get install libcr-dev</code></li>
 +
<li>I actually ran that on each node</li>
 +
</ul>
 +
</li>
 +
<li>Problems with getting nodes to communicate
 +
<ul>
 +
<li>This was a strange error, but when I was running python programs on the cluster and trying to get the nodes to exchange information, it just refused to work because it couldn't find libmpich.so.10</li>
 +
<li>For this I actually physically moved the file to somewhere on the path variable. &nbsp;Also, I couldn't find a file called libmpich.so.10, but I had one called libmpich.so.10.4. &nbsp;So here's what I did
 +
<ul>
 +
<li>Move libmpich.so.10.4 from&nbsp;<code>/usr/lib/x86_64-linux-gnu</code> to <code>/home/beo/mpich-install/lib</code> then</li>
 +
</ul>
 +
</li>
 +
<li>Create a symbolic link while in the mpich-install/lib directory
 +
<ul>
 +
<li><code>sudo ln -s libmpich.so.10.0.4 libmpich.so.10</code></li>
 +
</ul>
 +
</li>
 +
</ul>
 +
</li>
 +
</ul>
 +
<h4>Python Packages "not installed"</h4>
 +
<ul>
 +
<li>Errors where after installing a python package via <code>pip install &lt;package&gt; --user</code>, other nodes could not import the module.
 +
<ul>
 +
<li>Saw that the nodes did not have read/write permissions in the shared python package folder. &nbsp;Changed permissions with
 +
<ul>
 +
<li><code>sudo chown -r 755&nbsp;/home/beo/.local/</code></li>
 +
</ul>
 +
</li>
 +
</ul>
 +
</li>
 +
</ul>

Latest revision as of 18:18, 12 April 2016

Building a Beowulf Cluster (MPICH2)

Prerequisites

Let's Go

  1. Get a copy of Ubuntu 14.04 Server.  If you really want to, you can install a gui interface onto it later, like unity.

1? Install Ubuntu

This in itself can be a process, and is slow.  At least on my computers it was.

  • Make the bootable USB.
    • At the time of writing this, you can download Ubuntu 14.04 Server here.
    • http://www.ubuntu.com/download/server
    • I'm sure that if a newer version comes out, it should work as well, although I tried initially with 15.10 (Desktop) and had some trouble with that.
  • Choose a master node
    • People recommend that the master node be the most powerful.  Of course if you are using identical computers just choose whichever.  In my case, I had 1 computer with 4 cores, whereas the rest had 2.
  • Plop the usb into the master node and get to the install screen.
    • If you're not booting from the usb it may be because it is not the top priority in the boot sequence.  To change this you'll need to go to the bios setup screen.
    • While the computer is booting up press f2 or the Delete key.  (It could be either or, some manufacturers choose different keys, but that's what it usually is)
    • Find the settings for something along the lines of "Boot Sequence".
    • Identify the usb and move it to the top.  Save and Reboot.

Once you got that all working we can start installing Ubuntu!

1. Installing Ubuntu For Reals

The installation is mostly straightforward but just follow along to make sure we're on the same page.  There are a few things that need to be done during this process - like not encrypting the home directory.

  1. Do not detect keyboard layout - Choose EN - US (or whichever you'd prefer) manually
    • Why?  I'm actually not sure, it was just what I was directed to do.  Follow directions and stop asking questions.  These were directions for installing 12.04, so maybe there was a bug in the autodetect feature.
  2. Set host name to ub<x>, where x is the node number.
    • For example, the master node should be ub0.
  3. Set the name of the new user to "new-user".
  4. Set the account name to "new-user"
    • This might not be an option for you.  I don't think I was given this option.
  5. Do not encrypt the home directory.
    • If you do, setting up a shared folder with nfs will be rather difficult.
  6. Partition Method: Guided Use Entire Disk
  7. Remove existing logical volume data
    • Basically just allow it to overwrite whatever it wants.
  8. Leave HTTP proxy information blank
  9. No Automatic Updates
  10. Choose software to install.  Just select OpenSSH
    • Note that you actually have to press the spacebar to select the option.  If you press enter it will just go on without installing.  If you do this, it's ok.  You can install it later with sudo apt-get later.
  11. Install GRUB
  12. Hooray!
  13. Repeat this process for your other nodes.  You can of course do some now and some later (I did), though it may be easier to just do them all at once.

2. Setting up your hosts file

You'll want to do this so that you don't have to type in an entire ip address everytime you want to communicate with another node.  Write a list of each ip address and which node it corresponds to.

  • Set this up on every node.  Go edit the hosts file like so.

allnodes: sudo nano /etc/hosts/

Write to the file so it looks like this

127.0.0.1	localhost
192.168.1.6	ub0
192.168.1.7	ub1
192.168.1.8	ub2
192.168.1.9	ub3

 Be sure that each name is only used once, and replace the ip addresses with yours.  You can find the ip address of each node by using ifconfigin the terminal.

3. Adding the Cluster User

Now we'll make a new user that will be our cluster user.  This user will have the same name and password on every node.  I will call my user "beo", for beowulf.  We also need to clarify a user id.  Make the id be a number between 900 and 999.  That makes it so it is a user that doesn't show up in the usual gui interface.

Take note that I will write which node the command needs to be run on, followed by a colon, before writing the actual command.

allnodes: sudo adduser beo --uid 999

4. Sharing Your Home Directory With NFS

  • Now we need to set up nfs on the master node so that you can share a folder for programs and whatnot.  This is so you don't have to install a lot of things on every single node, or put a script on every single computer.  As you can imagine that would be quite tedious, especially if you have many nodes.
  • Install nfs-kernel-server on the master node

masternode: sudo apt-get install nfs-kernel-server

  • And on the children nodes install nfs-common

childnode: sudo apt-get install nfs-common

  • We will need to indicate which folder we want to share in our exports file.  Edit it with nano

masternode: sudo nano /etc/exports

/home/beo *(rw, sync, no_subtree_check)

Add the above line to the bottom of /etc/exports and restart the server

masternode: sudo service nfs-kernel-server restart

  • Now here, the york article discusses running a sudo ufw allow from <ipaddress>, but I didn't have to do this.  If after you run the next few steps you find that your specified folder is not being shared to your other nodes, you may need to check out the york article I posted near the beginning of this post.

  • Now we need to edit our /etc/fstab file and install nfs-common on the child nodes.  This will tell us where to copy the incoming shared folder from the master node.

childnode: sudo apt-get install nfs-common

childnode: sudo nano /etc/fstab

Add this line to the file.

ub0:/home/beo /home/beo nfs
  • Now, when the computer boots it should automatically mount the home directory from the master node, to the child nodes' home directories.  Check to see with

childnode: ls /home/beo/

This should mirror what is on the master node

5. Passwordless SSH

To get communication working smoothly between the nodes, we're going to want to set up passwordless ssh.

  • Get on master node
  • Change into your cluster user (beo)

masternode: su beo

masternode: ssh-keygen

  • When asked for a keyphrase, do not enter one.  Just leave the field blank, so that it will be "passwordless".
  • Once that finishes, run the command

masternode: ssh-copy-id localhost

  • Now you should be able to quickly log into the other nodes in your cluster through ssh.

masternode: ssh ub1

If you want to change the default port that is used for ssh, we have to make some changes to config files.  Unfortunately we have to do this in all nodes.

allnodes: sudo nano /etc/ssh/ssh_config

Port xxxxx

allnodes: sudo nano /etc/ssh/sshd_config

Port xxxxx
PermitRootLogin no

Note that there is already a line that says "PermitRootLogin".  Replace that line with the above.

6. MPICH

So there are two main options for setting up a message passing interface on your cluster as far as I can tell.  MPICH, and OpenMPI.  I am using MPICH.  Right before installing mpich2, we might want to install some other software.

beo@ub0:~$ sudo apt-get install build-essential gfortran gfortran-multilib autoconf

Install MPICH2.  Now.  There are two ways to do this.  The easy way, and the way that worked for me.  Here's the easy way.

beo@ub0:~$ sudo apt-get install mpich2

7. Process Manager

Once mpich2 is installed we need to set up the machine file so that mpich2 knows how many processes to use in each node.  We can make this file somewhere in the shared directory.

beo@ub0:~$ sudo nano /home/beo/machinefile

ub0:4
ub1:2
ub2:2
ub3:4

Where we write the node name and how many processes we want to use separated by a colon.

Great!  Now everything is set up and should be working, theoretically. Try to test it with this helloworld program from https://help.ubuntu.com/community/MpichCluster</a>.  Place the script in your home directory as "mpi_hello.c"

#include <stdio.h>
#include <mpi.h>

int main(int argc, char** argv) {
    int myrank, nprocs;

    MPI_Init(&argc, &argv);
    MPI_Comm_size(MPI_COMM_WORLD, &nprocs);
    MPI_Comm_rank(MPI_COMM_WORLD, &myrank);

    printf("Hello from processor %d of %d\n", myrank, nprocs);

    MPI_Finalize();
    return 0;
}

You need to compile it and then run it with...

beo@ub0:~$ mpicc mpi_hello.c -o mpi_hello

beo@ub0:~$ mpiexec -n 8 -f /home/beo/machinefile /home/beo/mpi_hello

Where -n is the flag for how many processors to use, and -f is the flag for the path to the machinefile.

Installing mpi4py

If you're like me and you really like using python, you might want to install mpi4py onto your cluster.  This was easy enough for me.  I just used pip to install the module.  

  • Don't use sudo apt-get to install mpi4py.  Apparently that has given people problems when being used with mpich2.

beo@ub0:~$ sudo pip install mpi4py --user

  • Notice that I added a --user flag in my pip install.  This is because if you do not do this, pip will install the module somewhere in the /usr/ folder, but we want it installed in the shared directory.

Troubleshooting Errors

During this process I had quite a few errors.  I'll try to go through the things that happened to me and tell you how I fixed them.

Installing Ubuntu

  • Got an error right off the bat.  "Error loading cdrom".
    • Moved usb to a new port and hit "retry" and it detected everything fine.  Strange Error.

Installing mpich

  • Like I said before, I had problems with using the apt-get install method to install mpich2.
  • "cannot find hydraproxy file"
    • This file is installed when you install mpich2.  What I had to do is add its location to my path variable
    • When all was said and done, my .bashrc file had these lines added to it
    • sudo nano ~/.bashrc
    • export PATH=/home/beo/mpich-install/bin:/home/beo/mpich-install/lib:$PATH
      export LD_LIBRARY_PATH=/usr/lib:/home/beo/mpich-install/lib:$LD_LIBRARY_PATH
      export LD_LIBRARY_PATH=/home/beo/.local/python2.7/site-packages:$LD_LIBRARY_PATH
      export LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu:$LD_LIBRARY_PATH
      export HYDRA_HOST_FILE=/home/beo/machinefile
      export PYTHONPATH=/home/beo/.local/python2.7/site-packages:$PYTHONPATH
      export PYTHONPATH=/home/beo/mpich-install/lib:$PYTHONPATH
    • The HYDRA_HOST_FILE variable didn't actually do what I was hoping it would do, so that line may be unecessary.
  • Some error about not being able to find libmpich.so files
    • sudo apt-get install libcr-dev
    • I actually ran that on each node
  • Problems with getting nodes to communicate
    • This was a strange error, but when I was running python programs on the cluster and trying to get the nodes to exchange information, it just refused to work because it couldn't find libmpich.so.10
    • For this I actually physically moved the file to somewhere on the path variable.  Also, I couldn't find a file called libmpich.so.10, but I had one called libmpich.so.10.4.  So here's what I did
      • Move libmpich.so.10.4 from /usr/lib/x86_64-linux-gnu to /home/beo/mpich-install/lib then
    • Create a symbolic link while in the mpich-install/lib directory
      • sudo ln -s libmpich.so.10.0.4 libmpich.so.10

Python Packages "not installed"

  • Errors where after installing a python package via pip install <package> --user, other nodes could not import the module.
    • Saw that the nodes did not have read/write permissions in the shared python package folder.  Changed permissions with
      • sudo chown -r 755 /home/beo/.local/