-
Notifications
You must be signed in to change notification settings - Fork 152
148 lines (131 loc) · 5.27 KB
/
ci-test.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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
# Copyright (c) 2020, yolort team. All rights reserved.
name: CI testing
on:
push:
branches:
- main
- release/*
pull_request:
branches:
- main
- release/*
jobs:
Unittest:
runs-on: ${{ matrix.image }}
strategy:
fail-fast: false
matrix:
image:
- ubuntu-latest
torch:
- PyTorch 1.9.1+cpu
- PyTorch 1.10.2+cpu
- PyTorch 1.11.0+cpu
- PyTorch 1.12.1+cpu
- PyTorch 1.13.1+cpu
include:
- torch: PyTorch 1.9.1+cpu
torch_address: torch==1.9.1+cpu torchvision==0.10.1+cpu -f https://download.pytorch.org/whl/torch_stable.html
unittest_type: -v --cov=test --cov-report=xml
torchvision: release/0.10
- torch: PyTorch 1.10.2+cpu
torch_address: torch==1.10.2+cpu torchvision==0.11.3+cpu -f https://download.pytorch.org/whl/cpu/torch_stable.html
unittest_type: -v --cov=test --cov-report=xml
torchvision: release/0.11
- torch: PyTorch 1.11.0+cpu
torch_address: torch==1.11.0+cpu torchvision==0.12.0+cpu --extra-index-url https://download.pytorch.org/whl/cpu
unittest_type: -v --cov=test --cov-report=xml
torchvision: release/0.12
- torch: PyTorch 1.12.1+cpu
torch_address: torch==1.12.1+cpu torchvision==0.13.1+cpu --extra-index-url https://download.pytorch.org/whl/cpu
unittest_type: -v --cov=test --cov-report=xml
torchvision: release/0.13
- torch: PyTorch 1.13.1+cpu
torch_address: torch==1.13.1+cpu torchvision==0.14.1+cpu --extra-index-url https://download.pytorch.org/whl/cpu
unittest_type: -v --cov=test --cov-report=xml
torchvision: release/0.14
steps:
- name: Clone repository
uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/[email protected]
with:
python-version: 3.8
- name: Upgrade pip
run: |
# install pip=>20.1 to use "pip cache dir"
python -m pip install --user --progress-bar off --upgrade pip
- name: Get pip cache dir
id: pip-cache
run: echo "::set-output name=dir::$(pip cache dir)"
- name: Cache dependencies
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install ${{ matrix.torch }}
run: |
# requirements for PyTorch and torchvision
pip install --user --progress-bar off numpy pillow scipy
pip install --user --progress-bar off ${{ matrix.torch_address }}
- name: Install dependencies for developers
run: |
# requirements for unittest
pip install --user --progress-bar off flake8 pytest
pip install --user --progress-bar off pytest-cov
# Install other dependencies
pip install --user --progress-bar off opencv-python
pip install --user --progress-bar off pycocotools>=2.0.2
pip install --user --progress-bar off onnx
pip install --user --progress-bar off onnxruntime
pip install --user --progress-bar off requests
pip install --user onnx_graphsurgeon --index-url https://pypi.ngc.nvidia.com
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=18 --max-line-length=120 --statistics
- name: Install yolort
run: |
pip install -e .
- name: Test and Generate coverage report
run: |
PYTORCH_TEST_WITH_SLOW=1 pytest ${{ matrix.unittest_type }}
- name: Upload coverage to Codecov
uses: codecov/[email protected]
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: ./coverage.xml
flags: unittests
env_vars: OS,PYTHON
name: codecov-umbrella
fail_ci_if_error: true
verbose: true
- name: Build LibTorchVision for ${{ matrix.torch }}
run: |
export TORCH_PATH=$(dirname $(python -c "import torch; print(torch.__file__)"))
cd ..
git clone https://github.com/pytorch/vision.git vision
cd vision
git checkout ${{ matrix.torchvision }}
mkdir build && cd build
cmake .. -DTorch_DIR=$TORCH_PATH/share/cmake/Torch
make -j4
sudo make install
- name: Export torchscript model
run: |
python test/tracing/trace_model.py
- name: Test libtorch tracing
run: |
export TORCH_PATH=$(dirname $(python -c "import torch; print(torch.__file__)"))
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$TORCH_PATH/lib/
cd test/tracing
mkdir build && cd build
cmake .. -DTorch_DIR=$TORCH_PATH/share/cmake/Torch
make
mv ../yolov5s.torchscript.pt ./
echo ">> Test libtorch tracing"
./test_tracing