Hi,
I need to deal with a very large matrix in Matlab, i.e. image(21600, 43200). With a floating point type, this matrix will take more than 3 GB memory. With a 64-bit machine and OS, this amount of memory can be allocated. But Matlab seems not be able to allocate that much of memory automatically. Does anybody have successful experience with similar situation?
Thanks in advance.
|
|
0
|
|
|
|
Reply
|
Tom
|
1/4/2010 4:38:04 PM |
|
"Tom Nimbus" <ravensalo@gmail.com> wrote in message <hht5hc$evt$1@fred.mathworks.com>...
> Hi,
>
> I need to deal with a very large matrix in Matlab, i.e. image(21600, 43200). With a floating point type, this matrix will take more than 3 GB memory. With a 64-bit machine and OS, this amount of memory can be allocated. But Matlab seems not be able to allocate that much of memory automatically. Does anybody have successful experience with similar situation?
===============================
If it works on a 64-bit machine, why not use that?
Generally speaking though, loading such a large matrix into memory sounds like it could be a brute force solution. If you tell us more about the structure of the matrix, people may be able to suggest more efficient, structured solutions. In particular, is the matrix sparse? See "help sparse", if you're not familiar with sparse MATLAB arrays.
|
|
0
|
|
|
|
Reply
|
Matt
|
1/4/2010 5:52:04 PM
|
|
"Matt J " <mattjacREMOVE@THISieee.spam> wrote in message <hht9s4$p0i$1@fred.mathworks.com>...
> "Tom Nimbus" <ravensalo@gmail.com> wrote in message <hht5hc$evt$1@fred.mathworks.com>...
> > Hi,
> >
> > I need to deal with a very large matrix in Matlab, i.e. image(21600, 43200). With a floating point type, this matrix will take more than 3 GB memory. With a 64-bit machine and OS, this amount of memory can be allocated. But Matlab seems not be able to allocate that much of memory automatically. Does anybody have successful experience with similar situation?
> ===============================
>
> If it works on a 64-bit machine, why not use that?
>
> Generally speaking though, loading such a large matrix into memory sounds like it could be a brute force solution. If you tell us more about the structure of the matrix, people may be able to suggest more efficient, structured solutions. In particular, is the matrix sparse? See "help sparse", if you're not familiar with sparse MATLAB arrays.
> ===============================
Matt, thanks for your replying. Yes, this is a sparse array. It contains data from a large image, in which a lot of pixels are blank with scattered clusters. It's impossible to find good ways to divide the image without affecting the integrity of any cluster in the image. My problem is to load this image into Matlab. Due to the limitation of a 32-bit system, it's not possible to allocate memory above 4 GB. So I tried the 64-bit system, but Matlab still gave me the "out of memory" error.
|
|
0
|
|
|
|
Reply
|
Tom
|
1/5/2010 1:05:04 AM
|
|
"Tom Nimbus" <ravensalo@gmail.com> wrote in message <hhu380$3f4$1@fred.mathworks.com>...
> "Matt J " <mattjacREMOVE@THISieee.spam> wrote in message <hht9s4$p0i$1@fred.mathworks.com>...
> > "Tom Nimbus" <ravensalo@gmail.com> wrote in message <hht5hc$evt$1@fred.mathworks.com>...
> > > Hi,
> > >
> > > I need to deal with a very large matrix in Matlab, i.e. image(21600, 43200). With a floating point type, this matrix will take more than 3 GB memory. With a 64-bit machine and OS, this amount of memory can be allocated. But Matlab seems not be able to allocate that much of memory automatically. Does anybody have successful experience with similar situation?
> > ===============================
> >
> > If it works on a 64-bit machine, why not use that?
> >
> > Generally speaking though, loading such a large matrix into memory sounds like it could be a brute force solution. If you tell us more about the structure of the matrix, people may be able to suggest more efficient, structured solutions. In particular, is the matrix sparse? See "help sparse", if you're not familiar with sparse MATLAB arrays.
> > ===============================
>
> Matt, thanks for your replying. Yes, this is a sparse array. It contains data from a large image, in which a lot of pixels are blank with scattered clusters. It's impossible to find good ways to divide the image without affecting the integrity of any cluster in the image. My problem is to load this image into Matlab. Due to the limitation of a 32-bit system, it's not possible to allocate memory above 4 GB. So I tried the 64-bit system, but Matlab still gave me the "out of memory" error.
=========================
You might be able to use memmapfile() to access the image file on disk from MATLAB. Then you can convert the data to a sparse matrix, at which point it will presumably occupy much less memory. Then you can save the sparse matrix to a .mat file.
|
|
0
|
|
|
|
Reply
|
Matt
|
1/5/2010 2:59:04 AM
|
|
For an example of something similar using memory mapping see
http://www.mathworks.com/matlabcentral/fileexchange/17992-3d-cube-slice
|
|
0
|
|
|
|
Reply
|
Malcolm
|
1/5/2010 4:20:19 PM
|
|
"Tom Nimbus" <ravensalo@gmail.com> wrote in message <hhu380$3f4$1@fred.mathworks.com>...
> Matt, thanks for your replying. Yes, this is a sparse array. It contains data from a large image, in which a lot of pixels are blank with scattered clusters. It's impossible to find good ways to divide the image without affecting the integrity of any cluster in the image. My problem is to load this image into Matlab. Due to the limitation of a 32-bit system, it's not possible to allocate memory above 4 GB. So I tried the 64-bit system, but Matlab still gave me the "out of memory" error.
=================
Yet another option might be to load the image in chunks using fread() and conver it to a sparse array piece-by-piece.
|
|
0
|
|
|
|
Reply
|
Matt
|
1/5/2010 5:22:05 PM
|
|
> =================
>
> Yet another option might be to load the image in chunks using fread() and conver it to a sparse array piece-by-piece.
Thanks a million, Matt. This is a brilliant idea and it works pretty well.
|
|
0
|
|
|
|
Reply
|
Tom
|
1/6/2010 1:38:04 AM
|
|
"Tom Nimbus" <ravensalo@gmail.com> wrote in message <hi0phs$q1v$1@fred.mathworks.com>...
>
> > =================
> >
> > Yet another option might be to load the image in chunks using fread() and conver it to a sparse array piece-by-piece.
>
> Thanks a million, Matt. This is a brilliant idea and it works pretty well.
I'm not sure whether this came out in the discussion, but for reference
I just tried
>> grunk = rand([21600,43200]);
>>image(grunk)
>> whos
Name Size Bytes Class Attributes
grunk 21600x43200 7464960000 double
>>
without problem.
Win7, x64, 12GBytes RAM.
(The rand() took a while & not sure how many real pixels I got in the image displayed.)
|
|
0
|
|
|
|
Reply
|
nanren888
|
1/6/2010 6:52:02 AM
|
|
|
7 Replies
294 Views
(page loaded in 0.393 seconds)
Similiar Articles: Large matrix handling - comp.soft-sys.matlabHi, I need to deal with a very large matrix in Matlab, i.e. image(21600, 43200). With a floating point type, this matrix will take more than 3 GB... calculate local minimum in a large matrix - comp.soft-sys.matlab ...... matrix N*N*N, I want to find the minimum mean value of a n*n*n sub-matrix within the large ... out there then I you should investigate the various options for handling that. write a matrix in .dat file - comp.soft-sys.matlabLarge matrix handling - comp.soft-sys.matlab Large matrix handling - comp.soft-sys.matlab In particular, is the matrix sparse? See ... write a matrix in .dat file - comp ... how to transpose large matrix? - comp.unix.shellLarge matrix handling - comp.soft-sys.matlab how to transpose large matrix? - comp.unix.shell Large matrix handling - comp.soft-sys.matlab how to transpose large matrix ... data structure, fread, find - comp.soft-sys.matlabLarge matrix handling - comp.soft-sys.matlab If you tell us more about the structure of the matrix ... option might be to load the image in chunks using fread ... Jacobian matrix numerical at a specific point - comp.soft-sys ...Large matrix handling - comp.soft-sys.matlab With a floating point type, this matrix will take more than 3 GB ... Automatic generation of Jacobian matrices - comp ... unit ... Automatic generation of Jacobian matrices - comp.lang.fortran ...Large matrix handling - comp.soft-sys.matlab Automatic generation of Jacobian matrices - comp.lang.fortran ..... is to be evaluated and jac is the resulting matrix. ... an ... Could not complete your request because there is not enough memory ...Large matrix handling - comp.soft-sys.matlab Could not complete your request because there is not enough memory ... RAM. (The rand() took a while & not sure how ... 'out of memory' covariance matrix - comp.soft-sys.matlab ...Out of Memory in Matlab - comp.soft-sys.matlab My A variable grows out of memory. Can you advice on how to ... Large matrix handling - comp.soft-sys.matlab Out of Memory ... How do you find all the 0's in a matrix and replace with NaN ...How do you find all the 0's in a matrix and replace with NaN ... Large matrix handling - comp.soft-sys.matlab How do I replace spaces with dash in a date ? - comp.lang.awk ... Large matrix handling - comp.soft-sys.matlab | Computer GroupHi, I need to deal with a very large matrix in Matlab, i.e. image(21600, 43200). With a floating point type, this matrix will take more than 3 GB... Large matrix handling - Newsreader - MATLAB CentralHi, I need to deal with a very large matrix in Matlab, i.e. image(21600, 43200). With a floating point type, this matrix will take more than 3 GB memory. 7/26/2012 1:17:14 AM
|