Out of memory and new computer

1 次查看(过去 30 天)
Alessandro Longo
Alessandro Longo 2018-5-31
评论: Greg 2018-6-3
Hello forum, I have to re-run a simulation that requires to create very large arrays (up to 160.000.000 elements) but with my actual computer I got the error "out of memory". Of course, I think it is due to the CPU (AMS A4) and the ram (4 gb). I run this simulation, the first time, on a very powerful computer (i7 and 64gb of ram) but it is something I can not afford. So I am thinking to buy (or rent) a new computer, but I would know which technical specifications are required, in order to not buy something useless. Can you help me to estimate which CPU and how much ram I need in order to do this? Sorry for my bad language and thanks in advance.
  8 个评论
David Goodmanson
David Goodmanson 2018-6-3
编辑:David Goodmanson 2018-6-3
Hi Allesandro,
It's not hard to figure out how much memory is required just for the variables. Assuming t,u1,u2,y1,y2 are all the same size and you are storing double precision 64 bit numbers, 5 * 1.6e8 * 8 = 6.4 gB. Of course you have to have more than that to give Matlab space to work. Add on system requirements and that puts you up in the 10 gB range. If possible, the most direct and probably cheapest way to go would be to add more memory to the computer you have. New vs. old CPU, that is not much of a factor.
Greg
Greg 2018-6-3
MATLAB Online crashes in spectacular form when I try:
a = randi(10,1.6e8,2); % So not enough for Alessandro
Simply calculating variable size is not a good answer, especially when talking about spending money on a tight budget. Run the profiler in memory mode to see how much RAM the whole codebase actually uses:
profile on -memory
% Run your code here
profile off
profile viewer
However, I still don't recommend making a purchase based on one codebase. What happens when the requirements go up to 1.8e8 elements?
Do more research into tall arrays as initially recommended. These are designed for exactly what you're experiencing. It is not a simple command you just put at the top of existing code; you will have to learn to modify the code to properly utilize tall.
Finally, since tall essentially just uses hard drive storage as RAM, there would be little difference from pagefile in your case. Try going into system settings and cranking up your pagefile size. Note, things will run much slower on HDD (or even SSD) than RAM.

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Loops and Conditional Statements 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by