Skip to main content

Latest Tweets

Using Knitro on ECCO

Print Friendly

Where to run knitro

We have a license for Knitro (http://www.ziena.com/knitromatlab.htm) on ECCO. It only works on a single node (compute-0-8).

How to submit knitro jobs

Unlike for some other software, there's no "qknitro". Here's how to submit Knitro jobs:

  1. Write your Matlab-Knitro or Knitro job
  2. Write your qsub job (see generic instructions), but be certain to include
    module load matlab/(YOUR VERSION)
    module load knitro
    

    (this ensures that knitro can find its license, and its libraries)

  3. From the command line, submit to the 'knitro' queue:

    qsub [other parameters] -q knitro myjob.qsub
  4. You could add

    #PBS -q knitro

    to your qsub job and omit the -q knitro part

Complete example qsub


#PBS -l mem=32768mb
#PBS -l ncpus=4
#PBS -q knitro
source /etc/profile.d/modules.sh
module load matlab/R2014b
module load knitro
matlab -nojvm -nodesktop -nosplash < test.m

You then should add the following code to your Matlab program test.m:

addpath('/opt/knitro/knitromatlab');
[x fval] = knitromatlab(@(x)cos(x),1)

before invoking the knitro functions.

Debugging

Occassionally, things break down. Some things you may be able to fix yourself, others you will need help.

  • Test with a simple call to knitro [ref]:

    [x fval] = knitromatlab(@(x)cos(x),1)
  • If the error message is something like this:

    Undefined function 'knitromatlab' for input arguments of type
    'function_handle'.

    then you forgot to add the module load knitro commands, you are on the wrong server (did not submit to knitro queue), something else changed, etc. Check again. It means that Matlab cannot find the knitro functions.
  • If the output is like this:

    ### Could not find a valid license.
    Your machine ID is xx-xx-xx-xx-xx.
    Please contact info@ziena.com or your local distributor to obtain a license.
    If you already have a license, please execute `get_machine_ID -v` and send the output to support.
    Failed to find a Ziena license.
    Fatal: KTR_set_int_param() passed NULL for knitro context pointer.
    Error using knitromatlab_mex
    KNITRO failed while attempting to set parameters.

    then you are on the right server, but forgot to do module load knitro
  • The correct output should be something like this

    ======================================
    Academic Ziena License (NOT FOR COMMERCIAL USE)
    KNITRO 9.0.1
    Ziena Optimization
    ======================================
    [snip] x =
    3.1416
    fval =
    -1.0000

Changes of note

  • The function is no longer called ktrlink() !!
  • In previous versions of this setup on ECCO, you could omit the "addpath()" part. That is no longer true.