Skip to content

Commit cbba303

Browse files
committed
add cuda
1 parent 74846bc commit cbba303

2 files changed

Lines changed: 52 additions & 21 deletions

File tree

.github/workflows/linux-cuda.yml

Lines changed: 33 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -38,22 +38,44 @@ jobs:
3838
CIBW_BUILD: "cp311-*linux*"
3939
CIBW_MANYLINUX_X86_64_IMAGE: "quay.io/pypa/manylinux_2_28_x86_64:latest"
4040
CIBW_BEFORE_BUILD: |
41-
# Install CUDA toolkit
42-
# For manylinux containers, you may need to install CUDA manually
43-
# Option 1: Use system package manager (if available)
44-
yum install -y cuda-toolkit-12-4 2>/dev/null || \
45-
apt-get update && apt-get install -y nvidia-cuda-toolkit 2>/dev/null || \
46-
echo "CUDA toolkit installation skipped - may need manual setup"
41+
# Install CUDA toolkit for manylinux containers
42+
# Note: CUDA installation in manylinux containers is complex
43+
# Consider using a CUDA-enabled base image or pre-installing CUDA
44+
45+
echo "Setting up CUDA environment..."
46+
47+
# Try to find existing CUDA installation
48+
if [ -d "/usr/local/cuda" ]; then
49+
export CUDA_HOME=/usr/local/cuda
50+
elif [ -d "/opt/cuda" ]; then
51+
export CUDA_HOME=/opt/cuda
52+
else
53+
# Try to install CUDA via package manager
54+
if command -v yum &> /dev/null; then
55+
# For RHEL/CentOS/AlmaLinux - try to add CUDA repo and install
56+
echo "Attempting to install CUDA via yum..."
57+
yum install -y wget || true
58+
# Note: This may require manual setup of CUDA repository
59+
# For production, consider using a CUDA-enabled Docker image
60+
fi
61+
62+
# Default CUDA_HOME if installation fails
63+
export CUDA_HOME=/usr/local/cuda
64+
mkdir -p $CUDA_HOME/bin $CUDA_HOME/lib64 || true
65+
fi
4766
4867
# Set CUDA environment variables
49-
export CUDA_HOME=/usr/local/cuda
50-
export PATH=$PATH:/usr/local/cuda/bin
51-
export LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH
68+
export PATH=$PATH:$CUDA_HOME/bin
69+
export LD_LIBRARY_PATH=$CUDA_HOME/lib64:$LD_LIBRARY_PATH
5270
5371
# Verify CUDA if available
5472
if command -v nvcc &> /dev/null; then
55-
echo "CUDA compiler version:"
56-
nvcc --version || true
73+
echo "CUDA compiler found:"
74+
nvcc --version
75+
else
76+
echo "Warning: CUDA compiler (nvcc) not found"
77+
echo "CUDA_HOME: $CUDA_HOME"
78+
echo "You may need to install CUDA manually or use a CUDA-enabled base image"
5779
fi
5880
CIBW_ENVIRONMENT: "CUDA_HOME=/usr/local/cuda PATH=$PATH:/usr/local/cuda/bin LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH"
5981
CIBW_CONFIG_SETTINGS: "wheel.build-tag=${{ github.run_number }}"

linux-cuda/pyproject.toml

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,33 @@
1-
# CUDA-specific build configuration for Linux
2-
# This file is used when building with cibuildwheel for CUDA-enabled wheels
3-
# The actual CUDA installation and environment setup is handled in the GitHub Actions workflow
1+
[build-system]
2+
requires = ["scikit-build-core>=0.9.0", "pybind11>=2.11.0", "setuptools-scm"]
3+
build-backend = "scikit_build_core.build"
4+
5+
[project]
6+
name = "hello-cuda"
7+
dynamic = ["version"]
8+
description = "CUDA-enabled pybind11 hello world module built with CMake."
9+
readme = "README.md"
10+
requires-python = ">=3.11,<3.12"
11+
license = { text = "MIT" }
12+
authors = [{ name = "Example Author" }]
13+
classifiers = [
14+
"Programming Language :: Python :: 3",
15+
"Programming Language :: C++",
16+
"Programming Language :: CUDA",
17+
"License :: OSI Approved :: MIT License",
18+
]
419

520
[tool.scikit-build]
21+
metadata.version.provider = "scikit_build_core.metadata.setuptools_scm"
622
minimum-version = "0.9"
723
cmake.version = ">=3.26"
824
build-dir = "build/{wheel_tag}"
925
wheel.packages = []
1026

1127
# CMake configuration for CUDA
1228
# These args will be passed to CMake during the build
13-
# Note: CUDA language support should be enabled in your CMakeLists.txt
1429
cmake.args = [
1530
"-DCMAKE_CUDA_ARCHITECTURES=75;80;86;89;90", # Common GPU architectures (adjust as needed)
1631
"-DENABLE_CUDA=ON",
1732
"-DCMAKE_CUDA_COMPILER=nvcc",
1833
]
19-
20-
# Example CMakeLists.txt additions needed for CUDA:
21-
# cmake_minimum_required(VERSION 3.26)
22-
# enable_language(CUDA)
23-
# find_package(CUDA REQUIRED)
24-
# set(CMAKE_CUDA_STANDARD 17)

0 commit comments

Comments
 (0)