Skip to main content

Databricks community member gurobi license setup

Answered

Comments

3 comments

  • Official comment
    Ronald van der Velden
    Gurobi Staff Gurobi Staff

    Hi Salma!

    There are two parts to make this work - I assume the challenge is only with the second bullet but just to be sure:

    • Installing Gurobi: Have you managed to install gurobipy on your Databricks cluster? Ideally you configure it as a required library on your cluster, but I'm not sure if you can access that functionality. Let me know if you need a workaround.
    • Configuring the license: I assume you have downloaded your WLS license from https://license.gurobi.com/ as a text file containing the parameters WLSACCESSID, WLSSECRET and LICENSEID. Now you need to tell the Gurobi API this WLS license information. The approaches we describe in the article, are the safest way to store your license key. If you can't use these approaches, you will unfortunately need to store the license information in your notebook. You can use the code snippet from the section "Retrieving and using environment variables", but will replace the calls to os.getenv() by hardcoded strings as below.
    with gp.Env(params={
      'LICENSEID': '...', 
      'WLSACCESSID': '...', 
      'WLSSECRET': '...'
    }) as env:
      with gp.Model(env=env) as model:
        # Construct and solve your model

    Does that help?

    Kind regards,
    Ronald

  • Salma Dessouki
    First Comment
    First Question

    When I run 

    import os

    WLSACCESSID = 'XX-XX-XX-XX'
    WLSSECRET = 'XX-XX-XX-XX
    LICENSEID = XXXX

    with gp.Env(params={
    'LICENSEID': LICENSEID,
    'WLSACCESSID': WLSACCESSID,
    'WLSSECRET': WLSSECRET
    }) as env:
    with gp.Model(env=env) as model:

    # Create Gurobi model
    model = gp.Model("3D_Optimization")

    Output:
    Set parameter WLSAccessID 
    Set parameter WLSSecret
    Set parameter LicenseID to value XXXX
    Academic license XXXX - for non-commercial use only - registered to sa___@mail.utoronto.ca
     
    Then after adding all of my variables, constraints, and objective function then i run: model.optimize()
    Output:
    Gurobi Optimizer version 11.0.0 build v11.0.0rc2 (linux64 - "Ubuntu 20.04.6 LTS")
    CPU model: Intel(R) Xeon(R) CPU E5-2686 v4 @ 2.30GHz, instruction set [SSE2|AVX|AVX2]
    Thread count: 1 physical cores, 2 logical processors, using up to 2 threads

    GurobiError: Model too large for size-limited license; visit https://www.gurobi.com/free-trial for a full license

    Any idea how to fix this?

    0
  • Riley Clement
    Gurobi Staff Gurobi Staff

    Hi Salma,

    Your first with statement creates an environment with your license details, the second with statement creates a model within that environment (called "model") - so far so good.  Then you have this line:

    model = gp.Model("3D_Optimization")

    which creates a new model, not tied to your environment, and overwrites your "model" variable.  This model is then linked to a default environment which looks to be associated with the free "pip" license that is distributed with gurobipy (which has restrictions on it).

    Can I suggest the following:

    import os
    
    params = {
    'WLSACCESSID':'XX-XX-XX-XX', 'WLSSECRET':'XX-XX-XX-XX ',
    'LICENSEID': XXXX,
    } with gp.Env(params=params) as env: with gp.Model("3D_Optimization", env=env) as model: # Create variables and constraints
    x = model.addVars(...) # <- example

    - Riley

    0

Please sign in to leave a comment.