How to install gurobi in Ubuntu 18.04 outside an academic domain

To install gurobi, you can do it throught anaconda or tarball, secondly we need configure PATHS and  register the licence.

Anaconda option to install:

chmod +x 
conda update -n base conda
conda update -n base conda
conda config --add channels
conda install gurobi

If you want to uninstall anaconda, you can do it the following:

conda install anaconda-clean
rm -rf ~/anaconda3

Tarball option to install:

First, you need to create an account in Gurobi here and after proceed to download it:

tar xzvf gurobi7.5.2_linux64.tar.gz
cd gurobi752/linux64
sudo python install

Configure gurobi:

We need to add the PATH to our environment. By default, in linux, we use .bashrc
Edit ~/.bashrc and add the following lines:

export GUROBI_HOME="/path_where_you_unzip_gurobi/gurobi702/linux64"
export PATH="${PATH}:${GUROBI_HOME}/bin"

To reload paths (restart bash) you can use "bash --" command. Now execute gurobi_cl:


ERROR 10009: No Gurobi license found (user anonymous, host anonymous, hostid b025bc03)

We need a licence to register gurobi. You can request a free-academic licence from here.
To dowload gurobi.lic you need to execute grbgetkey command with the key that the site gives you.

grbgetkey 78b0538c-4563-11e8-b039-0a45627c772a

Gurobi license key client (version 7.5.2)
Copyright (c) 2017, Gurobi Optimization, Inc.

Contacting Gurobi key server...

ERROR 303: hostname ( not recognized as belonging to an academic domain

If you are not in an academic domain, you can get it throught two ways:

First option (from public ip):

Install sshserver on your local workstation 
ssh -L your_username@your_ip_address
grbgetkey --server= --port=8080 --verbose xxxx-xxxx-xxxxxxx-xxxx 

Second option (from private ip):

Access to your academic domain throught ssh and download the licence with your machine info.
Gurobi request the following information to generate the licence:

<key> is a valid academic key obtained freely from the Gurobi website.
<hostname> is the hostname of the computer you’d like to create a license for.
<hostid> is the last 4 bytes of your first computer’s MAC address in hexadecimal notation.
<username> is your user name on the computer for which you are requesting a license.
<platform> is a string used by Gurobi to identify the OS of your computer (e.g. linux64).
<sockets> is the number of wired network devices on the computer you are requesting a license for.
<date> is today’s date in YYYY-MM-DD notation (without zero).

You can get the partial info from grbprobe:

CPU=Intel(R) Core(TM) i9-3337U CPU @ 4.80GHz

The others fields are:
DATE=`date +%Y-%m-%d | sed 's/-0/-/g'`

Download the licence with the following url from your computer inside the academic domain:

wget " &hostname=anonymous&hostid=bc25dc0d&username=anonymous&os=linux64&sockets=1&cpu=Intel%28R%29_Core%28TM%29_i9-3337U_CPU_%40_4.80GHz&localdate=2018-4-21" -O gurobi.lic

If you use this method to download gurobi.lic you must remove the following fourth first lines:

# DO NOT EDIT THIS FILE except as noted

Now, download the licence to your computer (where you have gurobi):

scp user@academic_domain:/path_to_gurobi.lic .

Export the path in your ~/.bashrc to detect the licence

export GRB_LICENSE_FILE="/path_to_your_licence/gurobi.lic"

Reload bash and execute

If you forget edit gurobi.lic you will probably get a segmentation fault:
Python 2.7.13 (default, Sep  4 2017, 15:40:17) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-18)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
Segmentation fault (core dumped)

Enjoy it!


Popular posts from this blog

How to fix Android when developer options are not available for this user

from: can't read /var/mail/ in Python scripts

How to fix VirtualBox error when you try to import an ova file