|
| 1 | +======================== |
| 2 | +GPU-Accelerated Solving |
| 3 | +======================== |
| 4 | + |
| 5 | +.. warning:: |
| 6 | + |
| 7 | + This feature is **experimental** and not tested in CI due to the lack of GPU-enabled machines. Use with caution and please report any issues. |
| 8 | + |
| 9 | +Linopy supports GPU-accelerated optimization solvers that can significantly speed up solving large-scale linear programming problems by leveraging the parallel processing capabilities of modern GPUs. |
| 10 | + |
| 11 | +Supported GPU Solvers |
| 12 | +===================== |
| 13 | + |
| 14 | +cuPDLPx |
| 15 | +------- |
| 16 | + |
| 17 | +`cuPDLPx <https://github.com/MIT-Lu-Lab/cuPDLPx>`_ is an open-source, GPU-accelerated first-order solver developed by MIT. It implements a Primal-Dual hybrid gradient (PDHG) method optimized for GPUs. |
| 18 | + |
| 19 | +To install it, you have to have the `CUDA Toolkit <https://developer.nvidia.com/cuda/toolkit>`_ installed requiring NVIDIA GPUs on your computer. Then, install with |
| 20 | + |
| 21 | +.. code-block:: bash |
| 22 | +
|
| 23 | + # Install CUDA Toolkit first (if not already installed) |
| 24 | + # Follow instructions at: https://developer.nvidia.com/cuda-downloads |
| 25 | +
|
| 26 | + # Install cuPDLPx |
| 27 | + pip install cupdlpx>=0.1.2 |
| 28 | +
|
| 29 | +**Features:** |
| 30 | + |
| 31 | +- GPU-accelerated solving for large-scale linear programs |
| 32 | +- Open source (Apache 2.0 license) |
| 33 | +- Direct API integration with linopy |
| 34 | +- Designed for problems with millions of variables and constraints |
| 35 | + |
| 36 | +**Limitations:** |
| 37 | + |
| 38 | +- Currently supports only Linear Programming (LP) |
| 39 | +- Does not support Mixed-Integer Programming (MIP) or Quadratic Programming (QP) |
| 40 | +- Lower numerical precision compared to CPU solvers (typical tolerance: ~2.5e-4 vs 1e-5) |
| 41 | +- File I/O not currently supported through cuPDLPx API |
| 42 | + |
| 43 | +For a complete list of cuPDLPx parameters, see the `cuPDLPx documentation <https://github.com/MIT-Lu-Lab/cuPDLPx/tree/main/python#parameters>`_. |
| 44 | + |
| 45 | +Xpress with GPU Acceleration |
| 46 | +----------------------------- |
| 47 | + |
| 48 | +`FICO Xpress <https://www.fico.com/en/fico-xpress-trial-and-licensing-options>`_ version 9.8 and later includes GPU acceleration support for certain operations. |
| 49 | + |
| 50 | +**Features:** |
| 51 | + |
| 52 | +- Commercial solver with GPU support |
| 53 | +- Supports LP, MIP, and QP |
| 54 | +- Full-precision solving |
| 55 | + |
| 56 | +Prerequisites |
| 57 | +============= |
| 58 | + |
| 59 | +Hardware Requirements |
| 60 | +--------------------- |
| 61 | + |
| 62 | +GPU solvers require: |
| 63 | + |
| 64 | +- NVIDIA GPU with CUDA support (compute capability 6.0 or higher recommended) |
| 65 | +- Sufficient GPU memory for your problem size (varies by problem) |
| 66 | +- PCIe 3.0 or higher for optimal data transfer |
| 67 | + |
| 68 | +Software Requirements |
| 69 | +--------------------- |
| 70 | + |
| 71 | +1. **CUDA Toolkit**: Most GPU solvers require CUDA 11.0 or later |
| 72 | +2. **Compatible GPU drivers**: Match your CUDA version |
| 73 | + |
| 74 | +Verifying Installation |
| 75 | +====================== |
| 76 | + |
| 77 | +To verify that the GPU solvers are properly installed and detected: |
| 78 | + |
| 79 | +.. code-block:: python |
| 80 | +
|
| 81 | + import linopy |
| 82 | + from linopy.solver_capabilities import ( |
| 83 | + SolverFeature, |
| 84 | + get_available_solvers_with_feature, |
| 85 | + ) |
| 86 | +
|
| 87 | + # Check available solvers |
| 88 | + print("All available solvers:", linopy.available_solvers) |
| 89 | +
|
| 90 | + # Check GPU-accelerated solvers |
| 91 | + gpu_solvers = get_available_solvers_with_feature( |
| 92 | + SolverFeature.GPU_ACCELERATION, linopy.available_solvers |
| 93 | + ) |
| 94 | + print("GPU solvers:", gpu_solvers) |
| 95 | +
|
| 96 | +
|
| 97 | +By default, GPU tests are skipped in the test suite to support CI environments without GPUs. To run GPU tests locally: |
| 98 | + |
| 99 | +.. code-block:: bash |
| 100 | +
|
| 101 | + # Run all tests including GPU tests |
| 102 | + pytest --run-gpu |
| 103 | +
|
| 104 | + # Run only GPU tests |
| 105 | + pytest -m gpu --run-gpu |
| 106 | +
|
| 107 | + # Run specific GPU test |
| 108 | + pytest test/test_optimization.py -k cupdlpx --run-gpu |
| 109 | +
|
| 110 | +
|
| 111 | +References |
| 112 | +========== |
| 113 | + |
| 114 | +- `cuPDLPx Repository <https://github.com/MIT-Lu-Lab/cuPDLPx>`_ |
| 115 | +- `cuPDLPx Python Documentation <https://github.com/MIT-Lu-Lab/cuPDLPx/tree/main/python>`_ |
| 116 | +- `CUDA Installation Guide <https://docs.nvidia.com/cuda/cuda-installation-guide-linux/index.html>`_ |
| 117 | +- `NVIDIA GPU Computing Resources <https://developer.nvidia.com/gpu-computing>`_ |
0 commit comments