Compiled code with matlab compiler using singleCompThread uses more than 100 percent cpu

조회 수: 5 (최근 30일)
I need to compile the code with singleCompThread. However, the resulted code when I run it using matlab runtime uses more than 100 percentage. This is limiting (reducing) the number of jobs I can submit because I have to allocate 2 cpus per job.
I have tried these to ways:
Using singleCompThred while compiling
mcc -m code_to_compile.m -R -singleCompThread
and using maxNumCompThreads(1) inside the code.
Please suggest a workaround!

답변 (1개)

Shivani
Shivani 2024년 2월 26일
편집: Shivani 2024년 2월 26일
I understand that you would like to limit MATLAB to using just a single core on your machine.
Without using the -singleCompThread option, you may still be able to limit MATLAB's CPU usage by using the means provided by your operating system. For example, if you are working in a Linux environment, you can try using the taskset command within the shell to launch and pin an instance of MATLAB to a specific CPU core. The following command would launch MATLAB (assuming it is on the system path) and restrict it to using only the first logical CPU core:
$ taskset -c 0 matlab
Depending on your platform, there may be other commands that you can use to alter a program's CPU usage, such as that of MATLAB. Using taskset, the maxNumCompThreads(n) command does not return an error as it does when using the -singleCompThread flag. One thing to note, though, is that the taskset command in Linux requires you to specify the exact logical CPU core(s) on which MATLAB is to run.
For more information about taskset, you can consult the documentation provided by your Linux operating system by issuing the following command at a terminal prompt:
$ man taskset
Hope this helps!

카테고리

Help CenterFile Exchange에서 C Shared Library Integration에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by