Skip to content

Commit fa325b2

Browse files
authored
Merge pull request #23 from shaia/fix/cuda-manylinux-wheel
fix: Build Linux CUDA wheels in NVIDIA manylinux container
2 parents 61a4b02 + 0b6ed10 commit fa325b2

File tree

1 file changed

+38
-34
lines changed

1 file changed

+38
-34
lines changed

.github/workflows/build-wheels.yml

Lines changed: 38 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -98,36 +98,13 @@ jobs:
9898
dir cfd\build\lib\Release
9999
100100
# ============ CUDA builds ============
101-
# Using CUDA 12.4 for compatibility with latest compilers:
102-
# - Windows: MSVC 14.44 requires CUDA 12.4+
103-
# - Linux: GCC 13 requires CUDA 12.4+ (or use GCC 12 with older CUDA)
104-
- name: Install CUDA Toolkit (Linux)
105-
if: runner.os == 'Linux' && matrix.variant == 'cuda'
106-
run: |
107-
# Install minimal CUDA 12.4 packages (avoid nsight tools with broken dependencies)
108-
wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/cuda-keyring_1.1-1_all.deb
109-
sudo dpkg -i cuda-keyring_1.1-1_all.deb
110-
sudo apt-get update
111-
# Install only compiler and runtime libraries (no profiling tools)
112-
sudo apt-get install -y cuda-nvcc-12-4 cuda-cudart-dev-12-4 cuda-nvrtc-dev-12-4 libcublas-dev-12-4 libcusparse-dev-12-4
113-
echo "/usr/local/cuda-12.4/bin" >> $GITHUB_PATH
114-
echo "CUDA_PATH=/usr/local/cuda-12.4" >> $GITHUB_ENV
115-
echo "LD_LIBRARY_PATH=/usr/local/cuda-12.4/lib64:$LD_LIBRARY_PATH" >> $GITHUB_ENV
101+
# Note: Linux CUDA build is done inside NVIDIA manylinux container (see Build wheel step)
116102

117103
- name: Build CFD library (Linux with CUDA)
118104
if: runner.os == 'Linux' && matrix.variant == 'cuda'
119105
run: |
120-
# Build with CUDA for Turing+ architectures (RTX 20 series onwards)
121-
# 75=Turing, 80=Ampere, 86=Ampere, 89=Ada, 90=Hopper
122-
cmake -S cfd -B cfd/build \
123-
-DCMAKE_BUILD_TYPE=Release \
124-
-DBUILD_SHARED_LIBS=OFF \
125-
-DCMAKE_POSITION_INDEPENDENT_CODE=ON \
126-
-DCFD_ENABLE_CUDA=ON \
127-
-DCFD_CUDA_ARCHITECTURES="75;80;86;89;90"
128-
cmake --build cfd/build --config Release
129-
echo "=== CFD library built with CUDA ==="
130-
ls -la cfd/build/lib/
106+
echo "Linux CUDA build will be done inside NVIDIA manylinux container"
107+
echo "Skipping host build to ensure manylinux compatibility"
131108
132109
- name: Install CUDA Toolkit (Windows)
133110
if: runner.os == 'Windows' && matrix.variant == 'cuda'
@@ -187,15 +164,42 @@ jobs:
187164
188165
- name: Build wheel (Linux - CUDA)
189166
if: runner.os == 'Linux' && matrix.variant == 'cuda'
190-
env:
191-
CFD_ROOT: ${{ github.workspace }}/cfd
192-
CFD_STATIC_LINK: "ON"
193-
CFD_USE_STABLE_ABI: "ON"
194167
run: |
195-
# CUDA wheels use host build (CUDA not available in manylinux container)
196-
# These wheels require matching CUDA runtime on user system
197-
pip wheel . --no-deps --wheel-dir dist/
198-
echo "=== Wheel built (CUDA - linux native) ==="
168+
# Build inside NVIDIA's manylinux-compatible CUDA container
169+
# Rocky Linux 8 is manylinux_2_28 compatible
170+
docker run --rm \
171+
-v "${{ github.workspace }}:/workspace" \
172+
-w /workspace \
173+
-e CFD_STATIC_LINK=ON \
174+
-e CFD_USE_STABLE_ABI=ON \
175+
nvidia/cuda:12.4.0-devel-rockylinux8 \
176+
bash -c "
177+
set -e
178+
# Install build tools (git for CMake FetchContent)
179+
dnf install -y cmake git python3.11 python3.11-pip python3.11-devel
180+
# Install patchelf via pip (EPEL version is too old for auditwheel)
181+
python3.11 -m pip install patchelf
182+
183+
# Build CFD C library with CUDA
184+
# 75=Turing, 80=Ampere, 86=Ampere, 89=Ada, 90=Hopper
185+
cmake -S cfd -B cfd/build \
186+
-DCMAKE_BUILD_TYPE=Release \
187+
-DBUILD_SHARED_LIBS=OFF \
188+
-DCMAKE_POSITION_INDEPENDENT_CODE=ON \
189+
-DCFD_ENABLE_CUDA=ON \
190+
-DCFD_CUDA_ARCHITECTURES='75;80;86;89;90'
191+
cmake --build cfd/build --config Release
192+
193+
# Build Python wheel
194+
export CFD_ROOT=/workspace/cfd
195+
python3.11 -m pip install scikit-build-core setuptools-scm
196+
python3.11 -m pip wheel . --no-deps --wheel-dir dist_raw/
197+
198+
# Repair wheel for manylinux compatibility
199+
python3.11 -m pip install auditwheel
200+
auditwheel repair dist_raw/*.whl --plat manylinux_2_28_x86_64 -w dist/
201+
"
202+
echo "=== Wheel built (CUDA manylinux) ==="
199203
ls -la dist/
200204
201205
- name: Build wheel (macOS)

0 commit comments

Comments
 (0)