Skip to content

Commit 094acea

Browse files
authored
Trying osqp-cu12 wheels (#171)
* cu12 extra that builds osqp-cu12 wheels.
1 parent 6e8b452 commit 094acea

File tree

10 files changed

+84
-135
lines changed

10 files changed

+84
-135
lines changed

.github/workflows/build_cuda.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Build CUDA
1+
name: Build CUDA Linux
22

33
on:
44
push:

.github/workflows/build_cuda_windows.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Build CUDA
1+
name: Build CUDA Windows
22

33
on:
44
push:
@@ -11,8 +11,8 @@ on:
1111
- master
1212

1313
env:
14-
CUDATOOLKIT_URL: https://developer.download.nvidia.com/compute/cuda/12.5.1/local_installers/cuda_12.5.1_555.85_windows.exe
15-
CUDATOOLKIT_COMPONENTS: nvcc_12.5 cudart_12.5 cublas_dev_12.5 curand_dev_12.5 cusparse_dev_12.5 thrust_12.5 visual_studio_integration_12.5
14+
CUDATOOLKIT_URL: https://developer.download.nvidia.com/compute/cuda/12.6.3/local_installers/cuda_12.6.3_561.17_windows.exe
15+
CUDATOOLKIT_COMPONENTS: nvcc_12.6 cudart_12.6 cublas_dev_12.6 curand_dev_12.6 cusparse_dev_12.6 thrust_12.6 visual_studio_integration_12.6
1616

1717
jobs:
1818
build_wheels:
@@ -41,7 +41,7 @@ jobs:
4141
uses: actions/cache@v4
4242
with:
4343
path: C:\Program Files (x86)\Intel\oneAPI\
44-
key: install-${{ env.WINDOWS_BASEKIT_URL }}-${{ env.WINDOWS_BASEKIT_COMPONENTS }}
44+
key: install-${{ env.CUDATOOLKIT_URL }}-${{ env.CUDATOOLKIT_COMPONENTS }}
4545

4646
- name: install cuda
4747
if: steps.cache-install.outputs.cache-hit != 'true'

.github/workflows/build_mkl.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Build MKL
1+
name: Build MKL Mac/Linux
22

33
on:
44
push:

.github/workflows/build_mkl_windows.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Build MKL
1+
name: Build MKL Windows
22

33
on:
44
push:

.github/workflows/release.yml

Lines changed: 0 additions & 121 deletions
This file was deleted.

backend/cuda/cibuildwheel.toml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@ repair-wheel-command = ""
77

88
[tool.cibuildwheel.linux]
99
before-all = [
10-
"yum-config-manager --add-repo https://developer.download.nvidia.com/compute/cuda/repos/rhel7/x86_64/cuda-rhel7.repo",
11-
"yum install -y cuda-toolkit-12-4"
10+
"yum-config-manager --add-repo https://developer.download.nvidia.com/compute/cuda/repos/rhel9/x86_64/cuda-rhel9.repo",
11+
"yum search cuda-toolkit*",
12+
"yum install -y cuda-toolkit-12-6"
1213
]
13-
environment = { CMAKE_CUDA_COMPILER = "/usr/local/cuda-12.4/bin/nvcc" }
14+
environment = { CMAKE_CUDA_COMPILER = "/usr/local/cuda-12.6/bin/nvcc" }
1415

1516
[tool.cibuildwheel.windows]
16-
environment = { CMAKE_CUDA_COMPILER = "C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.5/bin/nvcc.exe", CUDA_TOOLKIT_ROOT_DIR = "C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.5", CMAKE_GENERATOR_TOOLSET = "cuda=C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.5" }
17+
environment = { CMAKE_CUDA_COMPILER = "C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.6/bin/nvcc.exe", CUDA_TOOLKIT_ROOT_DIR = "C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.6", CMAKE_GENERATOR_TOOLSET = "cuda=C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.6" }

backend/cuda/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ requires = ["scikit-build-core", "pybind11"]
33
build-backend = "scikit_build_core.build"
44

55
[project]
6-
name = "osqp-cuda"
6+
name = "osqp-cu12"
77
dynamic = ["version"]
88
description = "OSQP: The Operator Splitting QP Solver"
99
requires-python = ">=3.8"

examples/update_matrices.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import osqp
2+
import numpy as np
3+
from scipy import sparse
4+
5+
if __name__ == '__main__':
6+
# Define problem data
7+
P = sparse.csc_matrix([[4, 1], [1, 2]])
8+
q = np.array([1, 1])
9+
A = sparse.csc_matrix([[1, 1], [1, 0], [0, 1]])
10+
l = np.array([1, 0, 0])
11+
u = np.array([1, 0.7, 0.7])
12+
13+
# Create an OSQP object
14+
prob = osqp.OSQP()
15+
16+
# Setup workspace
17+
prob.setup(P, q, A, l, u)
18+
19+
# Solve problem
20+
res = prob.solve()
21+
22+
# Update problem
23+
# IMPORTANT: The sparsity structure of P/A should remain the same,
24+
# so we only update Px and Ax
25+
# (i.e. the actual data values at indices with nonzero values)
26+
# NB: Update only upper triangular part of P
27+
P_new = sparse.csc_matrix([[5, 1.5], [1.5, 1]])
28+
A_new = sparse.csc_matrix([[1.2, 1.1], [1.5, 0], [0, 0.8]])
29+
prob.update(Px=sparse.triu(P_new).data, Ax=A_new.data)
30+
31+
# Solve updated problem
32+
res = prob.solve()
33+
34+
print('Status:', res.info.status)
35+
print('Objective value:', res.info.obj_val)
36+
print('Optimal solution x:', res.x)

examples/update_vectors.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import osqp
2+
import numpy as np
3+
from scipy import sparse
4+
5+
if __name__ == '__main__':
6+
# Define problem data
7+
P = sparse.csc_matrix([[4, 1], [1, 2]])
8+
q = np.array([1, 1])
9+
A = sparse.csc_matrix([[1, 1], [1, 0], [0, 1]])
10+
l = np.array([1, 0, 0])
11+
u = np.array([1, 0.7, 0.7])
12+
13+
# Create an OSQP object
14+
prob = osqp.OSQP()
15+
16+
# Setup workspace
17+
prob.setup(P, q, A, l, u)
18+
19+
# Solve problem
20+
res = prob.solve()
21+
22+
# Update problem
23+
q_new = np.array([2, 3])
24+
l_new = np.array([2, -1, -1])
25+
u_new = np.array([2, 2.5, 2.5])
26+
prob.update(q=q_new, l=l_new, u=u_new)
27+
28+
# Solve updated problem
29+
res = prob.solve()
30+
31+
print('Status:', res.info.status)
32+
print('Objective value:', res.info.obj_val)
33+
print('Optimal solution x:', res.x)

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ dev = [
4343
# ref: https://github.com/scipy/scipy/issues/20027
4444
"scipy!=1.12.0",
4545
]
46-
cuda = [
47-
"osqp-cuda",
46+
cu12 = [
47+
"osqp-cu12",
4848
]
4949

5050
[dependency-groups]

0 commit comments

Comments
 (0)