Skip to content

Commit 94aa69e

Browse files
authored
Build wrapper for cuda backend (#3)
1 parent 2937b8e commit 94aa69e

12 files changed

Lines changed: 106 additions & 18 deletions

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ jobs:
4141
strategy:
4242
fail-fast: false
4343
matrix:
44-
os: [ubuntu-latest, macos-13, macos-latest, windows-latest]
44+
os: [ubuntu-latest, macos-15-intel, macos-latest, windows-latest]
4545

4646
steps:
4747
- uses: actions/checkout@v4

.github/workflows/unit_tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
fail-fast: false
2929

3030
matrix:
31-
os: [ubuntu-latest, macos-13, windows-latest]
31+
os: [ubuntu-latest, macos-latest, windows-latest]
3232

3333
# Steps represent a sequence of tasks that will be executed as part of the job
3434
steps:

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,6 @@
22
build/
33
.vscode/
44
__pycache__/
5-
qoco_custom*/
5+
qoco_custom*/
6+
src/bindings.cpp
7+
dist/

CMakeLists.txt

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,22 @@ include(FetchContent)
2323
FetchContent_Declare(
2424
qoco
2525
GIT_REPOSITORY https://github.com/qoco-org/qoco.git
26-
GIT_TAG bbab0db3899f19331c5c8e9d31d68bbbb68704ae
26+
GIT_TAG d40cb8170b0e967be38ad0e1b134d9c51f5d636e
2727
)
2828

2929
list(POP_BACK CMAKE_MESSAGE_INDENT)
3030
FetchContent_MakeAvailable(qoco)
3131

32-
pybind11_add_module(qoco_ext src/bindings.cpp)
33-
target_include_directories(qoco_ext INTERFACE ${qoco_SOURCE_DIR}/include)
32+
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/bindings.cpp.in
33+
${CMAKE_CURRENT_SOURCE_DIR}/src/bindings.cpp)
34+
pybind11_add_module(${QOCO_EXT_MODULE_NAME} src/bindings.cpp)
35+
target_include_directories(${QOCO_EXT_MODULE_NAME} INTERFACE ${qoco_SOURCE_DIR}/include)
36+
install(TARGETS ${QOCO_EXT_MODULE_NAME} DESTINATION . COMPONENT python)
37+
38+
if(${QOCO_ALGEBRA_BACKEND} STREQUAL "builtin")
3439
target_link_libraries(qoco_ext PUBLIC pybind11::module qocostatic)
35-
install(TARGETS qoco_ext DESTINATION . COMPONENT python)
40+
elseif(${QOCO_ALGEBRA_BACKEND} STREQUAL "cuda")
41+
enable_language(CUDA)
42+
find_package(CUDA)
43+
target_link_libraries(qoco_cuda PUBLIC pybind11::module qocostatic)
44+
endif()

Dockerfile.cuda-manylinux

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Base manylinux image with Python interpreters
2+
FROM quay.io/pypa/manylinux_2_28_x86_64:2025.11.09-2
3+
4+
# Install prerequisites
5+
RUN yum install -y wget tar bzip2 xz gzip make gcc gcc-c++ git
6+
7+
# Install CUDA Toolkit 13.1 and cuDSS 0.7.1
8+
RUN wget https://developer.download.nvidia.com/compute/cuda/13.0.0/local_installers/cuda_13.0.0_580.65.06_linux.run && \
9+
sh cuda_13.0.0_580.65.06_linux.run --silent --toolkit && \
10+
rm cuda_13.0.0_580.65.06_linux.run && \
11+
curl -O https://developer.download.nvidia.com/compute/cudss/0.7.1/local_installers/cudss-local-repo-rhel10-0.7.1-0.7.1-1.x86_64.rpm && \
12+
rpm -i cudss-local-repo-rhel10-0.7.1-0.7.1-1.x86_64.rpm && \
13+
dnf clean all && \
14+
dnf -y install cudss
15+
16+
# Set CUDA environment variables
17+
ENV PATH=/usr/local/cuda/bin:$PATH
18+
ENV LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH
19+
ENV CUDAToolkit_ROOT=/usr/local/cuda/bin

backend/cuda/cibuildwheel.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[tool.cibuildwheel.linux]
2+
skip = ["*-musllinux*"]
3+
manylinux-x86_64-image = "mycuda-manylinux:latest"
4+
environment = { CUDAToolkit_ROOT = "/usr/local/cuda/bin" }

backend/cuda/pyproject.toml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
[build-system]
2+
requires = ["scikit-build-core", "pybind11"]
3+
build-backend = "scikit_build_core.build"
4+
5+
[project]
6+
name = "qoco-cuda"
7+
version = "0.1.0"
8+
description = "QOCO: Quadratic Objective Conic Optimizer"
9+
requires-python = ">=3.8"
10+
authors = [{ name = "Govind M. Chari", email = "[email protected]" }]
11+
dependencies = ["numpy>=1.7", "scipy>=0.13.2", "setuptools", "qoco>=0.2.0"]
12+
13+
[tool.scikit-build]
14+
install.components = ["python"]
15+
16+
[tool.scikit-build.cmake.define]
17+
QOCO_ALGEBRA_BACKEND = "cuda"
18+
QOCO_EXT_MODULE_NAME = "qoco_cuda"
19+
20+
[project.urls]
21+
Homepage = "https://github.com/qoco-org/qoco"
22+
Issues = "https://github.com/qoco-org/qoco/issues"

build_cuda_wheels.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
cp backend/cuda/pyproject.toml .
2+
docker build -f Dockerfile.cuda-manylinux -t mycuda-manylinux:latest .
3+
cibuildwheel --platform linux --output-dir dist --config-file backend/cuda/cibuildwheel.toml

pyproject.toml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,20 @@ description = "QOCO: Quadratic Objective Conic Optimizer"
99
readme = "README.md"
1010
requires-python = ">=3.8"
1111
authors = [{ name = "Govind M. Chari", email = "[email protected]" }]
12-
dependencies = ["jinja2", "numpy>=1.7", "qdldl", "scipy>=0.13.2", "setuptools"]
12+
dependencies = ["numpy>=1.7", "scipy>=0.13.2", "setuptools"]
13+
[project.optional-dependencies]
14+
cuda = [
15+
"qoco-cuda",
16+
]
1317

1418
[tool.scikit-build]
1519
install.components = ["python"]
1620
wheel.install-dir = "qoco"
1721

22+
[tool.scikit-build.cmake.define]
23+
QOCO_ALGEBRA_BACKEND = "builtin"
24+
QOCO_EXT_MODULE_NAME = "qoco_ext"
25+
1826
[project.urls]
1927
Homepage = "https://github.com/qoco-org/qoco"
2028
Issues = "https://github.com/qoco-org/qoco/issues"

requirements.txt

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

0 commit comments

Comments
 (0)