Search code examples
craspberry-pimpiscpnfs

How to avoid copying executable from master node to slaves in MPI?


I am trying to execute my MPI program which i wrote in C on a cluster but every time before executing it on the cluster i have to copy the executable from the master to the slave node as seen below.

pi@raspberrypi ~ $ mpicc -o test sir.c
pi@raspberrypi ~ $ scp test pi@192.168.1.38:/home/pi/test
test                                          100% 1142KB   1.1MB/s   00:01    

pi@raspberrypi ~ $ mpiexec -f pifile -n 2 ./test

The pifile is my hostname file. Its contents are as follows

92.168.1.37
192.168.1.38

Now if i don't copy the executable then this is the error i get

pi@raspberrypi ~ $ mpiexec -f pifile -n 2 ./test
[proxy:0:1@raspberrypi2] HYDU_create_process (/home/pi/mpich3/mpich-
3.0.4/src/pm/hydra/utils/launch/launch.c:75): execvp error on file ./test (No such file or 
directory)

===================================================================================
=   BAD TERMINATION OF ONE OF YOUR APPLICATION PROCESSES
=   EXIT CODE: 255
=   CLEANING UP REMAINING PROCESSES
=   YOU CAN IGNORE THE BELOW CLEANUP MESSAGES
===================================================================================

I would like to know how to avoid copying the executable as it does not make sense to do so in a big cluster.

In case you are suggesting an NFS implementation please explain how to go about it as i have no experience about the same.

Thank You


Solution

  • I solved the problem by setting up a NFS. Here's what i did.

    NOTE: This is a very minimal NFS implementation.

    On the master node

    Install NFS server

    $ sudo apt-get install rpcbind nfs-kernel-server
    

    Edit /etc/exports and add the shares:

    /home @my_slave_ip(rw,sync,no_subtree_check)
    /usr/local @my_slave_ip(rw,sync,no_subtree_check)
    

    After setting up /etc/exports, export the shares:

    sudo exportfs -ra
    

    Restart rpcbind

    $ sudo service rpcbind restart
    

    The NFS kernel server will also require a restart:

    sudo service nfs-kernel-server restart
    

    Congrats the master node is now ready :)

    Now on the slave node do the following

    Installation

    sudo apt-get install rpcbind nfs-common
    

    And then

    sudo mount ServerIP:/folder/already/setup/to/be/shared /home/username/folder/in/your/local/computer
    
    NOTE: Please do not mount your home directory as it will not work. Rather create a new folder 
    in the home directory and mount that folder.
    

    Heres what i did

    pi@raspberrypi ~ $ mkdir test         (On master)
    pi@raspberrypi2 ~ $ mkdir test        (On slave)
    

    On the slave then i did this

    pi@raspberrypi2 ~/test $ sudo mount 192.168.1.37:/home/pi/test /home/pi/test
    

    and it works :) hope it helps.

    References

    http://help.ubuntu.com/community/SettingUpNFSHowTo#NFS_Server https://raspberrypi.stackexchange.com/questions/10403/nfs-server-not-starting-portmapper-is-not-running