如何解决运行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的数据很少,所以我经常谷歌搜索和学习。如果这是原因,是否有任何方法可以增加进程数量?其他人写道-np 17错误,他们如何将处理过程增加到两位数?电脑有能力吗?请轻松解释,以便我理解。
解决方法
我的笔记本电脑是Intel i5,cpu核心是2和4线程。是否只有2个内核会发生这样的问题?
是的。默认情况下,Open MPI使用内核数作为插槽。因此,由于您只有2个核心,因此最多只能启动2个进程。
如果是原因,有什么办法可以增加进程数量?
是的,如果您在
kind: Namespace apiVersion: v1 metadata: name: ns-test labels: name: ns-test --- apiVersion: apps/v1 kind: Deployment metadata: annotations: kompose.cmd: /snap/kompose/19/kompose-linux-amd64 convert kompose.version: 1.21.0 (992df58d8) creationTimestamp: null labels: app: test-h2o name: test-h2o namespace: ns-test spec: replicas: 1 selector: matchLabels: app: test-h2o strategy: {} template: metadata: annotations: kompose.cmd: /snap/kompose/19/kompose-linux-amd64 convert kompose.version: 1.21.0 (992df58d8) creationTimestamp: null labels: app: test-h2o spec: containers: - image: test-h2o:3.30.1.1 imagePullPolicy: "" name: test-h2o resources: {} restartPolicy: Always serviceAccountName: "" volumes: null status: {} --- apiVersion: v1 kind: Service metadata: annotations: kompose.cmd: /snap/kompose/19/kompose-linux-amd64 convert kompose.version: 1.21.0 (992df58d8) creationTimestamp: null name: test-h2o-svc namespace: ns-test spec: ports: - name: "54321" port: 54321 targetPort: 54321 selector: app: test-h2o status: loadBalancer: {} --- apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: test-ingress namespace: ns-test annotations: #ingress.kubernetes.io/rewrite-target: / nginx.ingress.kubernetes.io/rewrite-target: /$2 spec: rules: - http: paths: - path: /h2otest(/|$)(.*) pathType: Prefix backend: service: name: test-h2o-svc port: number: 54321
命令中使用--use-hwthread-cpus
,则您的笔记本电脑中最多可以使用4个mpi进程,因为您的笔记本电脑中有4个线程。尝试运行命令mpirun
此外,您可以使用
mpirun -np 4 --use-hwthread-cpus a.out
选项来增加进程数,使其大于可用的内核/线程。例如,尝试使用--oversubscribe
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。