MATLAB Parallel Parfor 内存使用情况询问

发布于 01-08 01:35 字数 611 浏览 3 评论 0原文

我是新来这里提问的,尽管我之前已经在这里找到了许多问题的解决方案。

这个特殊问题我似乎找不到答案,所以我想我会加入并询问。

我正在使用并行计算工具箱一次运行多个模拟,我正在开发的代码将部署在单个核心上,因此不需要将算法转换为并行。

每个模拟创建的数据结构都很大,同时运行 8 个模拟会使用我机器中的所有可用 RAM (4GB)。

我目前正在考虑减少每个模拟使用的内存,并且想知道是否有人知道如何从函数的每个实例获取内存使用信息。

到目前为止,我一直在调用:

parfor i=1:8
   [IR(:, i) Data(i)] =   feval(F, NX, NY(i), SR, NS, i);
end

在函数 F 内部,

[usr, sys] = memory;
format short eng;
TEST.Mem = usr.MemUsedMATLAB;

但这可以理解的是返回 F 的所有 8 个实例正在使用的内存。

我想从 F 的每个实例获取信息。

注意:数据结构 TEST 作为 Data 返回到顶层函数。

预先感谢您的任何帮助。

I am new here for asking questions though I have found solutions to many problems here before.

This particular problem I cannot seem to find an answer for so I though I would join up and ask.

I am using the Parallel computing toolbox to run multiple simulations at once, the code I am developing is to be deployed on a single core so there is no need for converting the algorithm to parallel.

The data structures being created by each of the simulations are large, and running 8 simulations at once is using all of the available RAM in my machine (4GB).

I am currently looking at reducing the memory used by each simulation, and was wondering if anybody knew how to get memory usage info from each of the instances of the function.

So far I have been calling:

parfor i=1:8
   [IR(:, i) Data(i)] =   feval(F, NX, NY(i), SR, NS, i);
end

And inside function F

[usr, sys] = memory;
format short eng;
TEST.Mem = usr.MemUsedMATLAB;

But this understandably is returning the memory being used by all 8 instances of F.

I would like to get the information from each instance of F.

Note: The data structure TEST is returned as Data to the top level function.

Thanks in advance for any help.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

薄暮涼年2025-01-15 01:35:53

您可以使用 matlab profiler 来获取内存使用情况的提示:

% start profiler
profile -memory on;

% start your simulation
my_sim();


% look at profiler results
profile viewer

you can use the matlab profiler to get a hint at the memory usage:

% start profiler
profile -memory on;

% start your simulation
my_sim();


% look at profiler results
profile viewer
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文