Decreasing number of threads in MATLAB

100 views
Skip to first unread message

Muhammad Nadeem

unread,
Jul 8, 2021, 3:52:55 PM7/8/21
to mosek
Hey everyone,

I am trying to solve a big optimization problem in MATLAB using Mosek with Yalmip. I want to decrease number of threads because currently I am getting 'out of space' error. I am trying to use the following command but it is not working

ops.MSK_IPAR_INTPNT_MULTI_THREAD = 'MSK_OFF';

Can anyone help me here what is the problem, why it is not decreasing the number of threads?

Thanks,
Nadeem

Michal Adamaszek

unread,
Jul 8, 2021, 3:55:53 PM7/8/21
to mosek
Please explain "it is  not working" in more detail.

I am not sure if your syntax to set the parameter is correct as explained in https://docs.mosek.com/9.2/faq/faq.html#yalmip

Michal

Muhammad Nadeem

unread,
Jul 9, 2021, 1:05:55 AM7/9/21
to mosek
Thanks. By not working means, initially the optimizer threads are 4 and after using that command they are still 4. Should they be decreased to 1?

The overall command in Yalmip I am using is as:

ops = sdpsettings('verbose',1,'solver','mosek','showprogress',1,'mosek.MSK_IPAR_INTPNT_MULTI_THREAD',0);

Erling D. Andersen

unread,
Jul 9, 2021, 1:23:52 AM7/9/21
to mosek
You could try setting the parameter

ops.MSK_IPAR_INTPNT_NUM_THREADS =  1

That would be a better way of achieving what you want.


--
You received this message because you are subscribed to the Google Groups "mosek" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mosek+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mosek/ddca100b-a9f3-4ac2-b68a-b212eab91628n%40googlegroups.com.


--
Erling D. Andersen

MOSEK APS 
Fruebjergvej 3, 
Symbion Science Park Box 16, 
DK-2100 Copenhagen O

Michal Adamaszek

unread,
Jul 9, 2021, 2:25:21 AM7/9/21
to mosek
When you set MSK_IPAR_INTPNT_MULTI_THREAD=0 then the number of available threads is still displayed as 4 in the log output, but only 1 should be used. You should be able to track that in the CPU usage on the machine.

On the other hand if you set  MSK_IPAR_INTPNT_NUM_THREADS=1 then you should see only 1 thread available but remember  that  this must be done before the first loading of Mosek in your MATLAB session or else it will have no effect https://docs.mosek.com/9.2/faq/faq.html#mosek-is-ignoring-the-limit-on-the-number-of-threads

Max Bolingbroke

unread,
Oct 21, 2021, 9:05:57 AM10/21/21
to mosek
I think what's confusing here is that Mosek's log output says "Optimizer  - threads: 16" (or whatever the number is) even if you set MSK_IPAR_INTPNT_MULTI_THREAD=MSK_OFF for a particular problem.

Presumably Mosek is just reporting the size of the thread pool in its log output, even if you aren't actually utilizing that thread pool when running your particular optimization.

Erling D. Andersen

unread,
Oct 26, 2021, 12:32:22 AM10/26/21
to mosek
All this threading is way more complicated than you think when it should be efficient.

MOSEK version 9 employs Cilk for threading and the number of threads displayed is the number in the Cilk thread pool.

If you set

MSK_IPAR_INTPNT_MULTI_THREAD=MSK_OFF

then no work is send to the Cilk thread pool and all work is is performed in the main thread. 

Mosek version 10 will no longer employ Cilk but most likely oneTBB. This will allow for a more fine grained control on threading.
Although there will still be a thread pool.
Reply all
Reply to author
Forward
0 new messages