User Tools

Site Tools


tutorial:gurobi-install

Installing Gurobi on Linux systems

This tutorial is a short walk-through on how to install the Gurobi solver on linux systems, including our machines.

For feedback or suggestions feel free to write an e-mail to s6kopapauni-bonn.

Step 1 - Downloading and unpacking Gurobi

First of all you require the correct version of Gurobi. You can go to https://www.gurobi.com/downloads/ (you will need an account to view this page) and navigate the site to find the correct link. In this tutorial we will use the link to the current (November 2023) version 10.0.3.

After finding the link, download the archive:

wget https://packages.gurobi.com/11.0/gurobi11.0.1_linux64.tar.gz

Then move the archive into the directory in your home directory you want to install Gurobi into, in this example opt:

mv gurobi10.0.3_linux64.tar.gz ~/opt/

Note: You might have to create the ~/opt/ directory using mkdir ~/opt first.

Finally move into the directory and unpack the archive:

cd ~/opt/
tar -xzvf gurobi10.0.3_linux64.tar.gz

After unpacking you can delete the archive:

rm gurobi10.0.3_linux64.tar.gz

Step 2 - Setting up the environment variables

After installing and creating the license file we have to setup some variables in your .bashrc file.

First open the file:

vim ~/.bashrc

Then enter add the following lines, replacing {PATH_TO_YOUR_HOME} with the _aboslute_ path to your home directory, and save the file:

export GUROBI_HOME="{PATH_TO_YOUR_HOME}/opt/gurobi1003/linux64"
export GRB_LICENSE_FILE="{PATH_TO_YOUR_HOME}/gurobi.lic"
export PATH="${PATH}:${GUROBI_HOME}/bin"
export LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${GUROBI_HOME}/lib"

Note: If you installed Gurobi or the license file into a different directory you have to adjust the paths in the first two lines.

After saving, reload .bashrc:

source ~/.bashrc

Step 3 - Setting up the license file

To use Gurobi you need a license. The details of this license must be given in a file in order for Gurobi to work on the machine. Therefore you need to create a license file and in the next step link its location. In this example we will create the license file in the home directory.

First of all visit https://www.gurobi.com/academia/academic-program-and-licenses/ to aquire your license. Acadamic licences for Gurobi a free. After creating an account, then requesting a license you can open an overview of your licenses:

Then, once you click INSTALL on the license in the list, you should see this window:

Now copy the grbgetkey line from the site and enter it into a terminal. You will then be asked to specify a install directory for the license file, simply press enter to choose your home directory. For grbgetkey to work, you need to have Gurobi installed and properly setup first.

Should you put this license in a different path than the one specified in Step 2, you will have to go back and change the license variable in your .bashrc accordingly and reload it with source ~/.bashrc again.

Important

A free academic license expires after one year and is only valid on one machine. Alternatively, you can create an free WSL license, which expires after 3 month can be extended, which can be used on different machines. Those licenses are however limited to machine with no more than 8 CPU cores. For more information see here.

Step 4 - Test Gurobi

After getting a license you can test Gurobi:

gurobi.sh

If you can see an interactive shell looking similar to this, the installation setup was successful:

Python 3.7.11 (default, Aug 31 2021, 15:25:19)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-44)] on linux
Type "help", "copyright", "credits" or "license" for more information.
Set parameter Username
Set parameter LogFile to value "gurobi.log"
Academic license - for non-commercial use only - expires 2023-01-23

Gurobi Interactive Shell (linux64), Version 9.5.0
Copyright (c) 2021, Gurobi Optimization, LLC
Type "help()" for help

gurobi>

It is important that the line Academic license - for non-commercial use only is displayed, this confirms that the license setup was successful.

To close the application either enter exit() or press CTRL+D .

Fixing ''undefined reference'' bug

After the initial setup it is usual to get an undefined reference error when trying to build something with Gurobi. This is a known bug and easy to fix:

First navigate to the Gurobi build directory:

cd ~/opt/gurobi1003/linux64/src/build

Then use make to build:

make

Finally, copy the newly created lib files:

cp libgurobi_c++.a ../../lib/

For more info see here.

tutorial/gurobi-install.txt · Last modified: 2024/04/18 10:06 by jonas.charfreitag

Page Tools