How to install gurobi in Ubuntu 18.04 out/inside 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 Anaconda3-5.1.0-Linux-x86_64.sh
conda update -n base conda
conda update -n base conda
conda config --add channels http://conda.anaconda.org/gurobi
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
sudo python setup.py install
We need to add the PATH to our environment. By default, in linux, we use .bashrc
Edit ~/.bashrc and add the following lines:
To reload paths (restart bash) you can use "bash --" command.
Probably you will see the following issue:
gurobi_cl: error while loading shared libraries: libgurobi81.so: cannot open shared object file: No such file or directory
Also adds the following line to your bashrc file:
Restart bash and execute gurobi_cl again:
Warning: Failed to open log file 'gurobi.log'
ERROR 10013: Unable to write file
If you see this issue, you need to give access to your user to gurobi.log, just change them with:
chmod 777 gurobi.log
Now, execute again 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.
Gurobi license key client (version 7.5.2)
Copyright (c) 2017, Gurobi Optimization, Inc.
Contacting Gurobi key server...
ERROR 303: hostname reverso.181.223.199.operaciones.gtdinternet.com (188.8.131.52) 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 8080:apps.gurobi.com:8080 your_username@your_ip_address
grbgetkey --server=127.0.0.1 --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:
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
Reload bash and execute gurobi.sh
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)