Gurobi: Difference between revisions
mNo edit summary |
mNo edit summary |
||
Line 69: | Line 69: | ||
echo "Threads ${SLURM_CPUS_ON_NODE:-1}" > gurobi.env | echo "Threads ${SLURM_CPUS_ON_NODE:-1}" > gurobi.env | ||
gurobi_cl ${ | gurobi_cl ${GUROBI_HOME}/examples/data/coins.lp | ||
}} | }} | ||
Line 80: | Line 80: | ||
|contents= | |contents= | ||
#!/bin/bash | #!/bin/bash | ||
#SBATCH --time=0:30 | #SBATCH --time=0-00:30 # time limit (D-HH:MM) | ||
#SBATCH --cpus-per-task=1 # number of CPUs (threads) to use | |||
#SBATCH --mem-per-cpu=1000M # memory per CPU (in MB) | #SBATCH --mem-per-cpu=1000M # memory per CPU (in MB) | ||
module purge | module purge | ||
Line 88: | Line 89: | ||
echo "Threads ${SLURM_CPUS_ON_NODE:-1}" > gurobi.env | echo "Threads ${SLURM_CPUS_ON_NODE:-1}" > gurobi.env | ||
gurobi.sh ${ | gurobi.sh ${GUROBI_HOME}/examples/python/facility.py | ||
}} | }} |
Revision as of 20:03, 10 December 2019
Gurobi is a commercial software suite for solving complex optimization problems. This page wiki page describes the non-commercial use of Gurobi software on Compute Canada clusters and is currently a work in progress.
License limitations
Compute Canada supports and provides a free license to use Gurobi Graham, Cedar, Beluga and Niagara clusters. The license provides a total number of 4096 simultaneous uses (tokens in use) and permits distributed optimization with up to 100 nodes. A single user can run multiple simultaneous jobs. In order to use Gurobi you must agree to certain conditions. Please contact support and include a copy of the following Academic Usage Statement. You will then be added into the Compute Canada license file as a permitted user within a few days:
My Compute Canada username is "_______" and I am a member of the academic institution "_____________________". This message confirms that I will only use the Compute Canada Gurobi license provided on Compute Canada systems for the purpose of non-commercial research project(s) to be published in publicly available article(s).
Interactive Allocations
Gurobi Command-Line Tools
[gra-login2:~] salloc --time=1:00:0 --cpus-per-task=8 --mem=1G --account=def-xyz [gra800:~] module load gurobi [gra800:~] gurobi_cl Record=1 Threads=8 Method=2 ResultFile=p0033.sol LogFile=p0033.log $GUROBI_HOME/examples/data/p0033.mps [gra800:~] gurobi_cl --help
Gurobi Interactive Shell
[gra-login2:~] salloc --time=1:00:0 --cpus-per-task=8 --mem=1G --account=def-xyz [gra800:~] module load gurobi [gra800:~] echo "Record 1" > gurobi.env see * [gra800:~] gurobi.sh gurobi> m = read('/cvmfs/restricted.computecanada.ca/easybuild/software/2017/Core/gurobi/8.1.1/examples/data/glass4.mps') gurobi> m.Params.Threads = 8 see ** gurobi> m.Params.Method = 2 gurobi> m.Params.ResultFile = "glass4.sol" gurobi> m.Params.LogFile = "glass4.log" gurobi> m.optimize() gurobi> m.write('glass4.lp') gurobi> m.status see *** gurobi> m.runtime see **** gurobi> help()
where
* https://www.gurobi.com/documentation/8.1/refman/recording_api_calls.html ** https://www.gurobi.com/documentation/8.1/refman/parameter_descriptions.html *** https://www.gurobi.com/documentation/8.1/refman/optimization_status_codes.html **** https://www.gurobi.com/documentation/8.1/refman/attributes.html
Replay API Call Recording
[gra800:~] gurobi_cl recording000.grbr
Reference: https://www.gurobi.com/documentation/8.1/refman/recording_api_calls.html
Batch Jobs
Model in LP-format
This is an example jobscript for an optimization model written in the LP format.
#!/bin/bash
#SBATCH --time=0:30 # time limit (D-HH:MM)
#SBATCH --mem-per-cpu=1000M # memory per CPU (in MB)
module purge
module load gurobi
# Create environment file in current directory setting the number of threads:
echo "Threads ${SLURM_CPUS_ON_NODE:-1}" > gurobi.env
gurobi_cl ${GUROBI_HOME}/examples/data/coins.lp
Job using Gurobi Python
This is an example jobscript for a model using Gurobi-Python.
#!/bin/bash
#SBATCH --time=0-00:30 # time limit (D-HH:MM)
#SBATCH --cpus-per-task=1 # number of CPUs (threads) to use
#SBATCH --mem-per-cpu=1000M # memory per CPU (in MB)
module purge
module load gurobi
# Create environment file in current directory setting the number of threads:
echo "Threads ${SLURM_CPUS_ON_NODE:-1}" > gurobi.env
gurobi.sh ${GUROBI_HOME}/examples/python/facility.py