ran*_*ndo 5 python numpy lapack intel-mkl slurm
我有两个大小为 (2500, 208) 和 (208, 2500) 的密集矩阵。我想计算他们的产品。当它是单个进程时,它运行良好且快速,但当它处于多处理块中时,进程会在那里停留数小时。我做更大尺寸的稀疏矩阵乘法,但我没有问题。我的代码如下所示:
with Pool(processes=agents) as pool:
result = pool.starmap(run_func, args)
def run_func(args):
#Do stuff. Including large sparse matrices multiplication.
C = np.matmul(A,B) # or A.dot(B) or even using BLASS library directly dgemm(1, A, B)
#Never go after the line above!
Run Code Online (Sandbox Code Playgroud)
请注意,当该函数run_func
在单个进程中执行时,它可以正常工作。当我在本地机器上进行多处理时,它工作正常。当我在 HPC 上进行多处理时,它卡住了。我这样分配我的资源:
srun -v --nodes=1 --time 7-0:0 --cpus-per-task=2 --nodes=1 --mem-per-cpu=20G python3 -u run.py 2
其中最后一个参数是agents
上面代码中的数字。这是 HPC 上支持的 LAPACK 库详细信息(从 numpy 获得):
libraries = ['mkl_rt', 'pthread']
library_dirs = ['**/lib']
define_macros = [('SCIPY_MKL_H', None), ('HAVE_CBLAS', None)]
include_dirs = ['**/include']
blas_opt_info:
libraries = ['mkl_rt', 'pthread']
library_dirs = ['**lib']
define_macros = [('SCIPY_MKL_H', None), ('HAVE_CBLAS', None)]
include_dirs = ['**/include']
lapack_mkl_info:
libraries = ['mkl_rt', 'pthread']
library_dirs = ['**/lib']
define_macros = [('SCIPY_MKL_H', None), ('HAVE_CBLAS', None)]
include_dirs = ['**/include']
lapack_opt_info:
libraries = ['mkl_rt', 'pthread']
library_dirs = ['**/lib']
define_macros = [('SCIPY_MKL_H', None), ('HAVE_CBLAS', None)]
include_dirs = ['**/include']
Run Code Online (Sandbox Code Playgroud)
与我的本地机器相比,HPC 上的所有 python 包和 python 版本都是相同的。关于发生了什么的任何线索?
作为解决方法,我尝试使用多线程而不是多处理,问题现已解决。我不确定多处理背后的问题是什么。
归档时间: |
|
查看次数: |
173 次 |
最近记录: |