Skip to content

Submitting Gurobi Jobs With Torque

This script is an example of launching individual Gurobi Python jobs on the Kennesaw State HPC Cluster using Torque.

Torque Shell Script

In our example, we saved the following Torque script as run_gurobi.pbs (making sure to change netid@kennesaw.edu in the script to your correct email address):

run_gurobi.pbs
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/usr/bin/env bash

#PBS -l nodes=1:ppn=16,walltime=10:00:00
#PBS -m abe
#PBS -M netid@kennesaw.edu (1)
#PBS -q batch

# Load the environment modules we need
module load Anaconda3 Gurobi

# Make sure we're in the correct directory
cd $PBS_O_WORKDIR

# Run gurobi.sh against the python file we specified
gurobi.sh ${FILE}

# The following code checks the return code of gurobi.sh to see if it completed successfully
RETCODE=$?
echo ""
echo "--------------------------------"
if [[ ${RETCODE} -eq 0 ]]
then
        echo "Job Completed Successfully"
else
        echo "Job Returned An Error Code of: ${RETCODE}"
fi
echo "--------------------------------"

exit ${RETCODE}
  1. 🙋‍♂️ Make sure to change netid@kennesaw.edu on this line to your KSU email address or you won't receive emails when the job starts and stops.

Usage

Assuming you saved the Torque script from above as run_gurobi.pbs, and the name of your Gurobi Python script is my_script.py, you can submit your Gurobi job with the following command:

[barney@hpc ~]$ qsub run_gurobi.pbs -vFILE=${PWD}/my_script.py