You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
if replacing int(ncpu) into ncpu sometimes the process gets hanged, but it's avoided by wrapping the np.int32 object into int(). to be noted that type(ncpu) = np.int32
i don't fully understand why sometimes the problem is solved by wrapping np.int32 into int(), and others don't. should be something else, it's strange.. sth to be solved.
some context: Spyder 5.4.5 | Python 3.11.5 64-bit | Qt 5.15.2 | PyQt5 5.15.6 | Windows 10 (AMD64)
min repr example of crash: this example aims to group the parallelization in groups of 5.
importnumpyasnpfrompathos.multiprocessingimportProcessingPoolasPooldeff_phi(item):
print(item)
# enddef f_phi# Initialize a list to be grouped in blocks of 5 itemslis_1=np.arange(0, 13)
# Total number of elements in lis_1nn=len(lis_1)
# Create a vector to separate indices of lis_1 into groups of 5vec=np.arange(0, nn, 5)
# Create lists for "from" (start) indices and "to" (end) indiceslis_frm=list(vec[:-1]) # "From" indiceslis_to=list(vec[1:]) # "To" indices# Handle the remainder if the last group has fewer than 5 elementsiflis_to[-1] < (nn-1): # Handle the remainder group (e.g., 10 to 13)lis_frm+= [lis_to[-1]]
lis_to+= [nn-1]
#endif# Number of groups to be processedngru=len(lis_frm)
# Initialize lists for the number of CPUs and resultslis_ncpu= [None] *ngrulis_resp= [None] *ngru# Loop through all groups and process them in parallelforigroinrange(len(lis_frm)):
frm=lis_frm[igro] # "From" index for the current groupto=lis_to[igro] # "To" index for the current groupncpu=int(lis_to[igro] -lis_frm[igro]) # Number of parallel threads (ensure it's an integer)# Slice the input list for the current grouplis_argin=lis_1[frm:to]
lis= []
# Process the current group in parallelwithPool(ncpu) aspool:
lis=pool.map(f_phi, lis_argin)
# endwith# Store the resultslis_resp[igro] =lis# endfor
The text was updated successfully, but these errors were encountered:
if replacing
int(ncpu)
intoncpu
sometimes the process gets hanged, but it's avoided by wrapping the np.int32 object intoint()
. to be noted thattype(ncpu) = np.int32
i don't fully understand why sometimes the problem is solved by wrapping np.int32 into int(), and others don't. should be something else, it's strange.. sth to be solved.
some context: Spyder 5.4.5 | Python 3.11.5 64-bit | Qt 5.15.2 | PyQt5 5.15.6 | Windows 10 (AMD64)
min repr example of crash: this example aims to group the parallelization in groups of 5.
The text was updated successfully, but these errors were encountered: