我尝试遵循以下已记录的示例进行并行化,如下所示:
@numba.jit(nopython=True)
def foo(uIdx, grids):
return uIdx
@numba.jit(nopython=True, parallel=True)
def bar(grid, grids):
LIdxGrid = np.zeros(len(grid))
for uIdx in numba.prange(len(grid)):
LIdxGrid[uIdx] = foo(uIdx, grids)
return LIdxGrid
if __name__ == '__main__':
import numpy as np
grid = np.arange(12)
grids = (grid, grid)
bar(grid, grids)
但这似乎行不通。这个问题似乎源于传递grids(甚至没有在最终foo函数中使用它)。如果我在foo和中删除该引用bar,它将起作用:
bar(grid, 0)
Out[47]: array([ 0., 1., 2., 3., 4., 5., 6., 7., 8., 9., 10., 11.])
如何解决/解决此问题?
缥缈止盈
相关分类