Skip to content

Commit b903988

Browse files
committed
First stab at nested build matrix
1 parent 05955b3 commit b903988

File tree

2 files changed

+211
-0
lines changed

2 files changed

+211
-0
lines changed

Diff for: .github/workflows/build.yml

+179
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,179 @@
1+
on:
2+
workflow_call:
3+
inputs:
4+
host_platform:
5+
required: true
6+
type: string
7+
cuda_version:
8+
type: string
9+
default: "12.8.0"
10+
11+
defaults:
12+
run:
13+
shell: bash --noprofile --norc -xeuo pipefail {0}
14+
15+
permissions:
16+
contents: read # This is required for actions/checkout
17+
18+
jobs:
19+
build:
20+
strategy:
21+
fail-fast: false
22+
matrix:
23+
python_version:
24+
- "3.9"
25+
- "3.13"
26+
name: py${{ matrix.python_version }}, ${{ inputs.cuda_version }}
27+
runs-on: ${{ (inputs.host_platform == 'linux-64' && 'linux-amd64-cpu8') ||
28+
(inputs.host_platform == 'linux-aarch64' && 'linux-arm64-cpu8') ||
29+
(inputs.host_platform == 'win-64' && 'windows-2019') }}
30+
steps:
31+
- name: Checkout ${{ github.event.repository.name }}
32+
uses: actions/checkout@v4
33+
with:
34+
fetch-depth: 0
35+
36+
- name: Set up Python
37+
if: ${{ startsWith(inputs.host_platform, 'linux') }}
38+
id: setup-python
39+
uses: actions/setup-python@v5
40+
with:
41+
python-version: "3.12"
42+
43+
- name: Set up MSVC
44+
if: ${{ startsWith(inputs.host_platform, 'win') }}
45+
uses: ilammy/msvc-dev-cmd@v1
46+
47+
- name: Set environment variables
48+
run: |
49+
PYTHON_VERSION_FORMATTED=$(echo '${{ matrix.python_version }}' | tr -d '.')
50+
if [[ "${{ inputs.host_platform }}" == linux* ]]; then
51+
CIBW_BUILD="cp${PYTHON_VERSION_FORMATTED}-manylinux*"
52+
REPO_DIR=$(pwd)
53+
elif [[ "${{ inputs.host_platform }}" == win* ]]; then
54+
CIBW_BUILD="cp${PYTHON_VERSION_FORMATTED}-win_amd64"
55+
PWD=$(pwd)
56+
REPO_DIR=$(cygpath -w $PWD)
57+
fi
58+
59+
echo "CUDA_BINDINGS_PARALLEL_LEVEL=$(nproc)" >> $GITHUB_ENV
60+
CUDA_CORE_ARTIFACT_BASENAME="cuda-core-python${PYTHON_VERSION_FORMATTED}-${{ inputs.host_platform }}"
61+
echo "CUDA_CORE_ARTIFACT_BASENAME=${CUDA_CORE_ARTIFACT_BASENAME}" >> $GITHUB_ENV
62+
echo "CUDA_CORE_ARTIFACT_NAME=${CUDA_CORE_ARTIFACT_BASENAME}-${{ github.sha }}" >> $GITHUB_ENV
63+
echo "CUDA_CORE_ARTIFACTS_DIR=$(realpath "$REPO_DIR/cuda_core/dist")" >> $GITHUB_ENV
64+
CUDA_BINDINGS_ARTIFACT_BASENAME="cuda-bindings-python${PYTHON_VERSION_FORMATTED}-cuda${{ inputs.cuda_version }}-${{ inputs.host_platform }}"
65+
echo "CUDA_BINDINGS_ARTIFACT_BASENAME=${CUDA_BINDINGS_ARTIFACT_BASENAME}" >> $GITHUB_ENV
66+
echo "CUDA_BINDINGS_ARTIFACT_NAME=${CUDA_BINDINGS_ARTIFACT_BASENAME}-${{ github.sha }}" >> $GITHUB_ENV
67+
echo "CUDA_BINDINGS_ARTIFACTS_DIR=$(realpath "$REPO_DIR/cuda_bindings/dist")" >> $GITHUB_ENV
68+
echo "CIBW_BUILD=${CIBW_BUILD}" >> $GITHUB_ENV
69+
70+
- name: Dump environment
71+
run: |
72+
env
73+
74+
- name: Build cuda.core wheel
75+
uses: pypa/[email protected]
76+
env:
77+
CIBW_BUILD: ${{ env.CIBW_BUILD }}
78+
CIBW_ARCHS_LINUX: "native"
79+
CIBW_BUILD_VERBOSITY: 1
80+
with:
81+
package-dir: ./cuda_core/
82+
output-dir: ${{ env.CUDA_CORE_ARTIFACTS_DIR }}
83+
84+
- name: List the cuda.core artifacts directory
85+
run: |
86+
if [[ "${{ inputs.host_platform }}" == win* ]]; then
87+
export CHOWN=chown
88+
else
89+
export CHOWN="sudo chown"
90+
fi
91+
$CHOWN -R $(whoami) ${{ env.CUDA_CORE_ARTIFACTS_DIR }}
92+
ls -lahR ${{ env.CUDA_CORE_ARTIFACTS_DIR }}
93+
94+
- name: Check cuda.core wheel
95+
run: |
96+
pip install twine
97+
twine check ${{ env.CUDA_CORE_ARTIFACTS_DIR }}/*.whl
98+
99+
- name: Upload cuda.core build artifacts
100+
uses: actions/upload-artifact@v4
101+
with:
102+
name: ${{ env.CUDA_CORE_ARTIFACT_NAME }}
103+
path: ${{ env.CUDA_CORE_ARTIFACTS_DIR }}/*.whl
104+
if-no-files-found: error
105+
106+
- name: Set up mini CTK
107+
uses: ./.github/actions/fetch_ctk
108+
continue-on-error: false
109+
with:
110+
host-platform: ${{ inputs.host_platform }}
111+
cuda-version: ${{ inputs.cuda_version }}
112+
113+
- name: Build cuda.bindings wheel
114+
uses: pypa/[email protected]
115+
env:
116+
CIBW_BUILD: ${{ env.CIBW_BUILD }}
117+
CIBW_ARCHS_LINUX: "native"
118+
CIBW_BUILD_VERBOSITY: 1
119+
# CIBW mounts the host filesystem under /host
120+
CIBW_ENVIRONMENT_LINUX: >
121+
CUDA_PATH=/host/${{ env.CUDA_PATH }}
122+
LIBRARY_PATH=/host/${{ env.CUDA_PATH }}/lib
123+
CUDA_BINDINGS_PARALLEL_LEVEL=${{ env.CUDA_BINDINGS_PARALLEL_LEVEL }}
124+
CIBW_ENVIRONMENT_WINDOWS: >
125+
CUDA_HOME="$(cygpath -w ${{ env.CUDA_PATH }})"
126+
LIB="${CUDA_HOME}\\lib\\x64;${LIB}"
127+
CUDA_BINDINGS_PARALLEL_LEVEL=${{ env.CUDA_BINDINGS_PARALLEL_LEVEL }}
128+
with:
129+
package-dir: ./cuda_bindings/
130+
output-dir: ${{ env.CUDA_BINDINGS_ARTIFACTS_DIR }}
131+
132+
- name: List the cuda.bindings artifacts directory
133+
run: |
134+
if [[ "${{ inputs.host_platform }}" == win* ]]; then
135+
export CHOWN=chown
136+
else
137+
export CHOWN="sudo chown"
138+
fi
139+
$CHOWN -R $(whoami) ${{ env.CUDA_BINDINGS_ARTIFACTS_DIR }}
140+
ls -lahR ${{ env.CUDA_BINDINGS_ARTIFACTS_DIR }}
141+
142+
- name: Check cuda.bindings wheel
143+
run: |
144+
twine check ${{ env.CUDA_BINDINGS_ARTIFACTS_DIR }}/*.whl
145+
146+
- name: Upload cuda.bindings build artifacts
147+
uses: actions/upload-artifact@v4
148+
with:
149+
name: ${{ env.CUDA_BINDINGS_ARTIFACT_NAME }}
150+
path: ${{ env.CUDA_BINDINGS_ARTIFACTS_DIR }}/*.whl
151+
if-no-files-found: error
152+
153+
# We only need/want a single pure python wheel, pick linux-64 index 0.
154+
- name: Build and check cuda-python wheel
155+
if: ${{ strategy.job-index == 0 && inputs.host_platform == 'linux-64' }}
156+
run: |
157+
pushd cuda_python
158+
pip wheel -v --no-deps .
159+
twine check *.whl
160+
popd
161+
162+
- name: List the cuda-python artifacts directory
163+
if: ${{ strategy.job-index == 0 && inputs.host_platform == 'linux-64' }}
164+
run: |
165+
if [[ "${{ inputs.host_platform }}" == win* ]]; then
166+
export CHOWN=chown
167+
else
168+
export CHOWN="sudo chown"
169+
fi
170+
$CHOWN -R $(whoami) cuda_python/*.whl
171+
ls -lahR cuda_python
172+
173+
- name: Upload cuda-python build artifacts
174+
if: ${{ strategy.job-index == 0 && inputs.host_platform == 'linux-64' }}
175+
uses: actions/upload-artifact@v4
176+
with:
177+
name: cuda-python-wheel
178+
path: cuda_python/*.whl
179+
if-no-files-found: error

Diff for: .github/workflows/ci.yml

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: "CI"
2+
3+
concurrency:
4+
group: ${{ github.workflow }}-${{
5+
github.ref_name == 'main' && format('ci-main-build-test-{0}', github.run_id) ||
6+
format('ci-pr-build-test-on-{0}-against-branch-{1}', github.event_name, github.ref_name)
7+
}}
8+
cancel-in-progress: true
9+
10+
on:
11+
push:
12+
branches:
13+
- "pull-request/[0-9]+"
14+
- "main"
15+
16+
jobs:
17+
build:
18+
strategy:
19+
fail-fast: false
20+
matrix:
21+
host_platform:
22+
- linux-64
23+
- linux-aarch64
24+
- win-64
25+
name: Build ${{ matrix.host_platform }}
26+
if: ${{ github.repository_owner == 'nvidia' }}
27+
secrets: inherit
28+
uses:
29+
./.github/workflows/build.yml
30+
with:
31+
host_platform: ${{ matrix.host_platform }}
32+
cuda_version: "12.8.0"

0 commit comments

Comments
 (0)