gpt4 book ai didi

mpi - 从 MPICH 切换到 OpenMPI

转载 作者:行者123 更新时间:2023-12-05 06:03:54 35 4
gpt4 key购买 nike

我的 Ubuntu 20.04 中同时安装了 mpich 和 openmpi。

$ 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。

我如何更改为 openmpi?

我想确保需要更改的所有内容都是真实的。到目前为止,我正在考虑 header 、可执行文件和库。我不知道哪些是必须更改的所有目录,链接等。

例如,here建议 cmake -DMPI_CC_COMPILER=/.../mpicc。评论中提到它有效。但是:

  1. 我不确定它是否真的修复了所有 header 等。

  2. 我需要一个方法:

    2.1。适用于系统中的所有用户

    2.2。不需要那些宏

    2.3。也适用于 cmake

    以外的其他编译方法

至于2.3,我现在尝试配置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 解决这个问题吗?

我发现了这个,这让我觉得它可以,但在我的系统中它没有正确配置:

$ 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

相关

  1. Replace MPICH Installation by OpenMPI
  2. CMake : Selecting mpich over openmpi
  3. https://unix.stackexchange.com/questions/413099/flip-between-openmpi-and-mpich-as-default-using-linux-terminal
  4. Difference between mpi and mpich2 folder?
  5. CMake : Selecting mpich over openmpi
  6. Switch from MPICH to OpenMPI
  7. 这个? https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=896189
  8. 这个? https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=912437
  9. https://unix.stackexchange.com/questions/81992/better-way-to-add-alternative-using-update-alternatives
  10. https://askubuntu.com/questions/964600/how-to-add-slave-to-existing-update-alternatives-link-group

最佳答案

好像都是alternatives , 除了一个 (link group mpi), 已经设置为 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(并避免容易出错的单个链接操作)

sudo apt-get install --reinstall openmpi-bin

(拥有 mpicc.openmpi 的包)。这显然解决了一切。到目前为止它工作正常。


“历史”注释:我发现(奇怪的是)mpicc.openmpi 不在 update-alternatives 中,与其他 3 个链接组不同

$ 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

即使它安装在我的系统中

$ 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

为什么不放在首位呢?我还是不知道。

我决定使用重新安装,因为手动处理链接组可能会很麻烦

$ 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

关于mpi - 从 MPICH 切换到 OpenMPI,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66535019/

35 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com