Step 1 install the SSH server and client in Ubuntu to open the new version. Type openssh in all and select openssh-client and openssh-server to mark the application installation, you can also directly run $ sudoapt-getinstallopenssh-clientopenssh-server to install MPICH in step 2, enter mpi in all, and select mpi-bin, mpi-doc, libmp ich1.0-d.
Step 1 install the SSH server and client in Ubuntu
Open the new version, type openssh in all, select openssh-client and openssh-server to mark the application installation, or directly execute
$ Sudo apt-get install openssh-client openssh-server
Step 2 install MPICH
Open the new version, type mpi in all, and select mpi-bin, mpi-doc, libmp ich1.0-dev to install the application.
$ Sudo apt-get install mpi-bin mpi-doc libmp ich1.0-dev
Step 3 test installation
$ Touch hello. c
Enter the following content to hello. c
1 # include
2 # include
3 int main (int argc, char * argv [])
4 {
5 int npes, myrank;
6 MPI_Init (& argc, & argv );
7 MPI_Comm_size (MPI_COMM_WORLD, & npes );
8 MPI_Comm_rank (MPI_COMM_WORLD, & myrank );
9 printf ("From process % d out of % d, Hello World! \ N ", myrank, npes );
10 MPI_Finalize ();
11}
$ Mpicc-o hello. c
$ Mpirun-np 2 hello # It should output two Hello messages. You may need to enter the password in the middle. If you do not want to enter the password, see step 4.
Step 4: cancel the SSH Password
$ Ssh-keygen-t dsa # enter the password in the middle and press enter to generate the file ~ /. Ssh/id_dsa.pub
$ Cat id_dsa.pub> authorized_keys
$ Mpirun-np 2 hello # there should be no password input prompt