Parallel decorator on Numba routine featuring race condition

  Kiến thức lập trình

I have the following routine aiming to calculate in parallel different SVD of random matrices:

import numpy as np 
from numba import jit,prange 

@jit(nopython=True,parallel=True)
def svd_bn(aa,n):
    
    res=[]
    for k in prange(n):
        u,s,v=np.linalg.svd(aa[k],0)
        res.append( s ) 
        
        
    return res
aa=[np.random.rand(2*k,2*(k+1)) for k in range(1,10)]

res=svd_bn(aa,len(aa))

On a Windows OS, this works fine and returns the sorted elements in the list. On a Linux OS, this leads to a “double free or corruption (!prev)” error. My suspicion is that the parallelization on Linux leads to a race condition that is avoided on Windows, plus the “res” list is changing its entries dynamically.

Is there a way to overcome this problem using Numba? Note that in principle we don’t know the shape of the u,s,v arrays returned from the routine.

Theme wordpress giá rẻ Theme wordpress giá rẻ Thiết kế website

LEAVE A COMMENT