在全新的Raspberry Pi 4 Ubuntu上运行一个干净的Ubuntu,
ubuntu@ubuntu:~/mpi-hello-world/mpitutorial/tutorials/mpi-hello-world/code$ uname -a
Linux ubuntu 5.4.0-1028-raspi #31-Ubuntu SMP PREEMPT Wed Jan 20 11:36:14 UTC 2021 armv7l armv7l armv7l GNU/Linux
只是
sudo apt install mpi mpich
Make on this works fine:
#include <mpi.h>
#include <stdio.h>
int main(int argc, char** argv) {
// Initialize the MPI environment. The two arguments to MPI Init are not
// currently used by MPI implementations, but are there in case future
// implementations might need the arguments.
fprintf(stderr,"Starting...n");
MPI_Init(NULL, NULL);
fprintf(stderr,"MPI_Init accomplished...n");
// Finalize the MPI environment. No more MPI calls can be made after this
MPI_Finalize();
fprintf(stderr,"MPI_Finalize done!n");
}
但运行它时,调用MPI_Initialize((时会发生instagrash。
ubuntu@ubuntu:~/mpi-hello-world/mpitutorial/tutorials/mpi-hello-world/code$ mpirun -np 2 ./mpi_hello_world
Starting...
Starting...
===================================================================================
= BAD TERMINATION OF ONE OF YOUR APPLICATION PROCESSES
= PID 7855 RUNNING AT ubuntu
= EXIT CODE: 139
= CLEANING UP REMAINING PROCESSES
= YOU CAN IGNORE THE BELOW CLEANUP MESSAGES
===================================================================================
YOUR APPLICATION TERMINATED WITH THE EXIT STRING: Segmentation fault (signal 11)
This typically refers to a problem with your application.
Please see the FAQ page for debugging suggestions
有什么建议吗?!?
是的,问题是混合了mpi和mpich!这解决了问题:
sudo apt remove mpi mpich
sudo apt install mpi mpi-default-dev
之后make
运行平稳(之前也是如此(,然后执行也运行平稳!
mpirun -np 2 ./mpi_hello_world
一切都很好。感谢@Gilles的提示。
(我或多或少是随机选择了mpi而不是mpich,简单的网络搜索并没有显示出为我们计划做的简单事情选择其中一个的明确理由。(