2014-04-16 61 views
16

我不明白錯誤消息。我試圖做的是在安裝mpich2版本1.4或1.5到/opt/mpich2(兩個版本均失敗並出現相同錯誤)後運行MPICH2應用程序。我的MPI應用程序使用1.3編譯,但我可以在另一個工作站上使用mpi 1.4運行它。我正在Ubuntu 12.04上測試它。MPICH2 gethostbyname失敗

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) 

回答

2

作爲的問題不同,答案很可能是同我給了前段時間對的openmpi: gethostname() function missing in openMPI

的MPI便攜式解決方案是使用MPI_Get_processor_name()

+0

感謝您的回答。我錯過了錯誤消息的第一行。 – biocyberman

+0

@biocyberman你可能想接受答案。 –

5

此錯誤指示有問題解決localhost問題。檢查你的/ etc/hosts文件,確保你在這裏正確定義了localhost,它應該指向127.0.0.1。嘗試使用SSH連接到本地主機,確保工作。

+0

ssh到localhost的作品。我會嘗試尋找其他的東西,然後再回來。 – biocyberman

+5

這是我必須做的,以解決這個問題:通過'sudo scutil --set HostName'設置一個正確的主機名,然後將新的主機名(比如my_computer.local)添加到/ etc/hosts中,比如'127.0.0.1 my_computer.local '。您還必須在「共享」設置中啓用SSH訪問,並將您的公鑰添加到authorized_keys文件('cat〜/ .ssh/id_rsa.pub >>〜/ .ssh/authorized_keys')。 – herrherr

10

什麼工作對我來說是以下幾點:

確保您的主機名是1和2是相同的:

  1. 終端主機
  2. 「/ etc/hosts文件」 主機名

因此,如果您在終端中鍵入cat /etc/hosts,它應該看起來像:

// 127.0.0.1  my_hostname 

對我而言,我的主機名與1和2不一樣。一旦我改變它們匹配,那麼我的mpi程序就會執行。

要改變您的終端的主機名鍵入以下內容: sudo scutil --set HostName my_new_host_name

要改變你的/ etc /主機的主機名鍵入以下內容: sudo nano /etc/hosts

然後添加線

127.0.0.1  my_new_hostname 
+0

我遇到了這個完全相同的問題(注意原始發佈一年後) - 這個答案爲我提供瞭解決方案。 http://stackoverflow.com/questions/42041706/mpi4py-fatal-error-in-simple-hello-world?noredirect=1#comment71258508_42041706 – aph

10

解對於macOS

我偶然發現了macOS上的這個問題10.12.1。

解決方法是將127.0.0.1 computername.local添加到/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 
127.0.0.1 computername.local 
255.255.255.255 broadcasthost 
::1    localhost 

您可以更改/檢查您的計算機的名稱,如果你去系統預置>共享>計算機名稱