Search code examples
pythonnumpycudagpupyomo

Pyomo solves over NVIDIA Cuda


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!


Solution

  • 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)