Skip to content

Commit 57a710a

Browse files
authored
Merge pull request #368 from leofang/wheel_test
Test against CUDA wheels
2 parents 604fcac + 97c8c3e commit 57a710a

File tree

5 files changed

+221
-166
lines changed

5 files changed

+221
-166
lines changed

.github/workflows/build-and-test.yml

Lines changed: 15 additions & 163 deletions
Original file line numberDiff line numberDiff line change
@@ -198,181 +198,33 @@ jobs:
198198
- "12.6.2"
199199
- "12.0.1"
200200
- "11.8.0"
201+
local-ctk:
202+
- 1 # use mini CTK
203+
- 0 # use CTK wheels
201204
runner:
202205
- default
203206
include:
204207
- host-platform: linux-64
205208
python-version: "3.12"
206209
cuda-version: "12.6.2"
207210
runner: H100
208-
name: Test (${{ matrix.host-platform }}, Python ${{ matrix.python-version }}, CUDA ${{ matrix.cuda-version }}, Runner ${{ matrix.runner }})
211+
name: Test (${{ matrix.host-platform }}, Python ${{ matrix.python-version }}, CUDA ${{ matrix.cuda-version }}, Runner ${{ matrix.runner }}, ${{ (matrix.local-ctk == '1' && 'local CTK') || 'CTK wheels' }})
209212
# The build stage could fail but we want the CI to keep moving.
210213
if: ${{ github.repository_owner == 'nvidia' && !cancelled() }}
211214
permissions:
212-
id-token: write # This is required for configure-aws-credentials
213215
contents: read # This is required for actions/checkout
214-
runs-on: ${{ (matrix.runner == 'default' && matrix.host-platform == 'linux-64' && 'linux-amd64-gpu-v100-latest-1') ||
215-
(matrix.runner == 'default' && matrix.host-platform == 'linux-aarch64' && 'linux-arm64-gpu-a100-latest-1') ||
216-
(matrix.runner == 'H100' && 'linux-amd64-gpu-h100-latest-1-testing') }}
217-
# Our self-hosted runners require a container
218-
# TODO: use a different (nvidia?) container
219-
container:
220-
options: -u root --security-opt seccomp=unconfined --shm-size 16g
221-
image: ubuntu:22.04
222-
env:
223-
NVIDIA_VISIBLE_DEVICES: ${{ env.NVIDIA_VISIBLE_DEVICES }}
224216
needs:
225217
- build
226-
defaults:
227-
run:
228-
shell: bash --noprofile --norc -xeuo pipefail {0}
229-
steps:
230-
- name: Ensure GPU is working
231-
run: nvidia-smi
232-
233-
- name: Checkout ${{ github.event.repository.name }}
234-
uses: actions/checkout@v4
235-
with:
236-
fetch-depth: 0
237-
238-
- name: Set environment variables
239-
run: |
240-
PYTHON_VERSION_FORMATTED=$(echo '${{ matrix.python-version }}' | tr -d '.')
241-
if [[ "${{ matrix.host-platform }}" == linux* ]]; then
242-
REPO_DIR=$(pwd)
243-
elif [[ "${{ matrix.host-platform }}" == win* ]]; then
244-
PWD=$(pwd)
245-
REPO_DIR=$(cygpath -w $PWD)
246-
fi
247-
248-
BUILD_CUDA_MAJOR="$(cut -d '.' -f 1 <<< ${{ needs.build.outputs.BUILD_CTK_VER }})"
249-
TEST_CUDA_MAJOR="$(cut -d '.' -f 1 <<< ${{ matrix.cuda-version }})"
250-
if [[ $BUILD_CUDA_MAJOR != $TEST_CUDA_MAJOR ]]; then
251-
SKIP_CUDA_BINDINGS_TEST=1
252-
else
253-
SKIP_CUDA_BINDINGS_TEST=0
254-
fi
255-
256-
# make outputs from the previous job as env vars
257-
CUDA_CORE_ARTIFACT_BASENAME="cuda-core-python${PYTHON_VERSION_FORMATTED}-${{ matrix.host-platform }}"
258-
echo "PYTHON_VERSION_FORMATTED=${PYTHON_VERSION_FORMATTED}" >> $GITHUB_ENV
259-
echo "CUDA_CORE_ARTIFACT_BASENAME=${CUDA_CORE_ARTIFACT_BASENAME}" >> $GITHUB_ENV
260-
echo "CUDA_CORE_ARTIFACT_NAME=${CUDA_CORE_ARTIFACT_BASENAME}-${{ github.sha }}" >> $GITHUB_ENV
261-
echo "CUDA_CORE_ARTIFACTS_DIR=$(realpath "$REPO_DIR/cuda_core/dist")" >> $GITHUB_ENV
262-
CUDA_BINDINGS_ARTIFACT_BASENAME="cuda-bindings-python${PYTHON_VERSION_FORMATTED}-cuda${{ needs.build.outputs.BUILD_CTK_VER }}-${{ matrix.host-platform }}"
263-
echo "CUDA_BINDINGS_ARTIFACT_BASENAME=${CUDA_BINDINGS_ARTIFACT_BASENAME}" >> $GITHUB_ENV
264-
echo "CUDA_BINDINGS_ARTIFACT_NAME=${CUDA_BINDINGS_ARTIFACT_BASENAME}-${{ github.sha }}" >> $GITHUB_ENV
265-
echo "CUDA_BINDINGS_ARTIFACTS_DIR=$(realpath "$REPO_DIR/cuda_bindings/dist")" >> $GITHUB_ENV
266-
echo "SKIP_CUDA_BINDINGS_TEST=${SKIP_CUDA_BINDINGS_TEST}" >> $GITHUB_ENV
267-
268-
- name: Install dependencies
269-
uses: ./.github/actions/install_unix_deps
270-
continue-on-error: false
271-
with:
272-
# gcc for Cython tests, jq/wget for artifact fetching
273-
dependencies: "build-essential jq wget"
274-
dependent_exes: "gcc jq wget"
275-
276-
- name: Download cuda.bindings build artifacts
277-
if: ${{ env.SKIP_CUDA_BINDINGS_TEST == '0'}}
278-
uses: actions/download-artifact@v4
279-
with:
280-
name: ${{ env.CUDA_BINDINGS_ARTIFACT_NAME }}
281-
path: ${{ env.CUDA_BINDINGS_ARTIFACTS_DIR }}
282-
283-
- name: Download cuda.bindings build artifacts from the prior branch
284-
if: ${{ env.SKIP_CUDA_BINDINGS_TEST == '1'}}
285-
env:
286-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
287-
run: |
288-
# See https://github.com/cli/cli/blob/trunk/docs/install_linux.md#debian-ubuntu-linux-raspberry-pi-os-apt.
289-
# gh is needed for artifact fetching.
290-
mkdir -p -m 755 /etc/apt/keyrings \
291-
&& out=$(mktemp) && wget -nv -O$out https://cli.github.com/packages/githubcli-archive-keyring.gpg \
292-
&& cat $out | tee /etc/apt/keyrings/githubcli-archive-keyring.gpg > /dev/null \
293-
&& chmod go+r /etc/apt/keyrings/githubcli-archive-keyring.gpg \
294-
&& echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | tee /etc/apt/sources.list.d/github-cli.list > /dev/null \
295-
&& apt update \
296-
&& apt install gh -y
297-
298-
OLD_BRANCH=$(cat .github/BACKPORT_BRANCH)
299-
OLD_BASENAME="cuda-bindings-python${PYTHON_VERSION_FORMATTED}-cuda*-${{ matrix.host-platform }}*"
300-
LATEST_PRIOR_RUN_ID=$(gh run list -b ${OLD_BRANCH} -L 1 -w "CI: Build and test" -s completed -R NVIDIA/cuda-python --json databaseId | jq '.[]| .databaseId')
301-
gh run download $LATEST_PRIOR_RUN_ID -p ${OLD_BASENAME} -R NVIDIA/cuda-python
302-
ls -al $OLD_BASENAME
303-
mkdir -p "${{ env.CUDA_BINDINGS_ARTIFACTS_DIR }}"
304-
mv $OLD_BASENAME/*.whl "${{ env.CUDA_BINDINGS_ARTIFACTS_DIR }}"/
305-
306-
- name: Display structure of downloaded cuda.bindings artifacts
307-
run: |
308-
pwd
309-
ls -lahR $CUDA_BINDINGS_ARTIFACTS_DIR
310-
311-
- name: Download cuda.core build artifacts
312-
uses: actions/download-artifact@v4
313-
with:
314-
name: ${{ env.CUDA_CORE_ARTIFACT_NAME }}
315-
path: ${{ env.CUDA_CORE_ARTIFACTS_DIR }}
316-
317-
- name: Display structure of downloaded cuda.core build artifacts
318-
run: |
319-
pwd
320-
ls -lahR $CUDA_CORE_ARTIFACTS_DIR
321-
322-
- name: Set up Python ${{ matrix.python-version }}
323-
uses: actions/setup-python@v5
324-
with:
325-
python-version: ${{ matrix.python-version }}
326-
env:
327-
# we use self-hosted runners on which setup-python behaves weirdly...
328-
AGENT_TOOLSDIRECTORY: "/opt/hostedtoolcache"
329-
330-
- name: Set up mini CTK
331-
uses: ./.github/actions/fetch_ctk
332-
continue-on-error: false
333-
with:
334-
host-platform: ${{ matrix.host-platform }}
335-
cuda-version: ${{ matrix.cuda-version }}
336-
337-
- name: Run cuda.bindings tests
338-
if: ${{ env.SKIP_CUDA_BINDINGS_TEST == '0' }}
339-
run: |
340-
ls $CUDA_PATH
341-
342-
pushd "${CUDA_BINDINGS_ARTIFACTS_DIR}"
343-
pip install *.whl
344-
popd
345-
346-
pushd ./cuda_bindings
347-
pip install -r requirements.txt
348-
pytest -rxXs tests/
349-
if [[ "${{ matrix.host-platform }}" == linux* ]]; then
350-
bash tests/cython/build_tests.sh
351-
elif [[ "${{ matrix.host-platform }}" == win* ]]; then
352-
# TODO: enable this once win-64 runners are up
353-
exit 1
354-
fi
355-
pytest -rxXs tests/cython
356-
popd
357-
358-
- name: Run cuda.core tests
359-
run: |
360-
# If build/test majors match: cuda.bindings is installed in the previous step.
361-
# If mismatch: cuda.bindings is installed from the backport branch.
362-
if [[ "${SKIP_CUDA_BINDINGS_TEST}" == 1 ]]; then
363-
pushd "${CUDA_BINDINGS_ARTIFACTS_DIR}"
364-
pip install *.whl
365-
popd
366-
fi
367-
TEST_CUDA_MAJOR="$(cut -d '.' -f 1 <<< ${{ matrix.cuda-version }})"
368-
pushd "${CUDA_CORE_ARTIFACTS_DIR}"
369-
pip install $(ls *.whl)["cu${TEST_CUDA_MAJOR}"]
370-
popd
371-
372-
pushd ./cuda_core
373-
pip install -r "tests/requirements-cu${TEST_CUDA_MAJOR}.txt"
374-
pytest -rxXs tests/
375-
popd
218+
secrets: inherit
219+
uses:
220+
./.github/workflows/test-wheel.yml
221+
with:
222+
host-platform: ${{ matrix.host-platform }}
223+
python-version: ${{ matrix.python-version }}
224+
build-ctk-ver: ${{ needs.build.outputs.BUILD_CTK_VER }}
225+
cuda-version: ${{ matrix.cuda-version }}
226+
local-ctk: ${{ matrix.local-ctk}}
227+
runner: ${{ matrix.runner }}
376228

377229
doc:
378230
name: Docs
@@ -388,7 +240,7 @@ jobs:
388240
uses:
389241
./.github/workflows/build-docs.yml
390242
with:
391-
build_ctk_ver: ${{ needs.build.outputs.BUILD_CTK_VER }}
243+
build-ctk-ver: ${{ needs.build.outputs.BUILD_CTK_VER }}
392244

393245
checks:
394246
name: Check job status

.github/workflows/build-docs.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: "CI: Build and update docs"
33
on:
44
workflow_call:
55
inputs:
6-
build_ctk_ver:
6+
build-ctk-ver:
77
type: string
88
required: true
99

@@ -53,7 +53,7 @@ jobs:
5353
continue-on-error: false
5454
with:
5555
host-platform: linux-64
56-
cuda-version: ${{ inputs.build_ctk_ver }}
56+
cuda-version: ${{ inputs.build-ctk-ver }}
5757

5858
- name: Set environment variables
5959
run: |
@@ -65,7 +65,7 @@ jobs:
6565
echo "CUDA_CORE_ARTIFACT_BASENAME=${CUDA_CORE_ARTIFACT_BASENAME}" >> $GITHUB_ENV
6666
echo "CUDA_CORE_ARTIFACT_NAME=${CUDA_CORE_ARTIFACT_BASENAME}-${{ github.sha }}" >> $GITHUB_ENV
6767
echo "CUDA_CORE_ARTIFACTS_DIR=$(realpath "$REPO_DIR/cuda_core/dist")" >> $GITHUB_ENV
68-
CUDA_BINDINGS_ARTIFACT_BASENAME="cuda-bindings-python${PYTHON_VERSION_FORMATTED}-cuda${{ inputs.build_ctk_ver }}-linux-64"
68+
CUDA_BINDINGS_ARTIFACT_BASENAME="cuda-bindings-python${PYTHON_VERSION_FORMATTED}-cuda${{ inputs.build-ctk-ver }}-linux-64"
6969
echo "CUDA_BINDINGS_ARTIFACT_BASENAME=${CUDA_BINDINGS_ARTIFACT_BASENAME}" >> $GITHUB_ENV
7070
echo "CUDA_BINDINGS_ARTIFACT_NAME=${CUDA_BINDINGS_ARTIFACT_BASENAME}-${{ github.sha }}" >> $GITHUB_ENV
7171
echo "CUDA_BINDINGS_ARTIFACTS_DIR=$(realpath "$REPO_DIR/cuda_bindings/dist")" >> $GITHUB_ENV

0 commit comments

Comments
 (0)