I get "There are not enough slots available in the system" when I run mpi

Viewed 2262

I am a high school student. An error occurred while studying and coding the basic theory of mpi. I searched on the internet and tried everything, but I couldn't understand it well.

The code is really simple. There is no problem with the code and I understood it well.

#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;

}

But there was a problem with running mpi. It works well when i type it like this.

mpirun -np 2 ./hello

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

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

This error occurs at -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.

My laptop is Intel i5 and cpu core is 2 and 4 threads. Did such a problem happen because there were only 2 cores? I don't exactly understand this part.

There is not much data about mpi in Korea, so I always googling and studying. If that's the cause, is there any way to increase the number of processes? Other people wrote that there was an error in -np 17, how did they increase the process to double digits? Is the computer capable? Please explain it easily so that I can understand it well.

1 Answers

My laptop is Intel i5 and cpu core is 2 and 4 threads. Did such a problem happen because there were only 2 cores?

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.

If that's the cause, is there any way to increase the number of 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

Related