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

I get "There are not enough slots available in the system" when I run 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