I have installed a fresh version of Gurobi.jl and JuMP for Julia Version 1.3.1 on a linux server.
When making call to Gurobi 9.0 from Julia, I bump on the following error message :
ERROR: LoadError: Invalid Gurobi license
After some research on the internet, I have checked that :
my Gurobi license file was valid (N.B. this is an evaluation licence)
all environment variables are properly set
gurobi works well on its own or when used embedded in python.
Thank you for this solution, which I have used already since 1-2 years back. Nevertheless, I did all of the above and am using a Gurobi floating license (4 instances). Still it sometimes claims 2 or 3 licenses to solve one instance. Any ideas how to find the root-cause for this “random” behavior? I am doing consecutive optimization runs, and after each run I clear the environmental variable.
GC.gc()
if @isdefined(GUROBI_ENV)
Gurobi.free_env(GUROBI_ENV)
end
Also tried to put a “sleep (1)” after this in order to give some time before asking for the next license but this would not solve the issue.
In fact, even when only solving one problem, this happens. Often it takes place when running new instances (starting Julia in Atom). After repeatedly calling the optimizer it mostly stops claiming multiple licenses. However, this is random so I am a bit suspecting this relates to some communication problem between the client and license server (Gurobi?).
Would be nice to really get this under control and am happy for any further tips!
You should not be calling GC.gc() or free_env. The correct way is to call const GUROBI_ENV = Gurobi.Env() once only. If you re-include the script, bad things can happen. Indeed, in Julia 1.5 there is now a nice error:
julia> const x = 1
1
julia> const x = 2
WARNING: redefinition of constant x. This may fail, cause incorrect answers, or produce other errors.
2
For anyone that may come across this thread, you may run into issues if running the same script multiple times, for example while doing model development. In that case, I have used the following approach for defining the env constant,
I also happen to have the same error. This occurred when I tried installing Gurobi & JuMP on an HPC; I know that Gurobi academic license works as I had tested my Python script on this HPC.
I guess here is where I am confused. I used grbgetkey in /home/b2jia/anaconda3/pkgs/gurobi-9.1.2-py38_0/bin to validate the license, and gurobi_cl can indeed find this key. Am I somehow validating incorrectly?
Thank you for this, and sorry to piggy-back off another post. If someone experiences similar errors as I did, I was able to resolve my issue by contacting my HPC admin. Our primary network adapter may have been modified.
Great. I made a new release of Gurobi.jl, so people should see more informative messages in future and not just “Failed to obtain a valid license.”