我有一个问题,类似于这个:
import numpy as np
C = np.zeros((100,10))
for i in range(10):
C_sub = get_sub_matrix_C(i, other_args) # shape 10x10
C[i*10:(i+1)*10,:10] = C_sub
显然,不需要将其作为串行计算运行,因为每个子矩阵可以独立计算。
我想使用multiprocessing模块并为for循环创建多达4个进程。
我读了一些关于multiprocessing的教程,但无法弄清楚如何使用它来解决我的问题。
感谢您的帮助。
get_sub_matrix
只是几个矩阵访问,那么你不会获得任何加速。 - Bakuriu