基本上,我试图在numpy矩阵上执行代数运算时,在python中出现内存错误。变量u
是一个双倍的大矩阵(在失败的情况下它是一个288x288x156双精度矩阵,在这个巨大的情况下我只能得到这个错误,但我可以在其他大矩阵上做这个,只是不是这么大)。这里是Python错误:Python/Numpy MemoryError
Traceback (most recent call last):
File "S:\3D_Simulation_Data\Patient SPM Segmentation\20 pc
t perim erosion flattop\SwSim.py", line 121, in __init__
self.mainSimLoop()
File "S:\3D_Simulation_Data\Patient SPM Segmentation\20 pc
t perim erosion flattop\SwSim.py", line 309, in mainSimLoop
u = solver.solve_cg(u,b,tensors,param,fdHold,resid) # Solve the left hand si
de of the equation Au=b with conjugate gradient method to approximate u
File "S:\3D_Simulation_Data\Patient SPM Segmentation\20 pc
t perim erosion flattop\conjugate_getb.py", line 47, in solv
e_cg
u = u + alpha*p
MemoryError
u = u + alpha*p
是失败的代码行。
alpha
只是一个双倍,而u
和r
是上面描述的大矩阵(两个大小相同)。
我不太了解内存错误,特别是在Python中。任何洞察力/提示解决这个问题将非常感激!
感谢
但我的电脑有24GB的内存...有没有办法确保更多可用的Windows?编辑:由于某些原因,我们使用的是32位版本:/ Edit2:不幸的是,稀疏矩阵不是一个选项,因为所有元素都有值(热方程如问题)。 – tylerthemiler 2010-11-30 21:18:19
谢谢,我从内存中清除了一些东西,现在我可以加载它。 – tylerthemiler 2010-11-30 22:35:56
@tylerthemiler:使用非官方的64位版本http://www.lfd.uci.edu/~gohlke/pythonlibs/ – endolith 2013-10-31 18:52:25