Skip to main content

Specifying threads to be utilized on a remote machine

Answered

Comments

8 comments

  • Gurobot (AI-generated response)
    Gurobi Staff Gurobi Staff

    To ensure Gurobi only uses the 10 cores you requested, explicitly set the Threads parameter in your model to 10. This aligns Gurobi's usage with your Slurm allocation

    0
  • Tushar Rathi
    Gurobi-versary
    Conversationalist
    First Question

    However, if I only make 10 cores available and Gurobi's default setting of 0 for Threads parameter imposes a limit of 32 cores (which are obviously not available), then it should automatically utilize only 10. Why is there a need to set `Threads` parameter?

    0
  • Tushar Rathi
    Gurobi-versary
    Conversationalist
    First Question

    Jaromił Najman, any help/clarifications on this are appreciated. Thanks :)

    0
  • Ed Rothberg
    Gurobi Staff Gurobi Staff

    I think you're asking a SLURM question, not a Gurobi question.  It looks like --ntasks-per-node limits the number of jobs on a node, not the number of threads in a job.  To be sure, you should probably ask a SLURM expert.

    0
  • Eli Towle
    Gurobi Staff Gurobi Staff

    The Gurobi process isn't aware Slurm is limiting the number of cores it can use. The Gurobi process sees the machine has 24 physical cores and 24 logical processors, then uses that information to decide how many threads to use. If the number of cores available to Gurobi is externally limited to a number different than what is reported by the machine, you should set the Threads parameter to reflect this.

    1
  • Tushar Rathi
    Gurobi-versary
    Conversationalist
    First Question

    Thanks Eli Towle for the clarification! I have some follow-up questions:

    1. If I set the Threads parameter to 10, I assume it sets an upper limit on how many threads/cores (if single-threaded) Gurobi can use. Is that right? Or does it force Gurobi to use 10? 

    2. I have (say) 10 optimization problems that I am parallelizing on these 10 cores (one on each core). In this case, what do you recommend setting the Threads parameter to for each of these optimization models? Although each optimization problem utilizes one core, can Gurobi access the resources from other cores while they are occupied solving other optimization problems (without slowing down their performance)? If I simply set the Threads parameter to 10 for each model, will Gurobi figure out if it's actually efficient to utilize all threads or just stick to 1 thread (that's why question in point 1.), or maybe I should just set the Threads parameter to 1 for each problem? Again, the machine has more than 10 cores, so I would want to explicitly inform Gurobi about the available cores (which I limit using Slurm).
    0
  • Eli Towle
    Gurobi Staff Gurobi Staff

    If I set the Threads parameter to 10, I assume it sets an upper limit on how many threads/cores (if single-threaded) Gurobi can use. Is that right? Or does it force Gurobi to use 10? 

    Yes, 10 will be an upper bound on the number of threads Gurobi uses. There may be times when Gurobi does not use all 10 threads.

    Although each optimization problem utilizes one core, can Gurobi access the resources from other cores while they are occupied solving other optimization problems (without slowing down their performance)? If I simply set the Threads parameter to 10 for each model, will Gurobi figure out if it's actually efficient to utilize all threads or just stick to 1 thread (that's why question in point 1.), or maybe I should just set the Threads parameter to 1 for each problem?

    If you solve multiple models in parallel with Threads=10, each Gurobi process will use up to 10 threads. The individual Gurobi processes do not communicate with each other or look at what else is running on the machine to determine thread usage. In general, over-subscribing the machine by launching more threads than cores increases job throughput, though you should test this on your models.

    what do you recommend setting the Threads parameter to for each of these optimization models?

    I would test different combinations of Threads and number of parallel jobs to see what works best. For example:

    • Solve 10 jobs in parallel at a time, each with Threads=10
    • Solve 10 jobs in parallel at a time, each with Threads=5
    • Solve 10 jobs in parallel at a time, each with Threads=1
    • Solve 5 jobs in parallel at a time, each with Threads=2
    • Solve 2 jobs in parallel at a time, each with Threads=5
    1
  • Tushar Rathi
    Gurobi-versary
    Conversationalist
    First Question

    Perfect, that makes things clearer! Thanks Eli Towle.

    0

Please sign in to leave a comment.