切换互联网连接后gethostbyname失败

Don*_*nna 8 macos mpi osx-yosemite

在切换wifi主机后运行MPI作业时,我经常(但并不总是)遇到以下错误.

Fatal error in MPI_Init: Other MPI error, error stack:
MPIR_Init_thread(498)..............: 
MPID_Init(187).....................: channel initialization failed
MPIDI_CH3_Init(89).................: 
MPID_nem_init(320).................: 
MPID_nem_tcp_init(171).............: 
MPID_nem_tcp_get_business_card(418): 
MPID_nem_tcp_init(377).............: gethostbyname failed, MacBook-Pro.local     (errno 1)
Run Code Online (Sandbox Code Playgroud)

一切都在咖啡店工作正常,然后当我回到家时,我得到上述错误.没有其他改变.

我检查了/ etc/hosts和/ private/etc/hosts文件,看起来没问题 -

##
# 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
255.255.255.255 broadcasthost
Run Code Online (Sandbox Code Playgroud)

我可以ping localhost,所以问题并不完全是localhost没有解决.

重新启动总能解决问题,但有什么简单的我可以做"重置"我的系统,以便它识别本地主机?

我无法访问我正在运行的代码中的MPI初始化例程的详细信息,并且没有对gethostname进行任何显式调用.

我正在使用MPICH 3.1.4(2015年2月建立)并运行OSX 10.10.3

Don*_*nna 8

答案很简单 - 这似乎是有效的.

我编辑了文件/etc/hosts(或/private/etc/hosts在OSX中)并添加了该行

127.0.0.1   macbook-pro.local
Run Code Online (Sandbox Code Playgroud)

所以现在我的主机文件看起来像:

##
# 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
255.255.255.255 broadcasthost
127.0.0.1   macbook-pro.local
Run Code Online (Sandbox Code Playgroud)