# \`Gurobi.Optimizer()\` throws, reports \`Gurobi Error 10001\` even though there's plenty of memory

**URL:** https://discourse.julialang.org/t/gurobi-optimizer-throws-reports-gurobi-error-10001-even-though-theres-plenty-of-memory/107193
**Category:** Optimization (Mathematical)
**Tags:** gurobi
**Created:** [December 6, 2023, 4:00am UTC](https://discourse.julialang.org/t/gurobi-optimizer-throws-reports-gurobi-error-10001-even-though-theres-plenty-of-memory/107193 "2023-12-06T04:00:00Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![nsajko](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nsajko/32/221187_2.png) [@nsajko](https://discourse.julialang.org/u/nsajko)
#### Post date: [December 6, 2023, 4:00am UTC](https://discourse.julialang.org/t/gurobi-optimizer-throws-reports-gurobi-error-10001-even-though-theres-plenty-of-memory/107193/1 "2023-12-06T04:00:00Z")

</div>

I’m not sure why, but, some times when I run `Gurobi.Optimizer()`, it throws, reporting `Gurobi Error 10001`, which is meant for out-of-memory situations. I’m pretty sure that’s some kind of bug, because there seems to be plenty of memory left (there’s 32 GB of RAM, and, looking at `top`, I don’t think that more than 8 GB is utilized at any point. There’s also lots of swap space that’s not used at all.

This started happening recently and now it happens often.

I think it may have been caused by running two instances of Gurobi concurrently, not sure if that’s allowed under the Academic License. In any case, now it happens even when just a single Gurobi is running.

Output with stack trace:

```julia
ERROR: Gurobi Error 10001: 
Stacktrace:
  [1] _check_ret
    @ ~/.julia/packages/Gurobi/W2h9r/src/MOI_wrapper/MOI_wrapper.jl:400 [inlined]
  [2] Gurobi.Env(; output_flag::Int64, memory_limit::Nothing, started::Bool)
    @ Gurobi ~/.julia/packages/Gurobi/W2h9r/src/MOI_wrapper/MOI_wrapper.jl:110
  [3] Env
    @ ~/.julia/packages/Gurobi/W2h9r/src/MOI_wrapper/MOI_wrapper.jl:102 [inlined]
  [4] Gurobi.Optimizer(env::Nothing; enable_interrupts::Bool)
    @ Gurobi ~/.julia/packages/Gurobi/W2h9r/src/MOI_wrapper/MOI_wrapper.jl:331
  [5] Optimizer (repeats 2 times)
    @ ~/.julia/packages/Gurobi/W2h9r/src/MOI_wrapper/MOI_wrapper.jl:325 [inlined]

```

```julia-repl
julia> versioninfo()
Julia Version 1.11.0-DEV.1008
Commit b69398a810f (2023-12-04 03:08 UTC)
Build Info:
  Official https://julialang.org/ release
Platform Info:
  OS: Linux (x86_64-linux-gnu)
  CPU: 8 × Intel(R) Core(TM) i5-8300H CPU @ 2.30GHz
  WORD_SIZE: 64
  LLVM: libLLVM-15.0.7 (ORCJIT, skylake)
  Threads: 11 on 8 virtual cores
Environment:
  JULIA_PKG_DEVDIR = /home/nsajko/julia-dev-pkgs
  JULIA_EDITOR = code
  JULIA_NUM_THREADS = 8

(@v1.11) pkg> st Gurobi
Status `~/.julia/environments/v1.11/Project.toml`
  [2e9cd046] Gurobi v1.2.0

```

I’ll try rebooting now, not sure what else to try 😆

EDIT: a reboot didn’t help, so I switched to SCIP. This is so weird, I have no idea what could have changed on my laptop to cause this? Is it possible that Gurobi “phones home” and some of their servers are down, causing the solver to fail on my laptop? Really strange.

EDIT2: a workaround is to [reuse the same Gurobi environment for multiple solves](https://github.com/jump-dev/Gurobi.jl#reusing-the-same-gurobi-environment-for-multiple-solves). In my case I needed to change the line `make_opt() = Gurobi.Optimizer()` to:

```julia
const gurobi_environment = Gurobi.Env()
make_opt() = Gurobi.Optimizer(gurobi_environment)

```

---

<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: [December 6, 2023, 4:38am UTC](https://discourse.julialang.org/t/gurobi-optimizer-throws-reports-gurobi-error-10001-even-though-theres-plenty-of-memory/107193/2 "2023-12-06T04:38:13Z")

</div>

Did EDIT2 work?

> Julia Version 1.11.0-DEV.1008

Note that JuMP and related packages promise to support only the LTS of Julia (currently v1.6) and the latest official release (currently 1.9). Using the latest nightly is unsupported.

Do you have a reproducible example on Julia v1.6 or v1.9?

@vasyfa may have some insight.

---

<div class="post-metadata">

### Author: ![nsajko](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nsajko/32/221187_2.png) [@nsajko](https://discourse.julialang.org/u/nsajko)
#### Post date: [December 6, 2023, 4:41am UTC](https://discourse.julialang.org/t/gurobi-optimizer-throws-reports-gurobi-error-10001-even-though-theres-plenty-of-memory/107193/3 "2023-12-06T04:41:33Z")

</div>

> [@odow](#):
>
> Did EDIT2 work?

Yeah, my MIQPs get solved fine now. I guess the workaround is fine, and it seems like it should be more efficient anyway.

> [@odow](#):
>
> Do you have a reproducible example on Julia v1.6 or v1.9?

Sorry, but I don’t understand what’s causing this well enough to create a reproducer. It guess this depends on some global state of either Gurobi.jl or Gurobi itself, however I’m not sure why did this even start happening. Perhaps Gurobi doesn’t like when I create many Gurobi environments in a short time span?
