Skip to content

Commit 185233e

Browse files
authored
CI: add a GPU CI job (scipy#22275)
1 parent b84d904 commit 185233e

File tree

4 files changed

+5505
-0
lines changed

4 files changed

+5505
-0
lines changed

.github/workflows/gpu-ci.yml

+115
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
name: GPU jobs
2+
3+
# Updating the Pixi lock file:
4+
#
5+
# 1. Please try to avoid this unless it's actually necessary. Updating the lock
6+
# file generates a large diff, and triggers a lot of large package downloads
7+
# (also for local testing by maintainers).
8+
# 2. Consider committing the `pixi.toml` change in one commit, and the
9+
# `pixi.lock` change in a second commit. This allows the reviewer to redo
10+
# the lock file changes locally, or discard them in case of conflicts while
11+
# still keeping the `pixi.toml` changes.
12+
#
13+
#
14+
# In order to run a CI job step locally on a Linux machine with an NVIDIA GPU:
15+
#
16+
# $ cd .github/workflows
17+
# $ pixi run build
18+
# $ pixi run -e cupy test-cupy -v -m "array_api_backends and not slow"
19+
#
20+
# Or run different test commands in the same environments, e.g.:
21+
#
22+
# $ pixi run test-torch-cuda -s special
23+
# $ pixi run test-torch -s special
24+
#
25+
# To see available tasks per environment:
26+
#
27+
# $ pixi task ls -s
28+
29+
on:
30+
push:
31+
branches:
32+
- maintenance/**
33+
pull_request:
34+
branches:
35+
- main
36+
- maintenance/**
37+
38+
permissions:
39+
contents: read # to fetch code (actions/checkout)
40+
41+
env:
42+
CCACHE_DIR: "${{ github.workspace }}/.ccache"
43+
PIXI_CACHE_DIR: "${{ github.workspace }}/.cache/rattler"
44+
45+
concurrency:
46+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
47+
cancel-in-progress: true
48+
49+
jobs:
50+
get_commit_message:
51+
name: Get commit message
52+
uses: ./.github/workflows/commit_message.yml
53+
if: >
54+
needs.get_commit_message.outputs.message == 1
55+
&& (github.repository == 'scipy/scipy' || github.repository == '')
56+
57+
pytorch_gpu:
58+
name: PyTorch, JAX, CuPy GPU
59+
needs: get_commit_message
60+
runs-on: ghcr.io/cirruslabs/ubuntu-runner-amd64-gpu:22.04
61+
steps:
62+
- name: Checkout scipy repo
63+
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
64+
with:
65+
submodules: recursive
66+
67+
- name: Cache pixi
68+
uses: cirruslabs/cache@v4 #caa3ad0624c6c2acd8ba50ad452d1f44bba078bb # v4
69+
with:
70+
path: ${{ env.PIXI_CACHE_DIR }}
71+
# Cache hit if lock file did not change. If it did, still restore the cache,
72+
# since most packages will still be the same - the cache save will
73+
# then happen at the end (in case the lock file didn't change,
74+
# nothing is saved at the end of a job).
75+
key: ${{ runner.os }}-gpu-pixi-${{ hashFiles('.github/workflows/pixi.lock') }}
76+
restore-keys: |
77+
${{ runner.os }}-gpu-pixi
78+
79+
- name: Setup compiler cache
80+
uses: cirruslabs/cache@v4 #caa3ad0624c6c2acd8ba50ad452d1f44bba078bb # v4
81+
with:
82+
path: ${{ env.CCACHE_DIR }}
83+
# Make primary key unique by using `run_id`, this ensures the cache
84+
# is always saved at the end.
85+
key: ${{ runner.os }}-gpu-ccache-${{ github.run_id }}
86+
restore-keys: |
87+
${{ runner.os }}-gpu-ccache
88+
89+
- name: run nvidia-smi
90+
run: nvidia-smi
91+
92+
- name: run nvidia-smi --query
93+
run: nvidia-smi --query
94+
95+
- uses: prefix-dev/setup-pixi@ba3bb36eb2066252b2363392b7739741bb777659 # v0.8.1
96+
with:
97+
pixi-version: v0.39.2
98+
manifest-path: .github/workflows/pixi.toml
99+
cache: false
100+
101+
- name: Build SciPy
102+
working-directory: .github/workflows
103+
run: pixi run build
104+
105+
- name: Run PyTorch GPU tests
106+
working-directory: .github/workflows
107+
run: pixi run -e torch-cuda test-torch-cuda -v -m "array_api_backends and not slow"
108+
109+
- name: Run JAX GPU tests
110+
working-directory: .github/workflows
111+
run: pixi run -e jax-cuda test-jax-cuda -v -m "array_api_backends and not slow"
112+
113+
- name: Run CuPy tests
114+
working-directory: .github/workflows
115+
run: pixi run -e cupy test-cupy -v -m "array_api_backends and not slow"

0 commit comments

Comments
 (0)