mpi - 运行 mpi 时得到 "There are not enough slots available in the system"

标签 mpi

我是一名高中生。学习和编码 mpi 的基本理论时发生错误。我在互联网上搜索并尝试了所有方法,但我无法很好地理解它。

代码非常简单。代码没有问题,我理解得很好。

#include <stdio.h>

#include <mpi.h>

int main(int argc, char *argv[])

{   

   int num_procs, my_rank;

   MPI_Init(&argc, &argv);

   MPI_Comm_size(MPI_COMM_WORLD, &num_procs);

   MPI_Comm_rank(MPI_COMM_WORLD, &my_rank);

   printf("Hello world! I'm rank %d among %d processes.\n", my_rank, num_procs);

   MPI_Finalize();

   return 0;

}

但是运行mpi时出现了问题。当我这样输入时,效果很好。

mpirun -np 2 ./hello

Hello world! I'm rank 1 among 2 processes.

Hello world! I'm rank 0 among 2 processes.

此错误发生在 -np 3。

mpirun -np 3 ./hello

`There are not enough slots available in the system to satisfy the 3
slots that were requested by the application:

./hello

  Either request fewer slots for your application, or make more slots
  available for use.

   A "slot" is the Open MPI term for an allocatable unit where we can
   launch a process.  The number of slots available are defined by the
   environment in which Open MPI processes are run:

  1. Hostfile, via "slots=N" clauses (N defaults to number of
     processor cores if not provided)
  2. The --host command line parameter, via a ":N" suffix on the
     hostname (N defaults to 1 if not provided)
  3. Resource manager (e.g., SLURM, PBS/Torque, LSF, etc.)
  4. If none of a hostfile, the --host command line parameter, or an
     RM is present, Open MPI defaults to the number of processor cores

In all the above cases, if you want Open MPI to default to the number
of hardware threads instead of the number of processor cores, use the
--use-hwthread-cpus option.

Alternatively, you can use the --oversubscribe option to ignore the
number of available slots when deciding the number of processes to
launch.

我的笔记本电脑是 Intel i5,CPU 内核是 2 线程和 4 线程。是因为只有2核才出现这样的问题吗?这部分我不太明白。

韩国关于mpi的资料不多,所以一直在google学习。如果那是原因,有没有办法增加进程数?其他人写的-np 17有错误,他们是如何将进程增加到两位数的?电脑有能力吗?请简单地解释一下,以便我能很好地理解它。

最佳答案

我的笔记本电脑是 Intel i5,CPU 内核是 2 线程和 4 线程。是因为只有2核才出现这样的问题吗?

Yes. By default Open MPI uses the number of cores as slots. So since you only have 2 cores, you can only launch maximum of 2 processes.

如果是这个原因,有什么方法可以增加进程数吗?

Yes, If you use --use-hwthread-cpus with your mpirun command you can use upto 4 mpi processes in your laptop since you have 4 threads in your laptop. Try running the command, mpirun -np 4 --use-hwthread-cpus a.out

Also, you can use --oversubscribe option to increase the number of processes greater than the available cores/threads. For example try this mpirun -np 10 --oversubscribe a.out

关于mpi - 运行 mpi 时得到 "There are not enough slots available in the system",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64338352/

相关文章:

fortran - 16 字节实数的 MPI_AllReduce 的奇怪结果

c++ - boost mpi 发送 NULL 消息

c - GMP 将 char 数组转换为 float

compression - MPI:是否有能够压缩消息的 MPI 库?

c - 使用 mpi 并行排序

sockets - MPI消息可用性通知

c++ - boost::mpi 在具有相同标签的多个 isend/irecv 传输中抛出 MPI_ERR_TRUNCATE

c - MPI_File_read_at 逐行读取

C、openMPI : What is the best way to distribute blocks of data from each process to all other processes?

c - 在MPI中,如何编写下面的程序 等待所有计算完成