28

I don't understand the error message. I am trying to do is to run a MPICH2 application after I installed mpich2 version 1.4 or 1.5 to /opt/mpich2 (both version failed with the same error). My MPI application was compiled with 1.3 but I am able to run it with mpi 1.4 on another workstation. I am testing it on Ubuntu 12.04.

Fatal error in PMPI_Init_thread: Other MPI error, error stack:
MPIR_Init_thread(467)..............: 
MPID_Init(177).....................: channel initialization failed
MPIDI_CH3_Init(70).................: 
MPID_nem_init(319).................: 
MPID_nem_tcp_init(171).............: 
MPID_nem_tcp_get_business_card(418): 
MPID_nem_tcp_init(377).............: gethostbyname failed, localhost (errno 3)

6 Answers 6

22

Solution for macOS

I stumbled upon this issue on macOS 10.12.1.

The solution is to add 127.0.0.1 computername.local to /etc/hosts. Your file will look more or less like this:

##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting.  Do not change this entry.
##
127.0.0.1   localhost
127.0.0.1   computername.local
255.255.255.255 broadcasthost
::1             localhost 

You can change/check your computer's name if you go to System Preferences > Sharing > Computer Name.

2
  • In my case, my computer name somehow changed. I think it should stay the same as you compile and install MPI. When I changed it back, everything worked! But still, thanks for pointing out the right direction! Jun 20, 2018 at 7:10
  • I had to add just 127.0.0.1 computername (no .local) on MacOS 10.14.6 May 20, 2020 at 14:17
17

What worked for me was the following:

Make sure your hostname is the same for 1 and 2 below:

  1. terminal hostname
  2. "/etc/hosts" hostname

So if you type cat /etc/hosts in terminal it should look like:

// 127.0.0.1       my_hostname

My hostname was not the same for 1 and 2 for me. Once I changed them to match then my mpi program would execute.

To change your terminal hostname type the following: sudo scutil --set HostName my_new_host_name

To change your /etc/hosts hostname type the following: sudo nano /etc/hosts

and then add the line

127.0.0.1       my_new_hostname
1
6

This error indicates that there's a problem resolving localhost. Check your /etc/hosts file, make certain that you have localhost correctly defined here, it should be pointing to 127.0.0.1. Try using ssh to connect to localhost, make sure that works as well.

2
  • ssh to localhost works. I will try to look for other things and come back later. Apr 25, 2014 at 12:54
  • 6
    Here is what I had to do to solve this: set a proper hostname via sudo scutil --set HostName and then add the new hostname (say my_computer.local) to /etc/hosts like 127.0.0.1 my_computer.local. Also you have to enable SSH access in the "Sharing" settings and add your public key to the authorized_keys file (cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys).
    – herrherr
    Jun 6, 2014 at 11:24
2

Being the question different, the answer is probably the same I gave time ago for OpenMPI: gethostname() function missing in openMPI

The MPI portable solution is to use MPI_Get_processor_name()

1
  • Thanks for the answer. I missed the first line of the error message. Apr 16, 2014 at 15:20
0

adding -host localhost to the command line solved this for me. Suggested in https://github.com/pmodels/mpich/issues/4710#issuecomment-661933489

e.g.

mpiexec -host localhost -np 4 ./testExecutable
-1

Maybe your /dev/shm is full, try to clean it.

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.