# Parallel Solves in Gurobi.jl

**URL:** <https://discourse.julialang.org/t/parallel-solves-in-gurobi-jl/9908>\
**Category:** Optimization (Mathematical)\
**Created:** [March 22, 2018, 9:49pm UTC](https://discourse.julialang.org/t/parallel-solves-in-gurobi-jl/9908 "2018-03-22T21:49:28Z")\
**Posts on this page:** 1\
**Showing post:** 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:** [March 23, 2018, 12:52am UTC](https://discourse.julialang.org/t/parallel-solves-in-gurobi-jl/9908/2 "2018-03-23T00:52:33Z")

</div>

The issue with the new line is that it instantiates the Gurobi model on the master process and copies that model to the other processes. You need to create different Gurobi models on different processes.  
One option is

```julia
addprocs(2)

@everywhere using JuMP, Gurobi

@everywhere const env = Gurobi.Env()

@everywhere function upperbound_mip2(i)
    m = Model(solver=GurobiSolver(env, OutputFlag=0))
    @variable(m, 0 <= x[i=1:100] <= i)
    @objective(m, Max, x[i])
    solve(m)
    getobjectivevalue(m)
end

pmap(upperbound_mip2, 1:100)

```

another option is

```julia
addprocs(2)

@everywhere using JuMP, Gurobi

@everywhere const env = Gurobi.Env()
@everywhere const m = Model(solver=GurobiSolver(env, OutputFlag=0))
@everywhere @variable(m, 0 <= x[i=1:100] <= i)

@everywhere function upperbound_mip2(i)
    @objective(m, Max, x[i])
    solve(m)
    getobjectivevalue(m)
end

pmap(upperbound_mip2, 1:100)

```

---

_[View the full topic](https://discourse.julialang.org/t/parallel-solves-in-gurobi-jl/9908)._
