gpt4 book ai didi

multithreading - Cython Prange失败并显示致命Python错误: PyThreadState_Get: no current thread

转载 作者:行者123 更新时间:2023-12-03 12:59:34 24 4
gpt4 key购买 nike

我正在尝试使用prange并行化循环:

cdef fun(double [::1] someData)) nogil:
#direct call to a external c function
C_function(&someData[0])

#....
def parallelEvaluate(np.ndarray[np.double_t] largerArray):
#....
cdef np.ndarray[np.double_t] array
cdef np.ndarray[np.int] arbitraryIndices
for n in prange(loopLength, nogil=true):
with gil:
arbitraryIndices = # ... indices dependent on n
array = np.copy( largerArray[ arbitraryIndices] ) # copy of a non cont. array to the cont. 'array'
fun(array)

但是,这样做失败:
致命的Python错误:PyThreadState_Get:当前没有线程

这种行为的原因是什么?

谢谢!

最佳答案

确定了:

来自np.ndarray的隐式转换不起作用。我用一个额外的memoryview slice解决了它。

关于multithreading - Cython Prange失败并显示致命Python错误: PyThreadState_Get: no current thread,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42131988/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com