Gurobi

To setup your license properly (not for submitting jobs)

In your home directory, using the vi or nano editor on the HPC, create a file called gurobi.lic, that contains one line:

TOKENSERVER=oit205lic.oit.ncsu.edu

Then, on a new login node (log out and log in) do these tests:

  module load gurobi
  gurobi_cl --tokens

This should show that there are 4096 total tokens

How to integrate a check for token availability: https://support.gurobi.com/hc/en-us/articles/360029879251-How-do-I-check-the-availability-of-floating-license-tokens

gurobi_cl --license
should give:
License file: /home/[user]/gurobi.lic
Check if the value of $GRB_LICENSE_FILE is undefined.
echo $GRB_LICENSE_FILE
GRB_LICENSE_FILE: Undefined variable.

Using GUROBI in Python (for submitting jobs)

To run Python code which uses GUROBI, such as matrix1 in matrix examples, you should use a Conda environment.

Create a Conda environment with the gurobi python package using the gurobi_env.yml file. See the instructions for installing software with Conda for details about initializing conda.

Once you have initialized conda, use this command to create the environment:

conda env create --prefix /usr/local/usrapps/$GROUP/$USER/gurobi_matrix_env -f gurobi_env.yml

Create a batch script file called submit.sh containing:

#!/bin/bash
#SBATCH --job-name=gurobi_test
#SBATCH --output=out.%j
#SBATCH --error=err.%j
#SBATCH --time=00:10:00
#SBATCH --ntasks=1

source ~/.bashrc
conda activate /usr/local/usrapps/$GROUP/$USER/gurobi_matrix_env
python matrix.py
conda deactivate

Submit the job with

sbatch submit.sh

The output will be written to out.%j.

Last modified: September 01 2026 21:22:40.