Archive for September, 2014

Recently I tried to build a cluster out of my Laptop and Desktop using Ubuntu. Following is the step by step guideline on how to do same.

Configuration:
My PC is running Ubuntu 14.04 i386 and My Laptop is running Ubuntu x86_64 version. So yes, you can build a cluster successfully out of two different systems.
Both the systems should be on the same subnet.
In this case, IP address of my Laptop : 192.168.1.102/24
IP of my PC : 192.168.1.103/24

password-less ssh login for both the systems
Followed the tutorial from
http://www.tecmint.com/ssh-passw…

apt-get install following packages on both the systems:
libopenmpi-dev
openmpi-bin
mpich2

and other basic developer tools such as gcc etc. which we normally need for development.
In my case openmpi libraries got installed to
/usr/lib/openmpi/lib/
So I added the following to my .bashrc file:
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib/openmpi/lib/

Now your system is ready.
Lets test it now.
Open a editor of your choice (I prefer vim) and type the following program:
#include <stdio.h>
#include <stdlib.h>
#include <mpi.h>
int main ( int argc, char **argv )
{

int rank, size;
MPI_Init ( &argc, &argv );
MPI_Comm_rank ( MPI_COMM_WORLD, &rank );
MPI_Comm_size ( MPI_COMM_WORLD, &size );
printf ( “Hi, I am %d of %d\n”, rank, size );
system ( “hostname” );
MPI_Finalize ();
exit ( EXIT_SUCCESS );
}

Save the program as hello.c in your home directory.
Now compile the above program as
mpicc -o hello hello.c

mpicc is nothing but a fancy wrapper of gcc.
repeat the above steps for another system also.

Create a file named hosts.txt (it can be any name) on either of the machine with the following contents.
192.168.1.102
192.168.1.103

You can replace above ip addresses with the ones you have for your nodes.
Now lets run it as follows:
mpirun -np 4 -hostfile hosts.txt ~/hello

You will see 4 outputs most probably two from either of the systems.
Hi, I am 0 of 4
jkapil-desktop
Hi, I am 1 of 4
jkapil-laptop
Hi, I am 2 of 4
jkapil-desktop
Hi, I am 3 of 4
jkapil-laptop

The order may get shuffled depending on the scheduling of the processes on both systems and which system return the output first.
But yes, it did not serve my purpose as I will have to search for now MPI enabled equivalents of the application I am using but yes, its a start.
Welcome to the world of Supercomputing.

Here is a link to Quora Post where I posted this in original.

With Ubuntu 14.04, by default there are no options to modify the brightness of the system. However there is an app for same called brightness controller. But I had problems setting up the brightness for the boot time itself. So I decided to find out how did the Brightness Controller work. I downloaded the source code from the git page and found out that internally it uses the Xrandr . So I added the Xrandr command to my bashrc file and now I don’t have to set the brightness every time.
jkapil@jkapil-desktop:~$ xrandr
Screen 0: minimum 320 x 200, current 1366 x 768, maximum 32767 x 32767
VGA1 connected primary 1366x768+0+0 (normal left inverted right x axis y axis) 0mm x 0mm
1366x768       60.0*+
1024x768       75.1     70.1     60.0
800x600        72.2     75.0     60.3
640x480        75.0     72.8     60.0
720x400        70.1
HDMI1 disconnected (normal left inverted right x axis y axis)
HDMI2 disconnected (normal left inverted right x axis y axis)
DP1 disconnected (normal left inverted right x axis y axis)
DP2 disconnected (normal left inverted right x axis y axis)
VIRTUAL1 disconnected (normal left inverted right x axis y axis)

This gives you the output names associated with your display. In my case its VGA1. To set the brightness,

$xrandr --output VGA1 --brightness 0.7

–brightness value is in between 0 and 1 and is a fraction. First execute in terminal to find out the brightness value soothing to your eye and then put that value with the above command in your .bashrc file in home directory.