Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/291.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
同时运行的多个Python实例限制为35个_Python_Linux_Parallel Processing_Multiprocessing_Openblas - Fatal编程技术网

同时运行的多个Python实例限制为35个

同时运行的多个Python实例限制为35个,python,linux,parallel-processing,multiprocessing,openblas,Python,Linux,Parallel Processing,Multiprocessing,Openblas,我正在并行计算集群的不同处理器上以多个独立进程的形式运行Python 3.6脚本。 多达35个进程同时运行,没有问题,但第36个(以及更多)进程由于第二行出现分段错误而崩溃,该行是导入熊猫为pd。有趣的是,导入操作系统的第一行不会引起问题。 完整的错误消息是: OpenBLAS blas_thread_init: pthread_create: Resource temporarily unavailable OpenBLAS blas_thread_init: RLIMIT_NPROC 102

我正在并行计算集群的不同处理器上以多个独立进程的形式运行Python 3.6脚本。 多达35个进程同时运行,没有问题,但第36个(以及更多)进程由于第二行出现分段错误而崩溃,该行是
导入熊猫为pd
。有趣的是,导入操作系统的第一行
不会引起问题。
完整的错误消息是:

OpenBLAS blas_thread_init: pthread_create: Resource temporarily unavailable
OpenBLAS blas_thread_init: RLIMIT_NPROC 1024 current, 2067021 max
OpenBLAS blas_thread_init: pthread_create: Resource temporarily unavailable
OpenBLAS blas_thread_init: RLIMIT_NPROC 1024 current, 2067021 max
OpenBLAS blas_thread_init: pthread_create: Resource temporarily unavailable
OpenBLAS blas_thread_init: RLIMIT_NPROC 1024 current, 2067021 max
OpenBLAS blas_thread_init: pthread_create: Resource temporarily unavailable
OpenBLAS blas_thread_init: RLIMIT_NPROC 1024 current, 2067021 max
OpenBLAS blas_thread_init: pthread_create: Resource temporarily unavailable
OpenBLAS blas_thread_init: RLIMIT_NPROC 1024 current, 2067021 max
OpenBLAS blas_thread_init: pthread_create: Resource temporarily unavailable
OpenBLAS blas_thread_init: RLIMIT_NPROC 1024 current, 2067021 max
OpenBLAS blas_thread_init: pthread_create: Resource temporarily unavailable
OpenBLAS blas_thread_init: RLIMIT_NPROC 1024 current, 2067021 max
OpenBLAS blas_thread_init: pthread_create: Resource temporarily unavailable
OpenBLAS blas_thread_init: RLIMIT_NPROC 1024 current, 2067021 max
OpenBLAS blas_thread_init: pthread_create: Resource temporarily unavailable
OpenBLAS blas_thread_init: RLIMIT_NPROC 1024 current, 2067021 max
OpenBLAS blas_thread_init: pthread_create: Resource temporarily unavailable
OpenBLAS blas_thread_init: RLIMIT_NPROC 1024 current, 2067021 max
OpenBLAS blas_thread_init: pthread_create: Resource temporarily unavailable
OpenBLAS blas_thread_init: RLIMIT_NPROC 1024 current, 2067021 max
OpenBLAS blas_thread_init: pthread_create: Resource temporarily unavailable
OpenBLAS blas_thread_init: RLIMIT_NPROC 1024 current, 2067021 max
OpenBLAS blas_thread_init: pthread_create: Resource temporarily unavailable
OpenBLAS blas_thread_init: RLIMIT_NPROC 1024 current, 2067021 max
OpenBLAS blas_thread_init: pthread_create: Resource temporarily unavailable
OpenBLAS blas_thread_init: RLIMIT_NPROC 1024 current, 2067021 max
OpenBLAS blas_thread_init: pthread_create: Resource temporarily unavailable
OpenBLAS blas_thread_init: RLIMIT_NPROC 1024 current, 2067021 max
OpenBLAS blas_thread_init: pthread_create: Resource temporarily unavailable
OpenBLAS blas_thread_init: RLIMIT_NPROC 1024 current, 2067021 max
Traceback (most recent call last):
  File "/home/.../myscript.py", line 32, in <module>
    import pandas as pd
  File "/home/.../python_venv2/lib/python3.6/site-packages/pandas/__init__.py", line 13, in <module>
    __import__(dependency)
  File "/home/.../python_venv2/lib/python3.6/site-packages/numpy/__init__.py", line 142, in <module>
    from . import add_newdocs
  File "/home/.../python_venv2/lib/python3.6/site-packages/numpy/add_newdocs.py", line 13, in <module>
    from numpy.lib import add_newdoc
  File "/home/.../python_venv2/lib/python3.6/site-packages/numpy/lib/__init__.py", line 8, in <module>
    from .type_check import *
  File "/home/.../python_venv2/lib/python3.6/site-packages/numpy/lib/type_check.py", line 11, in <module>
    import numpy.core.numeric as _nx
  File "/home/.../python_venv2/lib/python3.6/site-packages/numpy/core/__init__.py", line 16, in <module>
    from . import multiarray
SystemError: initialization of multiarray raised unreported exception
/var/spool/slurmd/job04590/slurm_script: line 11: 26963 Segmentation fault      python /home/.../myscript.py -x 38
OpenBLAS blas\u thread\u init:pthread\u create:资源暂时不可用
OpenBLAS blas_thread_init:RLIMIT_NPROC 1024当前,最大2067021
OpenBLAS blas_thread_init:pthread_create:资源暂时不可用
OpenBLAS blas_thread_init:RLIMIT_NPROC 1024当前,最大2067021
OpenBLAS blas_thread_init:pthread_create:资源暂时不可用
OpenBLAS blas_thread_init:RLIMIT_NPROC 1024当前,最大2067021
OpenBLAS blas_thread_init:pthread_create:资源暂时不可用
OpenBLAS blas_thread_init:RLIMIT_NPROC 1024当前,最大2067021
OpenBLAS blas_thread_init:pthread_create:资源暂时不可用
OpenBLAS blas_thread_init:RLIMIT_NPROC 1024当前,最大2067021
OpenBLAS blas_thread_init:pthread_create:资源暂时不可用
OpenBLAS blas_thread_init:RLIMIT_NPROC 1024当前,最大2067021
OpenBLAS blas_thread_init:pthread_create:资源暂时不可用
OpenBLAS blas_thread_init:RLIMIT_NPROC 1024当前,最大2067021
OpenBLAS blas_thread_init:pthread_create:资源暂时不可用
OpenBLAS blas_thread_init:RLIMIT_NPROC 1024当前,最大2067021
OpenBLAS blas_thread_init:pthread_create:资源暂时不可用
OpenBLAS blas_thread_init:RLIMIT_NPROC 1024当前,最大2067021
OpenBLAS blas_thread_init:pthread_create:资源暂时不可用
OpenBLAS blas_thread_init:RLIMIT_NPROC 1024当前,最大2067021
OpenBLAS blas_thread_init:pthread_create:资源暂时不可用
OpenBLAS blas_thread_init:RLIMIT_NPROC 1024当前,最大2067021
OpenBLAS blas_thread_init:pthread_create:资源暂时不可用
OpenBLAS blas_thread_init:RLIMIT_NPROC 1024当前,最大2067021
OpenBLAS blas_thread_init:pthread_create:资源暂时不可用
OpenBLAS blas_thread_init:RLIMIT_NPROC 1024当前,最大2067021
OpenBLAS blas_thread_init:pthread_create:资源暂时不可用
OpenBLAS blas_thread_init:RLIMIT_NPROC 1024当前,最大2067021
OpenBLAS blas_thread_init:pthread_create:资源暂时不可用
OpenBLAS blas_thread_init:RLIMIT_NPROC 1024当前,最大2067021
OpenBLAS blas_thread_init:pthread_create:资源暂时不可用
OpenBLAS blas_thread_init:RLIMIT_NPROC 1024当前,最大2067021
回溯(最近一次呼叫最后一次):
文件“/home/../myscript.py”,第32行,在
作为pd进口熊猫
文件“/home/../python\u-venv2/lib/python3.6/site-packages/pandas/\uuuuu-init\uuuuu.py”,第13行,在
__导入(依赖项)
文件“/home/../python\u-venv2/lib/python3.6/site-packages/numpy/\uuuu-init\uuu.py”,第142行,在
从…起导入添加新文档
文件“/home/../python\u venv2/lib/python3.6/site packages/numpy/add\u newdocs.py”,第13行,在
从numpy.lib导入添加新文档
文件“/home/../python\u-venv2/lib/python3.6/site-packages/numpy/lib/\uuuuu-init\uuuuu.py”,第8行,在
from.type\u检查导入*
文件“/home/../python\u venv2/lib/python3.6/site packages/numpy/lib/type_check.py”,第11行,在
将numpy.core.numeric作为_nx导入
文件“/home/../python\u-venv2/lib/python3.6/site-packages/numpy/core/\u_-init\u__;.py”,第16行,在
从…起导入多数组
SystemError:初始化多数组引发未报告的异常
/var/spool/slurmd/job04590/slurm_脚本:第11行:26963分段错误python/home/../myscript.py-x 38
Pandas和其他一些软件包安装在虚拟环境中。我复制了虚拟环境,因此每个venv中运行的进程不超过24个。例如,上面的错误脚本来自一个在名为
python\u venv2
的虚拟环境中运行的脚本

无论有多少进程从Pandas的特定实例导入,问题每次都会出现在第36个进程上。(我甚至没有削弱并行计算集群的容量。)

那么,如果它不是对访问panda的进程数量的限制,那么它是对运行Python的进程数量的限制吗?为什么限制是35


是否可以在机器上安装多个Python副本(在单独的虚拟环境中?),以便我可以运行35个以上的进程?

分解错误消息

您的错误消息包含以下提示:

OpenBLAS blas_thread_init: pthread_create: Resource temporarily unavailable
OpenBLAS blas_thread_init: RLIMIT_NPROC 1024 current, 2067021 max
RLIMIT\u NPROC
变量控制用户可以拥有的进程总数。更具体地说,由于它是每个进程的设置,当进程调用
fork()
clone()
vfork()
、&c时,该进程的
RLIMIT\u NPROC
值将与该进程的父用户的总进程计数进行比较。如果超过该值,事情就会停止,正如您所经历的那样

错误消息表明OpenBLAS无法创建其他线程,因为您的用户使用了所有线程
RLIMIT\u NPROC
提供的线程

由于您在集群上运行,因此您的用户不太可能运行多个线程(与您在个人计算机上浏览web、播放音乐和c不同),因此可以合理地得出结论,OpenBLAS正在尝试启动多个线程

OpenBLAS如何使用线程

OpenBLAS可以使用多个线程来加速线性代数。您可能需要多个线程来快速解决单个更大的问题。您可能需要更少的线程来同时解决许多较小的问题

OpenBLAS必须限制它使用的线程数
export OPENBLAS_NUM_THREADS=4
export GOTO_NUM_THREADS=4
export OMP_NUM_THREADS=4
export OPENBLAS_NUM_THREADS=1