How to run google cloud mpi project with Linux
- Run
ssh-keygen -t rsain your terminal - Enter filename for key(eg. )
- Enter your password
- Run
scp <USER>.pub <USER>@<EXTERNAL_IP_OF_FIRST_INSANCE>:/home/<USER>/.ssh - Add it to
authorized_keys. To do this runcat .ssh/<USER>.pub >> .ssh/authorized_keys
- vCPU → 4 vCPU
- Boot disk: Ubuntu 17.10 LTS
- Allow HTTP traffic
- Run following commands:
sudo apt-get install mpichsudo apt-get install gcc - Upload and compile your code
- Upload your private key and run following commands:
evalssh-agentssh-add <PRIVATE_KEY_NAME>
To do this try to SSH into machine ssh -i <USER> <USER>@<EXTERNAL_IP_OF_FIRST_INSANCE>.
You should be greated with welcome message.
- Create snapshot based on the instance-1
- Create instance-2 based on the snapshot.
- Run
ssh -i <USER> <USER>@<EXTERNAL_IP_OF_SECOND_INSTANCE> - You should see welcome message.
We need this to be able to run mpirun on the instance-1.
- Run
scp <USER> <USER>@<EXTERNAL_IP_OF_FIRST_INSANCE>:/home/<USER>/.ssh. - Rename key to
id_rsa. Runmv .ssh/<USER> .ssh/id_rsa. - To verify that everything works run
ssh <INTERNAL_IP_OF_SECOND_INSTANCE>. - You should see welcome message.
We need to provide IP addresses to MPI.
- Create
hostfileon instance-1. Runtouch hostfile. - Run
echo <INTERNAL_IP_OF_THE_INSTANCE> >> hostfilefor each machine in the cluster.
Now you can run your program on the cluster.
mpirun -np <NUMBER_OF_PROCESSES> --hostfile <HOSTFILE_NAME> ./<APPLICATION>