numpy 数组的最大大小是多少? [英] What's the maximum size of a numpy array?

查看:132
本文介绍了numpy 数组的最大大小是多少?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建一个包含 2 708 000 000 个元素的矩阵.当我尝试创建一个这种大小的 numpy 数组时,它给了我一个值错误.有什么办法可以增加最大数组大小吗?

I'm trying to create a matrix containing 2 708 000 000 elements. When I try to create a numpy array of this size it gives me a value error. Is there any way I can increase the maximum array size?

ValueError Traceback(最近一次调用最后一次)

ValueError Traceback (most recent call last)

ValueError: 超出最大允许大小

ValueError: Maximum allowed size exceeded

推荐答案

您正在尝试创建一个包含 27 亿个条目的数组.如果您运行的是 64 位 numpy,每个条目 8 个字节,那么总共将是 20 GB.

You're trying to create an array with 2.7 billion entries. If you're running 64-bit numpy, at 8 bytes per entry, that would be 20 GB in all.

所以几乎可以肯定,您的机器内存不足.numpy 中没有通用的最大数组大小.

So almost certainly you just ran out of memory on your machine. There is no general maximum array size in numpy.

这篇关于numpy 数组的最大大小是多少?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆