gethostbyname failed

Symptom

When the mpirun command is executed, the error message "gethostbyname failed" is displayed, as shown below.

# mpirun -n 8 ./bin/all_reduce_test -b 8K -e 64M -f 2 -d fp32 -o sum -p 8
Fatal error in MPI_Init: Other MPI error, error stack:
MPIR_Init_thread(474)...................:
MPID_Init(190)..........................: channel initialization failed
MPIDI_CH3_Init(89)......................:
MPID_nem_init(320)......................:
MPID_nem_tcp_init(173)..................:
MPID_nem_tcp_get_business_card(420):
MPID_nem_tcp_init(379)..................: gethostbyname failed, HW-AI-LC-1-1 (errno 2)

Solution

Add the IP address and host name of the current node to the /etc/hosts file. For example, if the host name is HW-AI-LC-1-1 and the IP address is 172.16.0.100, add the following information to the /etc/hosts file:

172.16.0.100 HW-AI-LC-1-1