# How to call Gurobi solver?

**URL:** <https://discourse.julialang.org/t/how-to-call-gurobi-solver/106351>\
**Category:** Optimization (Mathematical)\
**Tags:** gurobi\
**Created:** [November 17, 2023, 7:33am UTC](https://discourse.julialang.org/t/how-to-call-gurobi-solver/106351 "2023-11-17T07:33:06Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kaiming\_Zhang](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kaiming_zhang/32/202862_2.png) [@Kaiming\_Zhang](https://discourse.julialang.org/u/Kaiming_Zhang)\
**Post date:** [November 17, 2023, 7:33am UTC](https://discourse.julialang.org/t/how-to-call-gurobi-solver/106351/1 "2023-11-17T07:33:06Z")

</div>

When I called Gurobi (v1.1.0) with the following code,

> m\_cvx = Model(optimizer\_with\_attributes(Gurobi.Optimizer,GRB\_ENV,“OutputFlag”=\>0))

it fails with methoderror.

```julia
MethodError: no method matching optimizer_with_attributes(::Type{Gurobi.Optimizer}, ::Gurobi.Env, ::Pair{String, Int64})

Closest candidates are:
  optimizer_with_attributes(::Any, !Matched::Pair...)
   @ JuMP C:\Users\MNRG\.julia\packages\JuMP\D44Aq\src\optimizer_interface.jl:47

Stacktrace:
 [1] cvxrs(network_data::Dict{String, Any}, option::String, target_network_data::Nothing)
   @ Main C:\Users\MNRG\Desktop\PowerFlowCVXRS-master\src\main.jl:405
 [2] scrs(network_data::Dict{String, Any}, max_iter_SCRS::Int64)
   @ Main C:\Users\MNRG\Desktop\PowerFlowCVXRS-master\src\main.jl:806
 [3] top-level scope
   @ C:\Users\MNRG\Desktop\PowerFlowCVXRS-master\example.jl:19

```

How should I call Gurobi solver?

---

<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, 2023, 8:23am UTC](https://discourse.julialang.org/t/how-to-call-gurobi-solver/106351/2 "2023-11-17T08:23:22Z")

</div>

Hi @Kaiming_Zhang

See [jump-dev/Gurobi.jl · JuMP](https://jump.dev/JuMP.jl/stable/packages/Gurobi/#Reusing-the-same-Gurobi-environment-for-multiple-solves)

You need

```julia
model = Model(() -> Gurobi.Optimizer(GRB_ENV))
set_silent(model)

```
