Limiting MATLAB processor usage: Difference between revisions

From Fluids Wiki
Jump to navigation Jump to search
(Created page with 'Sometimes it is necessary to limit the number of processors that MATLAB uses while it is running so as some of the machine's processors may be free for others to use. In older …')
 
 
(8 intermediate revisions by 3 users not shown)
Line 1: Line 1:
Sometimes it is necessary to limit the number of processors that MATLAB uses while it is running so as some of the machine's processors may be free for others to use.  
Sometimes it is desired to limit the number of processors that MATLAB uses while it is running so that some of the machine's processors may be free for others to use.  


In older versions of MATLAB, it was possible to change MATLAB's processor affinity after MATLAB had been started using the 'maxNumCompThreads' command, but this command has since been removed in newer versions.
In older versions of MATLAB, it was possible to change the number of threads that MATLAB forks with use of the 'maxNumCompThreads' command, but this command has been removed in newer versions.




Line 7: Line 7:




To start a new matlab job from the command-line limited to, for example, four processors, type:
To start a new matlab job from the command-line which is limited to, for example, four processors, type:
 
taskset -c 0,1,2,3 matlab  
<code>
That command will start matlab to only be able to use CPU's 0,1,2 & 3. To get an idea of which processors are currently in use, (to know which ones are free to pass into 'taskset'),  run the 'top' command, then hit 'f','j','enter'. The 'P' column indicates which processor a task is running on. To have 'top' run with the P column by default, save your settings by hitting shift+'W'+'enter'.
taskset -pc 0,1,2,3 matlab  
</code>
 
That command will start matlab to only be able to use CPU's 0,1,2 & 3. To get an idea of which processors are currently in use beforehand, (to know which ones are free to pass into 'taskset'),  run the 'top' command, then hit 'f','j','enter'. The 'P' column indicates which processor a task is running on. To have 'top' run with the P column by default, save your settings by hitting 'W'+'enter'.

Latest revision as of 16:02, 9 March 2017

Sometimes it is desired to limit the number of processors that MATLAB uses while it is running so that some of the machine's processors may be free for others to use.

In older versions of MATLAB, it was possible to change the number of threads that MATLAB forks with use of the 'maxNumCompThreads' command, but this command has been removed in newer versions.


The taskset Linux command

To start a new matlab job from the command-line which is limited to, for example, four processors, type:

taskset -c 0,1,2,3 matlab 

That command will start matlab to only be able to use CPU's 0,1,2 & 3. To get an idea of which processors are currently in use, (to know which ones are free to pass into 'taskset'), run the 'top' command, then hit 'f','j','enter'. The 'P' column indicates which processor a task is running on. To have 'top' run with the P column by default, save your settings by hitting shift+'W'+'enter'.