如何限制MATLAB在Linux中的使用
当我在PC上运行MATLAB模拟(20个内核)时,它使用所有内核。有什么方法可以将CPU的可用性限制为MATLAB,以便仅使用10个内核?
When I run a Matlab simulation on my PC (20 cores), it uses all cores. Is there any way to limit CPU availability to Matlab, so that it uses only, say, 10 cores?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
maxnumcompthreads
可以用于告诉MATLAB在计算中使用多少个线程。在您的情况下,请在脚本/功能的顶部写入:请注意,这会影响会话剩余时间在MATLAB上运行的所有内容,但不会影响未来的会话。这就是为什么您可能想将此命令放在脚本的顶部,以便每次运行该脚本时都适用。
还要注意,这不会影响并行处理工具箱,这是使用机器上多个CPU的另一种方法。它更改了使用多少线程来执行基本计算,例如矩阵乘法和卷积以及傅立叶变换等等。
The
maxNumCompThreads
function can be used to tell MATLAB how many threads to use in computation. In your case, write at the top of your script/function:Note that this will affect everything run on MATLAB during the remainder of the session, but will not affect future sessions. This is why you probably want to put this command at the top of your script, so that it applies every time you run that script.
Note also that this does not affect the Parallel Processing Toolbox, which is a different way of using multiple CPUs on your machine. It changes how many threads are used to do basic computations like matrix multiplications and convolutions and Fourier transforms and so on.