遵循这些准则MpichClusterUbuntu,我尝试使用装有Ubuntu 18.04.01 Server Edition的PC和装有Ubuntu 18.04.02 Desktop的笔记本电脑执行我的第一个mpi程序。直到本指南的第11步,一切正常,没有任何问题。
我设置了一个名为主机的机器文件 这两行:
192.168.1.7 # first 'master' node: the PC
192.168.1.5 # second node: the laptop
编译准则中包含的非常简单的示例文件后,无需:
#include <stdio.h>
#include <mpi.h>
int main(int argc, char** argv) {
int myrank, nprocs;
MPI_Init(&argc, &argv);
MPI_Comm_size(MPI_COMM_WORLD, &nprocs);
MPI_Comm_rank(MPI_COMM_WORLD, &myrank);
printf("Hello from processor %d of %d\n", myrank, nprocs);
MPI_Finalize();
return 0;
}
mpiu@pc01:~$ mpicc mpi_hello.c -o mpi_hello
在不考虑机器文件'hosts'的情况下执行,这是输出:
mpiu@pc01:~$ mpiexec -n 8 ./mpi_hello
------------------------------------------------------------------
[[27419,1],0]: A high-performance Open MPI point-to-point messaging
module was unable to find any relevant network interfaces:
Module: OpenFabrics (openib)
Host: pc01
Another transport will be used instead, although this may result in
lower performance.
NOTE: You can disable this warning by setting the MCA parameter
btl_base_warn_component_unused to 0.
----------------------------------------------------------------
Hello from processor 1 of 8
Hello from processor 2 of 8
Hello from processor 5 of 8
Hello from processor 6 of 8
Hello from processor 0 of 8
Hello from processor 3 of 8
Hello from processor 7 of 8
Hello from processor 4 of 8
[pc01:25010] 7 more processes have sent help message help-mpi-btl-
base.txt / btl:no-nics
[pc01:25010] Set MCA parameter "orte_base_help_aggregate" to 0 to see all
help / error messages
当执行调用机器文件“ hosts”时,执行保持空闲状态,而不会产生任何输出:
mpiu@pc01:~$ mpiexec -n 8 -machinefile hosts ./mpi_hello
PS: 这是“主”节点(PC)中/etc/netplan/50-cloud-init.yaml的内容:
network:
ethernets:
enp3s0:
#addresses: []
#dhcp4: true
addresses: [192.168.1.7/24]
gateway4: 192.168.1.1
nameservers:
addresses: [8.8.8.8,8.8.4.4]
dhcp4: no
version: 2
更新: 在Gilles的正确评论之后,我删除了openmpi,我猜它是以前安装的。
现在执行准则MpichClusterUbuntu18.04的步骤11: A)不调用机器文件:
marco@pc01:/mirror$ mpiexec -n 8 ./mpi_hello
Hello from processor 0 of 8
Hello from processor 1 of 8
Hello from processor 3 of 8
Hello from processor 5 of 8
Hello from processor 6 of 8
Hello from processor 7 of 8
Hello from processor 2 of 8
Hello from processor 4 of 8
B)但是将机器文件称为“主机”:
marco@pc01:/mirror$ mpiexec -n 8 -machinefile /home/mpiu/hosts
./mpi_hello
ssh: Could not resolve hostname pc0: Temporary failure in name resolution
ssh: Could not resolve hostname riccarcohp: Temporary failure in name
resolution
^C[mpiexec@pc01] Sending Ctrl-C to processes as requested
[mpiexec@pc01] Press Ctrl-C again to force abort
[mpiexec@pc01] HYDU_sock_write (utils/sock/sock.c:286): write error (Bad
file descriptor)
[mpiexec@pc01] HYD_pmcd_pmiserv_send_signal (pm/pmiserv
/pmiserv_cb.c:177): unable to write data to proxy
[mpiexec@pc01] ui_cmd_cb (pm/pmiserv/pmiserv_pmci.c:79): unable to send
signal downstream
[mpiexec@pc01] HYDT_dmxu_poll_wait_for_event (tools/demux
/demux_poll.c:77): callback returned error status
[mpiexec@pc01] HYD_pmci_wait_for_completion (pm/pmiserv
/pmiserv_pmci.c:198): error waiting for event
[mpiexec@pc01] main (ui/mpich/mpiexec.c:340): process manager error
waiting for completion
仅将IP地址放入机器文件“主机”后
mpiu@pc01:/mirror$ mpiexec -n 8 -machinefile /home/mpiu/hosts ./mpi_hello
Permission denied, please try again.
Permission denied, please try again.
mpiu@192.168.1.5: Permission denied (publickey,password).
但是从PC到笔记本电脑,我都可以毫无问题地进行SSH:
mpiu@pc01:/mirror$ ssh 192.168.1.5
mpiu@192.168.1.5's password:
mpiu@riccardo-HP-Laptop-15-da0xxx:~$
现在看来已经解决了,即使我第三次重复,也要执行相同的步骤:
这些是我在pc01(和riccardohp(笔记本电脑))之间设置无密码SSH的步骤:
marco@pc01:/$ su - mpiu
Password:
mpiu@pc01:~$ ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/mpiu/.ssh/id_rsa):
Created directory '/home/mpiu/.ssh'.
为了简化起见,我省略了密码:
Your identification has been saved in /home/mpiu/.ssh/id_rsa.
Your public key has been saved in /home/mpiu/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:..... mpiu@pc01
The key's randomart image is:
+---[RSA 2048]----+
...................
...................
+----[SHA256]-----+
我将公钥从pc01复制到笔记本电脑上:
mpiu@pc01:~$ ssh-copy-id 192.168.1.5
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/home
/mpiu/.ssh/id_rsa.pub"
The authenticity of host '192.168.1.5 (192.168.1.5)' can't be
established.
ECDSA key fingerprint is SHA256:.......................
Are you sure you want to continue connecting (yes/no)? yes
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to
filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are
prompted now it is to install the new keys
mpiu@192.168.1.5's password:
Number of key(s) added: 1
Now try logging into the machine, with: "ssh '192.168.1.5'"
and check to make sure that only the key(s) you wanted were added.
mpiu@pc01:~$ ssh '192.168.1.5'
Welcome to Ubuntu 18.04.2 LTS (GNU/Linux 4.18.0-16-generic x86_64)
mpiu@riccardo-HP-Laptop-15-da0xxx:~$
因此,显然,pc01和笔记本电脑之间的ssh连接似乎工作正常……
mpiu@riccardo-HP-Laptop-15-da0xxx:~$ ^C
mpiu@riccardo-HP-Laptop-15-da0xxx:~$ logout
Connection to 192.168.1.5 closed.
mpiu@pc01:~$ cd /
mpiu@pc01:/$ cd mirror
mpiu@pc01:/mirror$ mpicc mpi_hello.c -o mpi_hello
gcc: error: mpi_hello.c: No such file or directory
mpiu@pc01:/mirror$ nano mpi_hello.c
mpiu@pc01:/mirror$ mpicc mpi_hello.c -o mpi_hello
mpiu@pc01:/mirror$ mpiexec -n 8 ./mpi_hello
Hello from processor 0 of 8
Hello from processor 1 of 8
Hello from processor 2 of 8
Hello from processor 3 of 8
Hello from processor 4 of 8
Hello from processor 5 of 8
Hello from processor 6 of 8
Hello from processor 7 of 8
我将文件主机放在/ mirror中:
192.168.1.7
192.168.1.5
mpiu@pc01:/mirror$ mpiexec -n 8 -machinefile hosts ./mpi_hello
Hello from processor 2 of 8
Hello from processor 4 of 8
Hello from processor 6 of 8
Hello from processor 0 of 8
Hello from processor 1 of 8
Hello from processor 3 of 8
Hello from processor 5 of 8
Hello from processor 7 of 8
马可