Databricks community member gurobi license setup
Answeredhttps://support.gurobi.com/hc/en-us/articles/20660169766545-Databricks-Installation
I am a Databricks community member (free version) so the tips in this question were not as helpful. I have an academic user license as well as a WLS license. The post says that the license approach does not apply since you can’t access advanced configuration options, the second approach doesn’t work because I can’t create environment variables through the configuration, or using Databricks secrets.
Could you please give me a step by step on how I could setup my gurobi license with my WLS access key information in a Databricks notebook with a COMMUNITY membership?
0
-
Official comment
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 -
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.caThen 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 licenseAny idea how to fix this?
0 -
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.
Comments
3 comments