Skip to content

[QST]Simple_LP_pulp.ipynb on Colab, PulpSolverError: CUOPT: Not available #508

@yishuanglnvidiacom-netizen

Description

status = prob.solve(CUOPT(msg=0)) always returns PulpSolverError: CUOPT: Not available

Below is the code, how can I get this simple example run on Colab? Thanks

!pip install pulp==3.2.0
!pip install --extra-index-url=https://pypi.nvidia.com  nvidia-cuda-runtime-cu12==12.8.*   cuopt-server-cu12==25.8.* cuopt-sh-client==25.8.*
# Import packages.
from pulp import *
import numpy as np

# Generate a random non-trivial linear program.
m = 15
n = 10
np.random.seed(1)
s0 = np.random.randn(m)
lamb0 = np.maximum(-s0, 0)
s0 = np.maximum(s0, 0)
x0 = np.random.randn(n)
A = np.random.randn(m, n)
b = A @ x0 + s0
c = -A.T @ lamb0

# Define and solve the Pulp problem
prob = LpProblem("LP_example", LpMinimize)
x = [LpVariable(f"x{i}", lowBound=None) for i in range(n)]
prob += lpSum([c[i] * x[i] for i in range(n)]), "Objective"

for i in range(m):
    prob += lpSum([A[i, j] * x[j] for j in range(n)]) <= b[i], f"Constraint_{i}"

status = prob.solve(CUOPT(msg=0))

# Print results
print("\nThe optimal value is", value(prob.objective))
x_vals = np.array([x[i].varValue for i in range(n)])
np.set_printoptions(precision=8, suppress=True)
print("A solution x is")
print(x_vals)
PulpSolverError                           Traceback (most recent call last)
[/tmp/ipython-input-1803750161.py](https://localhost:8080/#) in <cell line: 0>()
----> 1 status = prob.solve(CUOPT(msg=0))
      2 
      3 # Print results
      4 print("\nThe optimal value is", value(prob.objective))
      5 x_vals = np.array([x[i].varValue for i in range(n)])

1 frames
[/usr/local/lib/python3.12/dist-packages/pulp/apis/cuopt_api.py](https://localhost:8080/#) in actualSolve(self, lp, callback)
     58         def actualSolve(self, lp, callback=None):
     59             """Solve a well formulated lp problem"""
---> 60             raise PulpSolverError("CUOPT: Not available")
     61 
     62     else:

PulpSolverError: CUOPT: Not available

Metadata

Metadata

Assignees

Labels

awaiting responseThis expects a response from maintainer or contributor depending on who requested in last comment.questionFurther information is requested

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions