Pyomo solves over NVIDIA Cuda

1.5k views Asked by At

I would like to know if there is a way to solve an Pyomo Concrete Model over a GPU with using the NVIDIA Cuda.

I checked out https://developer.nvidia.com/how-to-cuda-python, and saw a video about it. And It turns out if your input parameters are recognizable by numpy, such as; np.float32, np.float64, etc... it is possible to compile/solve over a GPU,

We are using a function to create all model and solve it with:

optim = SolverFactory('glpk')
optim = setup_solver(optim, logfile=log_filename)
result = optim.solve(prob, tee=True)

In this case our input to solve function would be prob(a pyomo concrete model). Is there a way to solve it over a GPU instead of a CPU?

Thank You!

2

There are 2 answers

0
sascha On BEST ANSWER

No you can't.

In fairness one could write a book on how misguided this idea is, but let's make it simple and just point out some basic stuff (and ignore a lot of other details):

  • GPUs are working differently and use other instructions than cpus
  • GPUs will need some driver/compiler to make some code runnable
  • While there might be some reduced high-level languages to generate GPU-compatible code using common code, this is highly experimental, limited and of course: way worse than hand-tuned code
  • GPUs are not faster for everything (more strict: they are only faster for some things and it's hard to achieve that)
    • And you need to pay for latency and data-copies too
    • GPUs also have less RAM in general
  • Linear-Programming and Integer-Programming are solved by highly complex algorithms
    • Theory says: Simplex-algorithm (which is used by GLPK) is very hard to parallelize (ouch; bad for GPU)
    • Theory says: IPM-methods (can solve LPs too) are easy to parallelize
    • There is no known competitive GPU-based Simplex-solver! (i actually don't know any Simplex-implementation for GPUs and can think of many reasons)
    • There are some specialized IPM-based methods for GPUs, not interfaced with pyomo; and there is no commercial GPU-based solver
      • IPMs are very bad for Integer-Programming
  • GLPK, your solver, has nothing to do with python, besides beeing called by python (so the whole python-cuda link us useless)
0
thaspius On

It isn't pyomo, but it is a solver that can leverage CUDA, check out NVIDIA's cuopt. It is relatively new to the scene but has been breaking records this year

https://github.com/NVIDIA/cuOpt-Resources

https://blogs.nvidia.com/blog/2023/03/21/cuopt-world-record-route/