Skip to content

GUROBI

How to get

To download gurobi you have to register at https://www.gurobi.com/academia/academic-program-and-licenses/

then you can download and activate your key.

On the CIRRELT/GERAD Linux computers, gurobi is already installed and you can acces it by loading the gurobi module.

module load gurobi

Installation

for some languages like python and julia, evn if gurobi is installed you have to install the package specific to the language.

gurobipy is available on pypy so it can be installed with pip.

module load gurobi/11.0.0
pip3 install gurobipy

Here's an installation procedure for gurobi 11.0.0. Make sure you load the same version of the module as the one you install.

You should use a virtual nvironment for your project.

import Pkg
Pkg.add("JuMP")
ENV["GUROBI_HOME"]  = "/home/gurobi/11.0.0/linux64"
Pkg.add("Gurobi")
Pkg.build("Gurobi")

Compilation

C++

When you compile your C++ program with gurobi, you need to specify which g++ library to use. This varies depending on the version of the compiler that you use. you can check the version with this command:

g++ --version
  • g++ < 7 use: -lgurobi_g++4.8

  • g++ >= 7 use: -lgurobi_g++5.2

If you're not using the default version of gurobi, you might need to adjust the library versions.

Number of threads

By default, gurobi will use all the core of a machine when you optimise. Since computers are shared, limit the number of cores for your application. Also, the more threads you use, the more memory it will use.

GRBsetintparam(GRBgetenv(model), GRB_INT_PAR_THREADS , 1)
model.set(GRB_IntParam_Threads, 1)
model.setParam(GRB.Param.Threads,1)
m = Model(solver = GurobiSolver(Threads=1))