问题描述
我的 Ubuntu 20.04 中有 mpich 和 openmpi.
I have both mpich and openmpi in my Ubuntu 20.04.
$ dpkg -l | grep mpi | grep lib
...
ii libmpich-dev:amd64 3.3.2-2build1 amd64 Development files for MPICH
ii libmpich12:amd64 3.3.2-2build1 amd64 Shared libraries for MPICH
...
ii libopenmpi-dev:amd64 4.0.3-0ubuntu1 amd64 high performance message passing library -- header files
ii libopenmpi3:amd64 4.0.3-0ubuntu1 amd64 high performance message passing library -- shared library
...
ii openmpi-bin 4.0.3-0ubuntu1 amd64 high performance message passing library -- binaries
ii openmpi-common 4.0.3-0ubuntu1 all high performance message passing library -- common files
..
$ dpkg -l | grep mpich
...
ii mpich 3.3.2-2build1 amd64 Implementation of the MPI Message Passing Interface standard
默认(可能是因为后来安装)似乎是 mpich.
The default (probably because it was installed later) appears to be mpich.
我将如何更改为 openmpi?
我想确保所有需要更改的内容都是真实的.到目前为止,我正在考虑头文件、可执行文件、库.我不知道哪些目录、链接等都必须更改.
I want to make sure that everything that needs to be changed actually is.So far, I am thinking about headers, executable, libraries.I do not know which are all directories, links, etc., that have to change.
例如,这里建议 cmake -DMPI_CC_COMPILER=/.../mpicc
.并且在评论中提到它有效.但是:
For instance, here it is suggested cmake -DMPI_CC_COMPILER=/.../mpicc
.And it was mentioned in comments that it worked. But:
我不确定它是否真的修复了所有标题等
I am not sure it actually fixes all headers, etc.
我需要一种方法:
2.1.适用于系统中的所有用户
2.1. Works for all users in the system
2.2.不需要那些宏
2.3.也适用于 cmake
至于2.3,我现在尝试配置petsc
As for 2.3, I tried now to configure petsc
$ ./configure --with-cc=mpicc --with-fc=mpif90 -with-cxx=mpicxx --with- make-np=10 --with-shared-libraries --download-f2cblaslapack --download-mumps --download-scalapack --with-debugging=0 COPTFLAGS="-O -O3 -march=native -mtune=native" FOPTF LAGS="-O -O3 -march=native -mtune=native" CXXOPTFLAGS="-O -O3 -march=native -mtune=native"
我得到了
Your libraries are from MPICH but it appears your mpiexec is from OpenMPI
这个问题可以用 update-alternatives
解决吗?
Can this be fixed with update-alternatives
?
我发现了这个,这让我觉得它可以,但在我的系统中它没有正确配置:
I found this, which makes me think it can, but in my system it is not correctly configured:
$ type mpiexec
mpiexec is hashed (/usr/bin/mpiexec)
$ ll /usr/bin/mpiexec
lrwxrwxrwx 1 root root 25 Jan 21 11:11 /usr/bin/mpiexec -> /etc/alternatives/mpiexec
$ ll /etc/alternatives/mpiexec
lrwxrwxrwx 1 root root 24 Jan 21 11:11 /etc/alternatives/mpiexec -> /usr/bin/mpiexec.openmpi
$ ll /usr/bin/mpiexec.openmpi
lrwxrwxrwx 1 root root 7 Apr 15 2020 /usr/bin/mpiexec.openmpi -> orterun
$ type mpirun
mpirun is /usr/bin/mpirun
$ ll /usr/bin/mpirun
lrwxrwxrwx 1 root root 24 Jan 21 11:11 /usr/bin/mpirun -> /etc/alternatives/mpirun
$ ll /etc/alternatives/mpirun
lrwxrwxrwx 1 root root 23 Jan 21 11:11 /etc/alternatives/mpirun -> /usr/bin/mpirun.openmpi
$ ll /usr/bin/mpirun.openmpi
lrwxrwxrwx 1 root root 7 Apr 15 2020 /usr/bin/mpirun.openmpi -> orterun
$ type mpicc
mpicc is hashed (/usr/bin/mpicc)
$ ll /usr/bin/mpicc
lrwxrwxrwx 1 root root 21 Feb 25 18:54 /usr/bin/mpicc -> /etc/alternatives/mpi
$ ll /etc/alternatives/mpi
lrwxrwxrwx 1 root root 20 Feb 25 18:54 /etc/alternatives/mpi -> /usr/bin/mpicc.mpich
相关
- 用 OpenMPI 替换 MPICH 安装
- CMake:通过 openmpi 选择 mpich
- https://unix.stackexchange.com/questions/413099/flip-between-openmpi-and-mpich-as-default-using-linux-terminal
- mpi 和 mpich2 文件夹的区别?
- CMake:通过 openmpi 选择 mpich
- 从 MPICH 切换到 OpenMPI
- 这个?https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=896189
- 这个?https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=912437
- https://unix.stackexchange.com/questions/81992/better-way-to-add-alternative-using-update-alternatives
- https://askubuntu.com/questions/964600/how-to-add-slave-to-existing-update-alternatives-link-group
推荐答案
似乎都替代方案,除了一个(链接组 mpi
),已经为openmpi设置了
It seems all alternatives, except for one (link group mpi
), were already set for openmpi
$ update-alternatives --get-selections | grep mpi
h5pcc auto /usr/bin/h5pcc.openmpi
mpi auto /usr/bin/mpicc.mpich
mpi-x86_64-linux-gnu auto /usr/lib/x86_64-linux-gnu/openmpi/include
mpirun auto /usr/bin/mpirun.openmpi
正确设置链接组mpi
(并避免容易出错的单个链接操作)
To set link group mpi
properly (and avoiding error-prone individual link operations)
sudo apt-get install --reinstall openmpi-bin
(拥有 mpicc.openmpi
的包).这显然解决了所有问题.到目前为止,它运行良好.
(the package owning mpicc.openmpi
).This apparently fixed everything.So far it is working fine.
历史"注意:我发现(奇怪的是)mpicc.openmpi
不在 update-alternatives
中,而不是其他 3 个链接组
"Historical" note:I had found that (strangely) mpicc.openmpi
was not in update-alternatives
, as opposed to the other 3 link groups
$ update-alternatives --list mpirun
/usr/bin/mpirun.mpich
/usr/bin/mpirun.openmpi
$ update-alternatives --list h5pcc
/usr/bin/h5pcc.mpich
/usr/bin/h5pcc.openmpi
$ update-alternatives --list mpi-x86_64-linux-gnu
/usr/include/x86_64-linux-gnu/mpich
/usr/lib/x86_64-linux-gnu/openmpi/include
$ update-alternatives --list mpi
/usr/bin/mpicc.mpich
即使它安装在我的系统中
even if it was installed in my system
$ ll /usr/bin/mpicc*
lrwxrwxrwx 1 root root 21 Feb 25 18:54 /usr/bin/mpicc -> /etc/alternatives/mpi
-rwxr-xr-x 1 root root 11K Mar 22 2020 /usr/bin/mpicc.mpich
lrwxrwxrwx 1 root root 12 Apr 15 2020 /usr/bin/mpicc.openmpi -> opal_wrapper
为什么不是一开始呢?我还是不知道.
Why would it not be in the first place? I still don't know.
我决定使用 reinstall
,因为手动处理链接组可能很麻烦
I decided to go with the reinstall
, since handling the link group manually might have been a mess
$ update-alternatives --query mpi
Name: mpi
Link: /usr/bin/mpicc
Slaves:
mpiCC /usr/bin/mpiCC
mpiCC.1.gz /usr/share/man/man1/mpiCC.1.gz
mpic++ /usr/bin/mpic++
mpic++.1.gz /usr/share/man/man1/mpic++.1.gz
mpicc.1.gz /usr/share/man/man1/mpicc.1.gz
mpicxx /usr/bin/mpicxx
mpicxx.1.gz /usr/share/man/man1/mpicxx.1.gz
mpif77 /usr/bin/mpif77
mpif77.1.gz /usr/share/man/man1/mpif77.1.gz
mpif90 /usr/bin/mpif90
mpif90.1.gz /usr/share/man/man1/mpif90.1.gz
mpifort /usr/bin/mpifort
mpifort.1.gz /usr/share/man/man1/mpifort.1.gz
Status: auto
Best: /usr/bin/mpicc.mpich
Value: /usr/bin/mpicc.mpich
Alternative: /usr/bin/mpicc.mpich
Priority: 40
Slaves:
mpiCC /usr/bin/mpicxx.mpich
mpiCC.1.gz /usr/share/man/man1/mpicxx.mpich.1.gz
mpic++ /usr/bin/mpicxx.mpich
mpic++.1.gz /usr/share/man/man1/mpicxx.mpich.1.gz
mpicc.1.gz /usr/share/man/man1/mpicc.mpich.1.gz
mpicxx /usr/bin/mpicxx.mpich
mpicxx.1.gz /usr/share/man/man1/mpicxx.mpich.1.gz
mpif77 /usr/bin/mpifort.mpich
mpif77.1.gz /usr/share/man/man1/mpif77.mpich.1.gz
mpif90 /usr/bin/mpifort.mpich
mpif90.1.gz /usr/share/man/man1/mpif90.mpich.1.gz
mpifort /usr/bin/mpifort.mpich
mpifort.1.gz /usr/share/man/man1/mpifort.mpich.1.gz
这篇关于从 MPICH 切换到 OpenMPI的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!