Requested 196608x4096 (12.0GB) array exceeds maximum array size preference. Creation of arrays greater than this limit may take a long time and cause MATLAB to unresponsive

8 visualizzazioni (ultimi 30 giorni)
I have two matrices.
Matrix A : size is 196608x4096 sparse double
Matrix B: size is [ 16 16 16 ] double
I was trying to multiply them through a loop ( As I have other operations to execute)
Inside the loop , when these two matrices are multiplied at that moment I am getting the error :
"Requested 196608x4096 (12.0GB) array exceeds maximum array size preference. Creation of arrays greater
than this limit may take a long time and cause MATLAB to become unresponsive."
I tried with "tall" but sparse matrix cannot be converted into tall . I there any way to tackle this problem as I do not have large amount of memory in my laptop.
Thanks in Advance.

Risposte (1)

Harsh Mahalwar
Harsh Mahalwar il 21 Feb 2024
Modificato: Harsh Mahalwar il 21 Feb 2024
Hi Amit,
I can recognise that you are trying to multiply 2 matrices of size (196608,4096) and (16, 16, 16) respectively. Due to maximum array size limitations, you are unable to load the (196608, 4096) sized matrix into your MATLAB environment.
You can remove the maximum array size limit by unchecking the checkbox in MATLAB >Preferences > Workspace > MATLAB array size limit.
1. Click on Preferences (present in the Home tab)
2. Go to the workspace.
3. Uncheck the maximum array size limit checkbox.
I can see that you have also tried using the tall arrays but were unable to convert your sparse array into them directly, I have a workaround for that,
To convert a sparse array to tall array, you can,
  1. Convert sparse array to a full array.
  2. Convert full array into a tall array.
Here’s a code example:
% Create a random sparse matrix.
rng default %for reproducibility
S = sprand(8,8,0.3)
S =
(2,1) 0.0344 (7,1) 0.4456 (8,1) 0.7547 (2,2) 0.4387 (4,3) 0.7655 (7,3) 0.6463 (8,4) 0.2760 (1,6) 0.9502 (5,6) 0.1869 (8,6) 0.6797 (3,7) 0.3816 (4,7) 0.7952 (8,7) 0.6551 (6,8) 0.4898 (7,8) 0.7094
% Convert the matrix to full storage.
A = full(S)
A = 8x8
0 0 0 0 0 0.9502 0 0 0.0344 0.4387 0 0 0 0 0 0 0 0 0 0 0 0 0.3816 0 0 0 0.7655 0 0 0 0.7952 0 0 0 0 0 0 0.1869 0 0 0 0 0 0 0 0 0 0.4898 0.4456 0 0.6463 0 0 0 0 0.7094 0.7547 0 0 0.2760 0 0.6797 0.6551 0
t = tall(A)
t = 8x8 tall double matrix 0 0 0 0 0 0.9502 0 0 0.0344 0.4387 0 0 0 0 0 0 0 0 0 0 0 0 0.3816 0 0 0 0.7655 0 0 0 0.7952 0 0 0 0 0 0 0.1869 0 0 0 0 0 0 0 0 0 0.4898 0.4456 0 0.6463 0 0 0 0 0.7094 0.7547 0 0 0.2760 0 0.6797 0.6551 0
Still, you might not be able to load those arrays into your workspace due to low memory in your device, in that case the only option you have might be to upgrade the memory size.
Also, you can refer to a similar question on MATLAB Answer using the following link,
I hope this helps, thanks!

Categorie

Scopri di più su Sparse Matrices in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by