Numpy内存错误,256GB RAM,64位python和64位numpy。 ulimit问题?

时间:2014-08-02 19:29:15

标签: python memory numpy opensuse ulimit

谷歌有很多关于numpy内存错误的帖子,但我找不到解决我问题的帖子。我正在运行别人的软件,使用的是具有256GB RAM,64位opensuse 13.1,64位python和64位numpy的高端服务器(据我所知)。见下文。

原始作者无法获得帮助请求,因此我尽力确定numpy尝试创建的对象的内存大小。首先,这是堆栈跟踪:

File "/home/<me>/cmsRelease/trunk/Classes/DotData.py", line 193, in __new__
  DataObj = numpy.rec.fromarrays(Columns,names = names)
File "/usr/lib64/python2.7/site-packages/numpy/core/records.py", line 562, in fromarrays
  _array = recarray(shape, descr)
File "/usr/lib64/python2.7/site-packages/numpy/core/records.py", line 400, in __new__
  self = ndarray.__new__(subtype, shape, (record, descr), order=order)
MemoryError

我使用以下for循环来估计对象大小,我知道如何:

size = 0
for i in Columns:  # Columns is the list passed into numpy.rec.fromarrays
    size += sys.getsizeof(i)
print "Columns size: " + str(size)

结果是Columns size: 12051648。除非我弄错了,只有12MB​​,但在任何一种情况下,它都与256GB相差甚远。

根据这些信息,我怀疑有一个系统限制(ulimit)阻止python访问内存。运行ulimit -a报告以下内容(我在运行程序之前设置ulimit -s 256000000):

core file size          (blocks, -c) 0
data seg size           (kbytes, -d) unlimited
scheduling priority             (-e) 0
file size               (blocks, -f) unlimited
pending signals                 (-i) 2065541
max locked memory       (kbytes, -l) 64
max memory size         (kbytes, -m) unlimited
open files                      (-n) 10000
pipe size            (512 bytes, -p) 8
POSIX message queues     (bytes, -q) 819200
real-time priority              (-r) 0
stack size              (kbytes, -s) 256000000
cpu time               (seconds, -t) unlimited
max user processes              (-u) 2065541
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited

问题

  1. 我错过了什么?
  2. 我没有正确测量Columns列表对象大小吗?
  3. 我需要设置另一个系统属性吗?
  4. 我希望Memory Error更加具体。我感谢您的帮助。

    支持系统信息

    系统内存:

    > free -h
                 total       used       free     shared    buffers     cached
    Mem:          252G       1.6G       250G       4.2M        12M        98M
    -/+ buffers/cache:       1.5G       250G
    Swap:         2.0G        98M       1.9G
    

    操作系统版本:

    > cat /etc/os-release
    NAME=openSUSE
    VERSION="13.1 (Bottle)"
    VERSION_ID="13.1"
    PRETTY_NAME="openSUSE 13.1 (Bottle) (x86_64)"
    ID=opensuse
    ANSI_COLOR="0;32"
    CPE_NAME="cpe:/o:opensuse:opensuse:13.1"
    BUG_REPORT_URL="https://bugs.opensuse.org"
    HOME_URL="https://opensuse.org/"
    ID_LIKE="suse"
    

    Python版本:

    Python 2.7.6 (default, Nov 21 2013, 15:55:38) [GCC] on linux2
    >>> import platform; platform.architecture()
    ('64bit', 'ELF')
    

    Numpy版本:

    >>> numpy.version
    <module 'numpy.version' from '/usr/lib64/python2.7/site-packages/numpy/version.pyc'>
    >>> numpy.version.version
    '1.7.1'
    

1 个答案:

答案 0 :(得分:4)

真的很尴尬。我真的失去了记忆。我开始top并观看所有256GB消耗。为什么我在调查过程中从未检查过这一点对于我自己来说都是一个谜。我很抱歉忽略了这一点。