Numpy在256GB RAM、64位Python和64位Numpy下的内存错误,ulimit问题?
在网上关于numpy内存错误的帖子有很多,但我找不到一个能解决我问题的。我正在使用一台高端服务器,内存有256GB,操作系统是64位的opensuse 13.1,使用64位的python和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
我有几个问题:
- 我遗漏了什么吗?
- 我是不是没有正确测量
Columns
列表对象的大小? - 还有其他系统属性需要设置吗?
我希望 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 个回答
4
真是太尴尬了。我真的内存不够用了。我打开了 top
命令,看到我的256GB内存被用光了。为什么在我调查的时候从来没有检查这个,连我自己都觉得很奇怪。对于我忽视这么明显的事情,我深感抱歉。