# Multi-threading in Gurobi-JuMP Interface

**URL:** https://discourse.julialang.org/t/multi-threading-in-gurobi-jump-interface/17626
**Category:** Optimization (Mathematical)
**Tags:** package
**Created:** [November 16, 2018, 11:20pm UTC](https://discourse.julialang.org/t/multi-threading-in-gurobi-jump-interface/17626 "2018-11-16T23:20:18Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![GabrielYin](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gabrielyin/32/6059_2.png) [@GabrielYin](https://discourse.julialang.org/u/GabrielYin)
#### Post date: [November 16, 2018, 11:20pm UTC](https://discourse.julialang.org/t/multi-threading-in-gurobi-jump-interface/17626/1 "2018-11-16T23:20:18Z")

</div>

Hi there,

I am a new Julia user in optimization usage, switched from GAMS and AMPL. I have tested some codes and they worked well. However, I would like to know how to set multi-threading in the Gurobi-JuMP interface.

I was just using Barrier method (Method=2) in Gurobi to solve an LP problem. I guess if I need to indicate the threads in the following code?  
‘’'julia  
using JuMP  
import Gurobi

m1 = Model(solver = Gurobi.GurobiSolver(Method=2))  
‘’’

In the output, I got:

Barrier statistics:  
AA’ NZ : 6.000e+00  
Factor NZ : 1.000e+01  
Factor Ops : 3.000e+01 (less than 1 second per iteration)  
Threads : 1

That’s where I am interested to change. Thanks in advance for your replies!

Gabriel

---

<div class="post-metadata">

### Author: ![GabrielYin](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gabrielyin/32/6059_2.png) [@GabrielYin](https://discourse.julialang.org/u/GabrielYin)
#### Post date: [November 16, 2018, 11:21pm UTC](https://discourse.julialang.org/t/multi-threading-in-gurobi-jump-interface/17626/2 "2018-11-16T23:21:19Z")

</div>

Sorry for the wrong quote lol, first-time user, I guess the right way is:

```julia
using JuMP
import Gurobi

m1 = Model(solver = Gurobi.GurobiSolver(Method=2))

```

---

<div class="post-metadata">

### Author: ![odow](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/odow/32/28685_2.png) [@odow](https://discourse.julialang.org/u/odow)
#### Post date: [November 17, 2018, 10:55pm UTC](https://discourse.julialang.org/t/multi-threading-in-gurobi-jump-interface/17626/3 "2018-11-17T22:55:38Z")

</div>

You’re looking for the `Threads` option, e.g., `GurobiSolver(Threads=2)`.

> **[Threads - Gurobi Optimization](https://www.gurobi.com/documentation/8.0/refman/threads.html)**
>
> Threads

---

<div class="post-metadata">

### Author: ![GabrielYin](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gabrielyin/32/6059_2.png) [@GabrielYin](https://discourse.julialang.org/u/GabrielYin)
#### Post date: [November 17, 2018, 11:21pm UTC](https://discourse.julialang.org/t/multi-threading-in-gurobi-jump-interface/17626/4 "2018-11-17T23:21:18Z")

</div>

Thanks for your reply.

I do not know if you mean to do like this, but it seems not working.

 ![threads](https://global.discourse-cdn.com/julialang/original/3X/d/8/d8e34370f726f532ece54a8b161ac28183149fb9.jpeg)  
It is just a small LP example.

Gabriel

---

<div class="post-metadata">

### Author: ![odow](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/odow/32/28685_2.png) [@odow](https://discourse.julialang.org/u/odow)
#### Post date: [November 17, 2018, 11:46pm UTC](https://discourse.julialang.org/t/multi-threading-in-gurobi-jump-interface/17626/5 "2018-11-17T23:46:45Z")

</div>

Presumably Gurobi decides that the model is too easy and it only uses one thread. Try on a harder model.

This isn’t really JuMP or Julia related, so you might have more luck on the Gurobi forum:  
[https://groups.google.com/forum/#!forum/gurobi](https://groups.google.com/forum/#!forum/gurobi)
