树莓派2搭建双机并行计算环境

0、准备材料

2个树莓派2,刷ubuntu14.04,安装好编译环境

地址:192.168.3.17,192.168.3.18

下载MPICH2源码

以下两个树莓派都要设置

1、安装相关软件

sudo apt-get install gfortran

sudo apt-get install mpich2

解压源码,并编译example下的cpi.c

mpicc cpi.c -o cpi 

2、相关设置

vi /etc/hosts 添加

192.168.3.17Yrpi2-1

192.168.3.18Yrpi2-2

新建文件machinefile,添加

192.168.3.17

192.168.3.18

设置无密码登陆

ssh-keygen -t rsa -C “ywz@ywz”

cat ~/.ssh/id_rsa.pub | ssh ubuntu@192.168.3.18 “mkdir .ssh;cat >> .ssh/authorized_keys”

做下无密码登陆测试 ssh 192.168.3.18 看是否已经登陆Yrpi2-2

测试

mpiexec -f machinefile -n 4 ./cpi

Process 1 of 2 is on Yrpi2-2

Process 0 of 2 is on Yrpi2-1

pi is approximately 3.1415926544231318, Error is 0.0000000008333387

wall clock time = 0.003329