7
下面简单的四线代码产生一个内存泄漏在我的Python 2.6.6/NumPy的1.7.0/MKL 10.3.6设置:如何避免与NumPy + MKL这四行内存泄漏?
import numpy as np
t = np.random.rand(10,10)
while True:
t = t/np.trace(t)
随着每次操作中,所使用的存储器的增长通过的大小一个10x10矩阵。但是,当我使用NumPy 1.4.1/ATLAS设置时没有这种行为。
我已阅读关于MKL不一定自动释放内存,所以我想这是爆炸的原因。有没有一种简单的方法来修改NumPy(编译之前或之后),这样这个四行可以正常工作?
输出np.show_config()的
numpy 1.7.0
lapack_opt_info:
libraries = ['mkl_rt', 'pthread']
library_dirs = ['$MKLPATH/lib/intel64']
define_macros = [('SCIPY_MKL_H', None)]
include_dirs = ['$MKLPATH/include']
blas_opt_info:
libraries = ['mkl_rt', 'pthread']
library_dirs = ['$MKLPATH/lib/intel64']
define_macros = [('SCIPY_MKL_H', None)]
include_dirs = ['$MKLPATH/include']
lapack_mkl_info:
libraries = ['mkl_rt', 'pthread']
library_dirs = ['$MKLPATH/lib/intel64']
define_macros = [('SCIPY_MKL_H', None)]
include_dirs = ['$MKLPATH/include']
blas_mkl_info:
libraries = ['mkl_rt', 'pthread']
library_dirs = ['$MKLPATH/lib/intel64']
define_macros = [('SCIPY_MKL_H', None)]
include_dirs = ['$MKLPATH/include']
mkl_info:
libraries = ['mkl_rt', 'pthread']
library_dirs = ['$MKLPATH/lib/intel64']
define_macros = [('SCIPY_MKL_H', None)]
include_dirs = ['$MKLPATH/include']
这绝对看起来像一个在numpy中的错误。也许你会有更多的运气提交给他们的bug跟踪器或尝试numpy 1.8? – entropy 2013-03-03 22:56:14
有趣的是,在循环中的[gc.collect]([gc - garbage collection](http://docs.python.org/2/library/gc.html))中指向一个numpy错误仍然会发生这种效果。也许值得提出他们的问题跟踪? – danodonovan 2013-03-03 22:58:32
谢谢,我已将此问题提交给numpy错误跟踪程序。一旦我在那里得到肯定的答复,我会尽快结束这个问题。 – 2013-03-03 23:50:59