運行numpy多處理時,我遇到了Python意外退出的問題。我已經分離出的問題,所以,我現在可以確認的是,多運行下面陳述的代碼時,可以完美運行:發生使用numpy進行多處理會使Python在OSX上意外退出
import numpy as np
from multiprocessing import Pool, Process
import time
import cPickle as p
def test(args):
x,i = args
if i == 2:
time.sleep(4)
arr = np.dot(x.T,x)
print i
if __name__ == '__main__':
x = np.random.random(size=((2000,500)))
evaluations = [(x,i) for i in range(5)]
p = Pool()
p.map_async(test,evaluations)
p.close()
p.join()
的問題,當我嘗試以下評估代碼。這使得Python的意外退出:
import numpy as np
from multiprocessing import Pool, Process
import time
import cPickle as p
def test(args):
x,i = args
if i == 2:
time.sleep(4)
arr = np.dot(x.T,x)
print i
if __name__ == '__main__':
x = np.random.random(size=((2000,500)))
test((x,4)) # Added code
evaluations = [(x,i) for i in range(5)]
p = Pool()
p.map_async(test,evaluations)
p.close()
p.join()
請幫助別人。我接受所有建議。謝謝。注意:我嘗試過兩種不同的機器,發生同樣的問題。
我使用WinPython跑Windows7的位/ 64位的代碼。這兩種情況都執行並退出,沒有錯誤。 – alandarev
對不起。有趣的是,它可以在Windows上運行。任何能向我解釋爲什麼發生這種情況的Apple用戶? – Maal
我可能誤導了你,當我對使用「意外」術語的蘋果發表憤怒評論時,無處不在。我高度懷疑你的問題是操作系統特定的。你可以嘗試運行你使用numpy安裝對付乾淨Python的腳本來查看問題是否存在? – alandarev