電腦上目前使用的mpi環境是2.1.1版本的openmpi,是我之前直接使用系統的包管理工具安裝的。但是系統包版本一般都比較老舊,現在openmpi最新版已經出到了4.0,即將出4.1了,所以我打算升級一下系統里的mpi環境。
本地環境:
- Corei7 9700k
- Ubuntu18.04 LTS
- gcc 7.5.0
- GNU make 4.1
- cmake 3.10.2
參考了 @xuyaowen 的安裝教程,這里我安裝的是最新的4.0.4版本。
直接上最終腳本:
curl -O -L https://download.open-mpi.org/release/open-mpi/v4.0/openmpi-4.0.4.tar.gz
tar xvzf openmpi-4.0.4.tar.gz
cd openmpi-4.0.4
# --prefix 用於配置自身環境中安裝的位置
./configure --prefix=/usr/local --with-orte
# 8核CPU並行編譯
make -j 8 all
make -j 8 install
注意!腳本需要以root權限運行,以安裝mpi到系統路徑。
安裝完成之后可以使用 mpirun --version 來檢查是否安裝成功。
按照參考教程安裝的過程中遇到了一個問題,在網上沒有搜到很滿意的解決方案,最終自己嘗試解決了這個問題。
我在本機 Ubuntu18.04 LTS 安裝完成之后,運行時報錯,提示缺少運行庫:
mpirun: error while loading shared libraries: libopen-rte.so.40: cannot open shared object file: No such file or directory
查閱README發現第 1972 行有這么一段話:
The following pkg-config(1) configuration files *may* be installed,
depending on which command line options were specified to Open MPI's
configure script. They are not necessary for MPI applications, but
may be used by applications that use Open MPI's lower layer support
libraries.
orte: Open MPI Run-Time Environment applications
opal: Open Portable Access Layer applications
根據報錯提示,在./configure的時候加入 --with-orte 選項修復了這個問題。