-
Notifications
You must be signed in to change notification settings - Fork 603
122 lines (102 loc) · 3.35 KB
/
tests-gpu.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
name: GPU Tests
on:
push:
branches:
- master
pull_request:
types:
- opened
- reopened
- labeled
- synchronize
concurrency:
group: gpu-test-${{ github.ref }}
cancel-in-progress: true
env:
TORCH_VERSION: 2.2.0
jobs:
gpu-tests:
runs-on:
- self-hosted
- ubuntu-22.04
- gpu
if: >-
${{
github.event_name == 'push' ||
(
github.event_name == 'pull_request' &&
contains(github.event.pull_request.labels.*.name, 'gpu') &&
github.event.pull_request.state == 'open'
)
}}
strategy:
max-parallel: 2
matrix:
python-version:
- 3.9
- '3.10'
- '3.11'
env:
SUITE: gpu
steps:
- name: Update PATH and LD_LIBRARY_PATH
run: |
echo "$HOME/.local/bin" >> $GITHUB_PATH
echo "/usr/local/cuda/bin" >> $GITHUB_PATH
echo "LD_LIBRARY_PATH=/usr/local/cuda/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}" >> $GITHUB_ENV
- name: Checkout Repo
uses: actions/checkout@v3
with:
fetch-depth: 1
- name: Setup Python
id: setup_python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
# Since the self-hosted runner can be re-used. It is best to set up all package
# installations in a virtual environment that gets cleaned at the end of each workflow run
- name: Setup Python virtual environment
id: setup_venv
env:
VENV_NAME: ${{ github.workspace }}/venv_${{ steps.setup_python.outputs.python-version }}_${{ github.sha }}
run: |
# Clear any pre-existing venvs
rm -rf venv_*
# Create new venv for this workflow_run
python --version
python -m venv ${{ env.VENV_NAME }}
# Add the venv to PATH for subsequent steps
echo ${{ env.VENV_NAME }}/bin >> $GITHUB_PATH
# Adding venv name as an output for subsequent steps to reference if needed
echo "venv_name=${{ env.VENV_NAME }}" >> $GITHUB_OUTPUT
- name: Display Python-Path
run: |
which python
which pip
- name: Install dependencies
run: |
python -m pip install --upgrade pip && pip install wheel --upgrade
pip install -r requirements-ci.txt --upgrade
pip install -r requirements-dev.txt --upgrade
- name: Install Torch
run: |
python -m pip install --no-cache-dir torch==${{ env.TORCH_VERSION }} -f https://download.pytorch.org/whl/cu118/torch_stable.html
- name: Install PennyLane
run: |
python setup.py bdist_wheel
pip install dist/PennyLane*.whl
- name: Install Lightning-master
run: python -m pip install -i https://test.pypi.org/simple/ PennyLane-Lightning --pre --upgrade
- name: Run tests
run: python -m pytest -m "${{ env.SUITE }}" tests
# Cleans up the working directory so subsequent jobs on same runner get a clean working directory
# This step runs even if any of the previous steps fail
- name: Cleanup
if: always()
run: |
rm -rf ${{ steps.setup_venv.outputs.venv_name }}
rm -rf *
rm -rf .git
rm -rf .gitignore
rm -rf .github
pip cache purge