How to use multithreads more efficiently with Gurobi?
AnsweredDear Friends,
I am using Java to solve a massive number (say 1 million) of MIPs on a server with 64 cores. I am using 44 (N1=44) cores to take the 1 million MIP tasks, and for each task I am also using a multi-threading strategy with model.set(GRB.IntParam.Threads, 20) (N2=20) to speed up each MIP. However, I wonder whether this is a good way because I am not sure whether the 44 Gurobi models are competing for the 20 threads which would harm the multi-threading performance of each MIP. Or do you have any advice on a good balance of core distribution strategy for N1 and N2. For example, a big N1 and small N2 or small N1 and big N2?
Thank you very much for your help!
-
If I understand correctly you are using N1=44 cores to run 44 MIPs in parallel and for each of those MIPs you are setting Threads=20. Is this correct?
0 -
Yes, Jaromił. That's correct.
0 -
In this case it is possible that multiple models will fight over resources. It is best to set Threads to a value which would avoid "overlapping" of processes, i.e., N1 / #MIPs = Threads. In your case this would mean to set Threads=1. It might make sense to do some testing before setting this value. You could test running a set of your MIPs with Threads=1,2,4,8 and see which Threads setting performs best on a representative test set of your MIPs. You can then still use N1 = 44 cores and then run 44/#threads MIPs with setting Threads=#threads. This way, each optimization run would not have to possibly fight for resources. As an example, you could use N1 = 44 cores and run 11 MIPs in parallel with each using Threads=4.
Best regards,
Jaromił0 -
Thanks for your advice. In my case, each core will have one model running. So, do you mean it is better to set N1*N2 = #total cores (64 here), like N1=32, N2=2,or N1=64, N2=1, so that N1 models will not fight for resources? Moreover, I really care about the running time, so if I set N1=N2=32, each model might not benefit from Gurobi's multithreaded strategy because 32*32 >> 64?
0 -
So, do you mean it is better to set N1*N2 = #total cores (64 here), like N1=32, N2=2,or N1=64, N2=1, so that N1 models will not fight for resources?
Yes, this is what I mean. It might be worth considering to use N1=16, N2=4, or N1=8, N2=8, because usually MIPs benefit from multiple threads. This however has to be tested on your side.
Moreover, I really care about the running time, so if I set N1=N2=32, each model might not benefit from Gurobi's multithreaded strategy because 32*32 >> 64?
Correct, different processes might start fighting over resources, causing a significant slowdown in the end.
Best regards,
Jaromił0 -
Thanks again! I will try this out.
0
Please sign in to leave a comment.
Comments
6 comments