本文介绍了Octave - 内存不足或维度对于 Octave 的索引类型来说太大的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道有 3 个问题具有类似的异常消息.不幸的是,没有人回答任何问题,评论也无法解决我的问题.

I'm aware of the fact that there are 3 questions with a similar exception message. Unfortunately none of the questions is answered and the comments could not solve my problem.

我在 Windows 10 系统上使用 64 位版本的 Octave 4.2.1,总共有 16 GB 内存,运行时大约有 11 GB 可用空间.当我尝试将 60000 x 10 矩阵与 10 x 60000 矩阵相乘时,Octave 出现以下异常:

I use Octave 4.2.1 in the 64 bit version on a Windows 10 System with 16 GB RAM in total and ~11 GB free during runtime.When i try to multiply a 60000 x 10 matrix with a 10 x 60000 matrix Octave comes up with the following exception:

错误:内存不足或维度对于 Octave 的索引类型来说太大

这种乘法将产生一个 60000 x 60000 的矩阵,因此对于 64 位索引应该不是问题.我什至不能做 zeros(60000,60000);

This multiplication would result in a 60000 x 60000 matrix and therefore should not be a problem for a 64 bit index.I can't even do zeros(60000,60000);

我不明白我做错了什么.有人能指出我正确的方向吗?

I don't get what i am doing wrong. Could someone point me into the right direction?

推荐答案

通常情况下,此错误经常被误解(也许我们应该将其视为八度音程跟踪器上的错误;))

As is often the case, this error is often misinterpreted (maybe we should address this as a bug on the octave tracker already ;) )

>> 60000*60000
ans =    3.6000e+09
>> intmax
ans = 2147483647
>> 60000*60000 > intmax
ans = 1

即生成的 60000x60000 矩阵的元素数大于系统支持的最大整数表示,因此无法使用整数索引对此类矩阵进行线性索引.

I.e. the number of elements of the resulting 60000x60000 matrix is larger than the maximum integer representation supported by the system, therefore there is no way to linearly index such a matrix using an integer index.

此外,为了使用实际 64 位索引,您需要以这种方式编译八度,因为这往往不是默认值,但不幸的是,这并不像您希望的那么简单,因为您还必须使用相应的 64 位支持库.更多相关信息这里.

Also, in order to use actual 64-bit indexing, you need to compile octave in that manner, as this tends not to be the default, but unfortunately that's not as straightforward as you might wish, as you'll have to use the respective 64-bit supporting libraries as well. More on that here.

话虽如此,如果您的矩阵本质上确实是稀疏的,则很有可能改用稀疏矩阵.如果没有,您实际上是在使用大数据",并且需要找到解决方法,例如块处理/将大数组映射到文件等.阅读常见的大数据"技术是值得的.不幸的是,octave 似乎还不支持 matlab 的 memmapfile 命令,但您可以使用 fwrite/fread/fseek适当地从文件中读取适当的范围.

Having said that, it may well be possible to make use of sparse matrices instead if your matrices are indeed sparse in nature. If not, you're essentially using 'big data', and you need to find workarounds, such as blockprocessing / mapping large arrays to files etc. It's worth reading up on common "big data" techniques. Unfortunately octave does not seem to support matlab's memmapfile command just yet, but you can simulate this using fwrite / fread / fseek appropriately to read appropriate ranges from a file.

这篇关于Octave - 内存不足或维度对于 Octave 的索引类型来说太大的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-14 05:22