num2cell out of memory

조회 수: 1 (최근 30일)
Jorge Aarón Morán Holguín
Jorge Aarón Morán Holguín 2019년 12월 23일
댓글: Sharif Khalil 2021년 1월 2일
I have a huge dataset that when loaded in the workbench it turns into a 67x20838735 double. Then problem is that when I try to convert it into cell array I get the following message: Out of memory. Type "help memory" for your options.
inputs = num2cell(inputs)
I trien to find a way to solve this problem with loops, but I don't find any way to succeed.

답변 (2개)

Uerm
Uerm 2019년 12월 23일
Hi,
You are working with quite a large variable. I have tried the following
n = rand(67,20838735);
When running whos it says that the variable n uses a bit more than 11 GB of memory. That is more than what most of the normal computers/laptops have :) I think that your computer simply does not have enough memory (RAM). How much RAM does your computer have?
There are some things that you can try.
1) Before converting to cell arrays, you can try to convert the variable from double to single:
n = single(n);
This will make the variable n use half of the memory it did when it was a double.
2) Normally, MATLAB limits the maximum array size to a percentage of the RAM of the computer. You can get rid of this limit by this path:
Click the Home tab --> Click Preferences --> Choose Workspace in the left menu --> On the bottom of the page there is a box saying "Limit the maximum array size to a percentage of RAM". Make sure that this box is empty --> Click Apply and OK.
I suggest that you start with step 2. If that does not work, supply with step 1.
If none of the above works, you can make MATLAB use virtual memory. You can read more about it here:
The tradeoff of using virtual memory is the computation speed!
  댓글 수: 1
Jorge Aarón Morán Holguín
Jorge Aarón Morán Holguín 2019년 12월 23일
Hello,
My computes has a total 96GB of memory.
>> memory
Maximum possible array: 45018 MB (4.720e+10 bytes) *
Memory available for all arrays: 45018 MB (4.720e+10 bytes) *
Memory used by MATLAB: 93519 MB (9.806e+10 bytes)
Physical Memory (RAM): 96922 MB (1.016e+11 bytes)
* Limited by System Memory (physical + swap file) available.
I have tried both options combined and the problem remains.

댓글을 달려면 로그인하십시오.


per isakson
per isakson 2019년 12월 24일
편집: per isakson 2019년 12월 24일
Why do you want to convert the numerical matrix to a cell array? It requires an enormous amount of memory for overhead.
>> clearvars
>> num = (1:12);
>> cac = num2cell( num );
>> whos num cac
Name Size Bytes Class Attributes
cac 1x12 1440 cell
num 1x12 96 double
I think the resulting cell array will need (1440/96)*11 GB. That's twice as much as your ram.
  댓글 수: 3
per isakson
per isakson 2019년 12월 27일
But that doesn't answer the question why you try to convert a numerical array into a cell array with the statement
inputs = num2cell(inputs)
Sharif Khalil
Sharif Khalil 2021년 1월 2일
Hi Jorge,
Did you get an answer to your problem?

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Introduction to Installation and Licensing에 대해 자세히 알아보기

제품


릴리스

R2019a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by