Skip to content

Commit 3fff795

Browse files
committed
Get the build CI working with python caching
1 parent 05955b3 commit 3fff795

File tree

2 files changed

+217
-0
lines changed

2 files changed

+217
-0
lines changed

.github/workflows/build.yml

+185
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,185 @@
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: Setup proxy cache
37+
uses: nv-gha-runners/setup-proxy-cache@main
38+
continue-on-error: true
39+
# Skip the cache on Windows nodes outside of our org.
40+
if: ${{ inputs.host-platform != 'win-64' }}
41+
42+
- name: Set up Python
43+
if: ${{ startsWith(inputs.host-platform, 'linux') }}
44+
id: setup-python
45+
uses: actions/setup-python@v5
46+
with:
47+
python-version: "3.12"
48+
49+
- name: Set up MSVC
50+
if: ${{ startsWith(inputs.host-platform, 'win') }}
51+
uses: ilammy/msvc-dev-cmd@v1
52+
53+
- name: Set environment variables
54+
run: |
55+
PYTHON_VERSION_FORMATTED=$(echo '${{ matrix.python-version }}' | tr -d '.')
56+
if [[ "${{ inputs.host-platform }}" == linux* ]]; then
57+
CIBW_BUILD="cp${PYTHON_VERSION_FORMATTED}-manylinux*"
58+
REPO_DIR=$(pwd)
59+
elif [[ "${{ inputs.host-platform }}" == win* ]]; then
60+
CIBW_BUILD="cp${PYTHON_VERSION_FORMATTED}-win_amd64"
61+
PWD=$(pwd)
62+
REPO_DIR=$(cygpath -w $PWD)
63+
fi
64+
65+
echo "CUDA_BINDINGS_PARALLEL_LEVEL=$(nproc)" >> $GITHUB_ENV
66+
CUDA_CORE_ARTIFACT_BASENAME="cuda-core-python${PYTHON_VERSION_FORMATTED}-${{ inputs.host-platform }}"
67+
echo "CUDA_CORE_ARTIFACT_BASENAME=${CUDA_CORE_ARTIFACT_BASENAME}" >> $GITHUB_ENV
68+
echo "CUDA_CORE_ARTIFACT_NAME=${CUDA_CORE_ARTIFACT_BASENAME}-${{ github.sha }}" >> $GITHUB_ENV
69+
echo "CUDA_CORE_ARTIFACTS_DIR=$(realpath "$REPO_DIR/cuda_core/dist")" >> $GITHUB_ENV
70+
CUDA_BINDINGS_ARTIFACT_BASENAME="cuda-bindings-python${PYTHON_VERSION_FORMATTED}-cuda${{ inputs.cuda-version }}-${{ inputs.host-platform }}"
71+
echo "CUDA_BINDINGS_ARTIFACT_BASENAME=${CUDA_BINDINGS_ARTIFACT_BASENAME}" >> $GITHUB_ENV
72+
echo "CUDA_BINDINGS_ARTIFACT_NAME=${CUDA_BINDINGS_ARTIFACT_BASENAME}-${{ github.sha }}" >> $GITHUB_ENV
73+
echo "CUDA_BINDINGS_ARTIFACTS_DIR=$(realpath "$REPO_DIR/cuda_bindings/dist")" >> $GITHUB_ENV
74+
echo "CIBW_BUILD=${CIBW_BUILD}" >> $GITHUB_ENV
75+
76+
- name: Dump environment
77+
run: |
78+
env
79+
80+
- name: Build cuda.core wheel
81+
uses: pypa/cibuildwheel@v2.22.0
82+
env:
83+
CIBW_BUILD: ${{ env.CIBW_BUILD }}
84+
CIBW_ARCHS_LINUX: "native"
85+
CIBW_BUILD_VERBOSITY: 1
86+
with:
87+
package-dir: ./cuda_core/
88+
output-dir: ${{ env.CUDA_CORE_ARTIFACTS_DIR }}
89+
90+
- name: List the cuda.core artifacts directory
91+
run: |
92+
if [[ "${{ inputs.host-platform }}" == win* ]]; then
93+
export CHOWN=chown
94+
else
95+
export CHOWN="sudo chown"
96+
fi
97+
$CHOWN -R $(whoami) ${{ env.CUDA_CORE_ARTIFACTS_DIR }}
98+
ls -lahR ${{ env.CUDA_CORE_ARTIFACTS_DIR }}
99+
100+
- name: Check cuda.core wheel
101+
run: |
102+
pip install twine
103+
twine check ${{ env.CUDA_CORE_ARTIFACTS_DIR }}/*.whl
104+
105+
- name: Upload cuda.core build artifacts
106+
uses: actions/upload-artifact@v4
107+
with:
108+
name: ${{ env.CUDA_CORE_ARTIFACT_NAME }}
109+
path: ${{ env.CUDA_CORE_ARTIFACTS_DIR }}/*.whl
110+
if-no-files-found: error
111+
112+
- name: Set up mini CTK
113+
uses: ./.github/actions/fetch_ctk
114+
continue-on-error: false
115+
with:
116+
host-platform: ${{ inputs.host-platform }}
117+
cuda-version: ${{ inputs.cuda-version }}
118+
119+
- name: Build cuda.bindings wheel
120+
uses: pypa/cibuildwheel@v2.22.0
121+
env:
122+
CIBW_BUILD: ${{ env.CIBW_BUILD }}
123+
CIBW_ARCHS_LINUX: "native"
124+
CIBW_BUILD_VERBOSITY: 1
125+
# CIBW mounts the host filesystem under /host
126+
CIBW_ENVIRONMENT_LINUX: >
127+
CUDA_PATH=/host/${{ env.CUDA_PATH }}
128+
LIBRARY_PATH=/host/${{ env.CUDA_PATH }}/lib
129+
CUDA_BINDINGS_PARALLEL_LEVEL=${{ env.CUDA_BINDINGS_PARALLEL_LEVEL }}
130+
CIBW_ENVIRONMENT_WINDOWS: >
131+
CUDA_HOME="$(cygpath -w ${{ env.CUDA_PATH }})"
132+
LIB="${CUDA_HOME}\\lib\\x64;${LIB}"
133+
CUDA_BINDINGS_PARALLEL_LEVEL=${{ env.CUDA_BINDINGS_PARALLEL_LEVEL }}
134+
with:
135+
package-dir: ./cuda_bindings/
136+
output-dir: ${{ env.CUDA_BINDINGS_ARTIFACTS_DIR }}
137+
138+
- name: List the cuda.bindings artifacts directory
139+
run: |
140+
if [[ "${{ inputs.host-platform }}" == win* ]]; then
141+
export CHOWN=chown
142+
else
143+
export CHOWN="sudo chown"
144+
fi
145+
$CHOWN -R $(whoami) ${{ env.CUDA_BINDINGS_ARTIFACTS_DIR }}
146+
ls -lahR ${{ env.CUDA_BINDINGS_ARTIFACTS_DIR }}
147+
148+
- name: Check cuda.bindings wheel
149+
run: |
150+
twine check ${{ env.CUDA_BINDINGS_ARTIFACTS_DIR }}/*.whl
151+
152+
- name: Upload cuda.bindings build artifacts
153+
uses: actions/upload-artifact@v4
154+
with:
155+
name: ${{ env.CUDA_BINDINGS_ARTIFACT_NAME }}
156+
path: ${{ env.CUDA_BINDINGS_ARTIFACTS_DIR }}/*.whl
157+
if-no-files-found: error
158+
159+
# We only need/want a single pure python wheel, pick linux-64 index 0.
160+
- name: Build and check cuda-python wheel
161+
if: ${{ strategy.job-index == 0 && inputs.host-platform == 'linux-64' }}
162+
run: |
163+
pushd cuda_python
164+
pip wheel -v --no-deps .
165+
twine check *.whl
166+
popd
167+
168+
- name: List the cuda-python artifacts directory
169+
if: ${{ strategy.job-index == 0 && inputs.host-platform == 'linux-64' }}
170+
run: |
171+
if [[ "${{ inputs.host-platform }}" == win* ]]; then
172+
export CHOWN=chown
173+
else
174+
export CHOWN="sudo chown"
175+
fi
176+
$CHOWN -R $(whoami) cuda_python/*.whl
177+
ls -lahR cuda_python
178+
179+
- name: Upload cuda-python build artifacts
180+
if: ${{ strategy.job-index == 0 && inputs.host-platform == 'linux-64' }}
181+
uses: actions/upload-artifact@v4
182+
with:
183+
name: cuda-python-wheel
184+
path: cuda_python/*.whl
185+
if-no-files-found: error

.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)